Skip to content

Commit

Permalink
Source Stripe hotfix: correctly sync balance_transactions stream (#3131)
Browse files Browse the repository at this point in the history
  • Loading branch information
sherifnada committed Apr 29, 2021
1 parent fd0d253 commit 7c2406a
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 92 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.2
LABEL io.airbyte.version=0.1.3
LABEL io.airbyte.name=airbyte/source-stripe
Original file line number Diff line number Diff line change
@@ -1,5 +1,115 @@
{
"streams": [
{
"stream": {
"name": "customer_balance_transactions",
"json_schema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"object": {
"type": "string"
},
"amount": {
"type": "integer"
},
"created": {
"type": "integer"
},
"credit_note": {
"type": "string"
},
"currency": {
"type": "string"
},
"customer": {
"type": "string"
},
"description": {
"type": "string"
},
"ending_balance": {
"type": "integer"
},
"invoice": {
"type": "string"
},
"livemode": {
"type": "boolean"
},
"metadata": {
"type": "object",
"additionalProperties": true
},
"type": {
"type": "string"
}
}
},
"supported_sync_modes": ["incremental"],
"source_defined_cursor": true,
"default_cursor_field": ["created"]
},
"sync_mode": "incremental",
"destination_sync_mode": "overwrite",
"cursor_field": ["created"]
},
{
"sync_mode": "incremental",
"destination_sync_mode": "overwrite",
"stream": {
"name": "balance_transactions",
"json_schema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"object": {
"type": "string"
},
"amount": {
"type": "integer"
},
"created": {
"type": "integer"
},
"credit_note": {
"type": "string"
},
"currency": {
"type": "string"
},
"customer": {
"type": "string"
},
"description": {
"type": "string"
},
"ending_balance": {
"type": "integer"
},
"invoice": {
"type": "string"
},
"livemode": {
"type": "boolean"
},
"metadata": {
"type": "object",
"additionalProperties": true
},
"type": {
"type": "string"
}
}
}
}
},
{
"stream": {
"name": "charges",
Expand Down Expand Up @@ -3262,94 +3372,6 @@
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite",

"cursor_field": ["created"]
},
{
"stream": {
"name": "balance_transactions",
"json_schema": {
"properties": {
"fee": {
"type": ["null", "integer"]
},
"currency": {
"type": ["null", "string"]
},
"source": {
"type": ["null", "string"]
},
"fee_details": {
"type": ["null", "array"],
"items": {
"properties": {
"application": {
"type": ["null", "string"]
},
"type": {
"type": ["null", "string"]
},
"description": {
"type": ["null", "string"]
},
"amount": {
"type": ["null", "integer"]
},
"currency": {
"type": ["null", "string"]
}
},
"type": ["null", "object"]
}
},
"available_on": {
"type": ["null", "integer"]
},
"status": {
"type": ["null", "string"]
},
"description": {
"type": ["null", "string"]
},
"net": {
"type": ["null", "integer"]
},
"exchange_rate": {
"type": ["null", "number"]
},
"type": {
"type": ["null", "string"]
},
"sourced_transfers": {
"items": {},
"type": ["null", "array"]
},
"id": {
"type": ["null", "string"]
},
"object": {
"type": ["null", "string"]
},
"created": {
"type": ["null", "string"],
"format": "date-time"
},
"amount": {
"type": ["null", "integer"]
},
"updated": {
"type": ["null", "string"],
"format": "date-time"
}
},
"type": ["null", "object"]
},
"supported_sync_modes": ["incremental"],
"source_defined_cursor": true,
"default_cursor_field": ["created"]
},
"sync_mode": "incremental",
"destination_sync_mode": "overwrite",
"cursor_field": ["created"]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def path(self, stream_slice: Mapping[str, any] = None, **kwargs):
return f"customers/{customer_id}/balance_transactions"

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

Expand Down Expand Up @@ -268,6 +268,7 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
authenticator = TokenAuthenticator(config["client_secret"])
args = {"authenticator": authenticator, "account_id": config["account_id"]}
return [
BankAccounts(**args),
BalanceTransactions(**args),
Charges(**args),
Coupons(**args),
Expand All @@ -283,7 +284,6 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
Products(**args),
Subscriptions(**args),
SubscriptionItems(**args),
Transfers(**args),
Refunds(**args),
BankAccounts(**args),
Transfers(**args),
]

0 comments on commit 7c2406a

Please sign in to comment.