Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source Stripe: external account streams #14357

Merged
merged 6 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@
- name: Stripe
sourceDefinitionId: e094cb9a-26de-4645-8761-65c0c425d1de
dockerRepository: airbyte/source-stripe
dockerImageTag: 0.1.34
dockerImageTag: 0.1.35
documentationUrl: https://docs.airbyte.io/integrations/sources/stripe
icon: stripe.svg
sourceType: api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9291,7 +9291,7 @@
type: "string"
path_in_connector_config:
- "client_secret"
- dockerImage: "airbyte/source-stripe:0.1.34"
- dockerImage: "airbyte/source-stripe:0.1.35"
spec:
documentationUrl: "https://docs.airbyte.io/integrations/sources/stripe"
connectionSpecification:
Expand Down
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 @@ RUN pip install .
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.34
LABEL io.airbyte.version=0.1.35
LABEL io.airbyte.name=airbyte/source-stripe
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"object": {
"type": ["string", "null"]
},
"account_holder_name": {
"type": ["string", "null"]
},
"account_holder_type": {
"type": ["string", "null"]
},
"account_type": {
"type": ["string", "null"]
},
"bank_name": {
"type": ["string", "null"]
},
"country": {
"type": ["string", "null"]
},
"currency": {
"type": ["string", "null"]
},
"fingerprint": {
"type": ["string", "null"]
},
"last4": {
"type": ["string", "null"]
},
"metadata": {
"type": ["object", "null"]
},
"routing_number": {
"type": ["string", "null"]
},
"status": {
"type": ["string", "null"]
},
"account": {
"type": ["string", "null"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"object": {
"type": ["string", "null"]
},
"address_city": {
"type": ["string", "null"]
},
"address_country": {
"type": ["string", "null"]
},
"address_line1": {
"type": ["string", "null"]
},
"address_line1_check": {
"type": ["string", "null"]
},
"address_line2": {
"type": ["string", "null"]
},
"address_state": {
"type": ["string", "null"]
},
"address_zip": {
"type": ["string", "null"]
},
"address_zip_check": {
"type": ["string", "null"]
},
"brand": {
"type": ["string", "null"]
},
"country": {
"type": ["string", "null"]
},
"cvc_check": {
"type": ["string", "null"]
},
"dynamic_last4": {
"type": ["string", "null"]
},
"exp_month": {
"type": ["integer", "null"]
},
"exp_year": {
"type": ["integer", "null"]
},
"fingerprint": {
"type": ["string", "null"]
},
"funding": {
"type": ["string", "null"]
},
"last4": {
"type": ["string", "null"]
},
"metadata": {
"type": ["object", "null"]
},
"name": {
"type": ["string", "null"]
},
"redaction": {
"type": ["string", "null"]
},
"tokenization_method": {
"type": ["string", "null"]
},
"account": {
"type": ["string", "null"]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
Customers,
Disputes,
Events,
ExternalAccountBankAccounts,
ExternalAccountCards,
InvoiceItems,
InvoiceLineItems,
Invoices,
Expand Down Expand Up @@ -74,4 +76,6 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
SubscriptionItems(**args),
Subscriptions(**incremental_args),
Transfers(**incremental_args),
ExternalAccountBankAccounts(**args),
ExternalAccountCards(**args),
]
Original file line number Diff line number Diff line change
Expand Up @@ -563,3 +563,34 @@ class PromotionCodes(IncrementalStripeStream):

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


class ExternalAccount(StripeStream, ABC):
"""
Bank Accounts and Cards are separate streams because they have different schemas
"""

object = ""

def path(self, **kwargs):
return f"accounts/{self.account_id}/external_accounts"

def request_params(self, **kwargs):
params = super().request_params(**kwargs)
return {**params, **{"object": self.object}}


class ExternalAccountBankAccounts(ExternalAccount):
"""
https://stripe.com/docs/api/external_account_bank_accounts/list
"""

object = "bank_account"


class ExternalAccountCards(ExternalAccount):
"""
https://stripe.com/docs/api/external_account_cards/list
"""

object = "card"
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_source_streams():
with open("sample_files/config.json") as f:
config = json.load(f)
streams = SourceStripe().streams(config=config)
assert len(streams) == 22
assert len(streams) == 24


@pytest.fixture(name="config")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
Customers,
Disputes,
Events,
ExternalAccount,
ExternalAccountBankAccounts,
ExternalAccountCards,
InvoiceItems,
InvoiceLineItems,
Invoices,
Expand Down Expand Up @@ -166,6 +169,7 @@ def config_fixture():
(CheckoutSessions, {}, "checkout/sessions"),
(CheckoutSessionsLineItems, {"stream_slice": {"checkout_session_id": "CS1"}}, "checkout/sessions/CS1/line_items"),
(PromotionCodes, {}, "promotion_codes"),
(ExternalAccount, {}, "accounts/<account_id>/external_accounts"),
],
)
def test_path(
Expand All @@ -188,6 +192,8 @@ def test_path(
(BankAccounts, {"stream_state": {}, "stream_slice": {"subscription_id": "SI"}}, {"limit": 100, "object": "bank_account"}),
(CheckoutSessions, {"stream_state": None}, {"limit": 100}),
(CheckoutSessionsLineItems, {"stream_state": None}, {"limit": 100, "expand[]": ["data.discounts", "data.taxes"]}),
(ExternalAccountBankAccounts, {"stream_state": None}, {"limit": 100, "object": "bank_account"}),
(ExternalAccountCards, {"stream_state": None}, {"limit": 100, "object": "card"}),
],
)
def test_request_params(
Expand Down
5 changes: 4 additions & 1 deletion docs/integrations/sources/stripe.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ The Stripe source connector supports the following streams:
* [Subscription Items](https://stripe.com/docs/api/subscription_items/list)
* [Subscriptions](https://stripe.com/docs/api/subscriptions/list) \(Incremental\)
* [Transfers](https://stripe.com/docs/api/transfers/list) \(Incremental\)
* [ExternalAccountBankAccounts](https://stripe.com/docs/api/external_account_bank_accounts/list)\(Full Refresh\)
* [ExternalAccountCards](https://stripe.com/docs/api/external_account_cards/list)\(Full Refresh\)

### Data type mapping

Expand All @@ -74,7 +76,8 @@ The Stripe connector should not run into Stripe API limitations under normal usa

| Version | Date | Pull Request | Subject |
|:--------|:-----------| :--- |:-------------------------------------------------------------------------------------------------------------------------------------------------------|
| 0.1.34 | 2022-07-21 | [14924](https://github.com/airbytehq/airbyte/pull/14924) | Remove `additionalProperties` field from spec and schema |
| 0.1.35 | 2022-07-21 | [14924](https://github.com/airbytehq/airbyte/pull/14924) | Remove `additionalProperties` field from spec and schema |
| 0.1.34 | 2022-07-01 | [14357](https://github.com/airbytehq/airbyte/pull/14357) | added external account streams |
| 0.1.33 | 2022-06-06 | [13449](https://github.com/airbytehq/airbyte/pull/13449) | added semi-incremental support for CheckoutSessions and CheckoutSessionsLineItems streams, fixed big in StripeSubStream, added unittests, updated docs |
| 0.1.32 | 2022-04-30 | [12500](https://github.com/airbytehq/airbyte/pull/12500) | Improve input configuration copy |
| 0.1.31 | 2022-04-20 | [12230](https://github.com/airbytehq/airbyte/pull/12230) | Update connector to use a `spec.yaml` |
Expand Down