Skip to content

Commit

Permalink
Source Stripe: 2 new streams - Refunds & Bank Accounts (#3030) (#3086)
Browse files Browse the repository at this point in the history
* Refunds & Bank Accounts streams for stripe (#3030)

Add two new streams:
Refunds - incremental stream.
Bank Accounts - full refresh stream.

* Refunds & Bank Accounts streams for stripe (#3030)

Update quotes in source.py file.

* Refunds & Bank Accounts streams for stripe (#3030)

Add state for `refunds` stream to sample_files/state.json file.
Update catalog data for `refunds` and `bank_accounts` streams in sample_files/full_catalog.json file.

* Refunds & Bank Accounts streams for stripe (#3030)

Update source-stripe connector version from `0.1.0` to `0.1.1`.
  • Loading branch information
Zirochkaa committed Apr 28, 2021
1 parent 5b5f53c commit 4a023f7
Show file tree
Hide file tree
Showing 6 changed files with 238 additions and 2 deletions.
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-stripe/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ COPY $CODE_PATH ./$CODE_PATH
COPY setup.py ./
RUN pip install .

LABEL io.airbyte.version=0.1.0
LABEL io.airbyte.version=0.1.1
LABEL io.airbyte.name=airbyte/source-stripe
Original file line number Diff line number Diff line change
Expand Up @@ -3767,6 +3767,120 @@
"sync_mode": "incremental",
"destination_sync_mode": "overwrite",
"cursor_field": ["created"]
},
{
"stream": {
"name": "refunds",
"json_schema": {
"type": ["null", "object"],
"properties": {
"id": {
"type": ["null", "string"]
},
"object": {
"type": ["null", "string"]
},
"amount": {
"type": ["null", "integer"]
},
"balance_transaction": {
"type": ["null", "string"]
},
"charge": {
"type": ["null", "string"]
},
"created": {
"type": ["null", "string"],
"format": "date-time"
},
"currency": {
"type": ["null", "string"]
},
"metadata": {
"type": ["null", "object"],
"properties": {}
},
"payment_intent": {
"type": ["null", "string"]
},
"reason": {
"type": ["null", "string"]
},
"receipt_number": {
"type": ["null", "string"]
},
"source_transfer_reversal": {
"type": ["null", "string"]
},
"status": {
"type": ["null", "string"]
},
"transfer_reversal": {
"type": ["null", "string"]
}
}
},
"supported_sync_modes": ["incremental"],
"source_defined_cursor": true,
"default_cursor_field": ["created"]
},
"sync_mode": "incremental",
"destination_sync_mode": "overwrite",
"cursor_field": ["created"]
},
{
"stream": {
"name": "bank_accounts",
"json_schema": {
"type": ["null", "object"],
"properties": {
"id": {
"type": ["null", "string"]
},
"object": {
"type": ["null", "string"]
},
"account_holder_name": {
"type": ["null", "string"]
},
"account_holder_type": {
"type": ["null", "string"]
},
"bank_name": {
"type": ["null", "string"]
},
"country": {
"type": ["null", "string"]
},
"currency": {
"type": ["null", "string"]
},
"customer": {
"type": ["null", "string"]
},
"fingerprint": {
"type": ["null", "integer"]
},
"last4": {
"type": ["null", "string"]
},
"metadata": {
"type": ["null", "object"],
"properties": {}
},
"routing_number": {
"type": ["null", "string"]
},
"status": {
"type": ["null", "string"]
}
}
},
"supported_sync_modes": ["full_refresh"],
"source_defined_cursor": false
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"balance_transactions": { "created": 1617067556 },
"payouts": { "created": 1617067556 },
"disputes": { "created": 1610996305 },
"products": { "created": 1585511341 }
"products": { "created": 1585511341 },
"refunds": { "created": 1619595629 }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"type": ["null", "object"],
"properties": {
"id": {
"type": ["null", "string"]
},
"object": {
"type": ["null", "string"]
},
"account_holder_name": {
"type": ["null", "string"]
},
"account_holder_type": {
"type": ["null", "string"]
},
"bank_name": {
"type": ["null", "string"]
},
"country": {
"type": ["null", "string"]
},
"currency": {
"type": ["null", "string"]
},
"customer": {
"type": ["null", "string"]
},
"fingerprint": {
"type": ["null", "integer"]
},
"last4": {
"type": ["null", "string"]
},
"metadata": {
"type": ["null", "object"],
"properties": {}
},
"routing_number": {
"type": ["null", "string"]
},
"status": {
"type": ["null", "string"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"type": ["null", "object"],
"properties": {
"id": {
"type": ["null", "string"]
},
"object": {
"type": ["null", "string"]
},
"amount": {
"type": ["null", "integer"]
},
"balance_transaction": {
"type": ["null", "string"]
},
"charge": {
"type": ["null", "string"]
},
"created": {
"type": ["null", "string"],
"format": "date-time"
},
"currency": {
"type": ["null", "string"]
},
"metadata": {
"type": ["null", "object"],
"properties": {}
},
"payment_intent": {
"type": ["null", "string"]
},
"reason": {
"type": ["null", "string"]
},
"receipt_number": {
"type": ["null", "string"]
},
"source_transfer_reversal": {
"type": ["null", "string"]
},
"status": {
"type": ["null", "string"]
},
"transfer_reversal": {
"type": ["null", "string"]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,31 @@ def path(self, **kwargs):
return "transfers"


class Refunds(IncrementalStripeStream):
cursor_field = "created"

def path(self, **kwargs):
return "refunds"


class BankAccounts(StripeStream):
name = "bank_accounts"

def path(self, stream_slice: Mapping[str, any] = None, **kwargs):
customer_id = stream_slice["customer_id"]
return f"customers/{customer_id}/sources"

def request_params(self, **kwargs) -> MutableMapping[str, Any]:
params = super().request_params(**kwargs)
params["object"] = "bank_account"
return params

def read_records(self, stream_slice: Optional[Mapping[str, Any]] = None, **kwargs) -> Iterable[Mapping[str, Any]]:
customers_stream = Customers(authenticator=self.authenticator)
for customer in customers_stream.read_records(sync_mode=SyncMode.full_refresh):
yield from super().read_records(stream_slice={"customer_id": customer["id"]}, **kwargs)


class SourceStripe(AbstractSource):
def check_connection(self, logger, config) -> Tuple[bool, any]:
try:
Expand Down Expand Up @@ -252,4 +277,6 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
Subscriptions(authenticator=authenticator),
SubscriptionItems(authenticator=authenticator),
Transfers(authenticator=authenticator),
Refunds(authenticator=authenticator),
BankAccounts(authenticator=authenticator),
]

0 comments on commit 4a023f7

Please sign in to comment.