1
0
mirror of synced 2025-12-25 02:09:19 -05:00

Source Stripe: New Stream - Persons (#26208)

* Initial Commit

* EOF

* Update airbyte-integrations/connectors/source-stripe/source_stripe/streams.py

Co-authored-by: Mal Hancock <mhancock@archangelic.space>

* Resolve Comments

* fix unittest

* fix SAT

* fix schema

---------

Co-authored-by: Mal Hancock <mhancock@archangelic.space>
Co-authored-by: midavadim <midavadim@yahoo.com>
This commit is contained in:
btkcodedev
2023-07-15 01:42:28 +05:30
committed by GitHub
parent b81cc031e0
commit 0a2cd5f757
11 changed files with 492 additions and 3 deletions

View File

@@ -14,5 +14,5 @@ ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
LABEL io.airbyte.version=3.11.0
LABEL io.airbyte.version=3.12.0
LABEL io.airbyte.name=airbyte/source-stripe

View File

@@ -42,6 +42,8 @@ acceptance_tests:
bypass_reason: "This stream can't be seeded in our sandbox account"
- name: "payment_methods"
bypass_reason: "this stream can't be seeded in our sandbox account"
- name: "persons"
bypass_reason: "this stream can't be seeded in our sandbox account"
- name: "reviews"
bypass_reason: "this stream can't be seeded in our sandbox account"
- name: "transfers"

View File

@@ -69,6 +69,13 @@
"stream_descriptor": { "name": "plans" }
}
},
{
"type": "STREAM",
"stream": {
"stream_state": { "created": 10000000000 },
"stream_descriptor": { "name": "persons" }
}
},
{
"type": "STREAM",
"stream": {

View File

@@ -193,6 +193,35 @@
"cursor_field": ["created"],
"primary_key": [["id"]]
},
{
"stream": {
"name": "persons",
"json_schema": {},
"supported_sync_modes": ["full_refresh", "incremental"],
"source_defined_cursor": true,
"default_cursor_field": ["created"],
"source_defined_primary_key": [["id"]]
},
"sync_mode": "incremental",
"destination_sync_mode": "overwrite",
"cursor_field": ["created"],
"primary_key": [["id"]]
},
{
"stream": {
"name": "products",
"json_schema": {},
"supported_sync_modes": ["full_refresh", "incremental"],
"source_defined_cursor": true,
"default_cursor_field": ["created"],
"source_defined_primary_key": [["id"]]
},
"sync_mode": "incremental",
"destination_sync_mode": "overwrite",
"cursor_field": ["created"],
"primary_key": [["id"]]
},
{
"stream": {
"name": "file_links",

View File

@@ -5,7 +5,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: e094cb9a-26de-4645-8761-65c0c425d1de
dockerImageTag: 3.11.0
dockerImageTag: 3.12.0
dockerRepository: airbyte/source-stripe
githubIssueLabel: source-stripe
icon: stripe.svg

View File

@@ -0,0 +1,422 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Persons Schema",
"additionalProperties": true,
"type": ["null", "object"],
"properties": {
"id": {
"type": ["null", "string"]
},
"object": {
"type": ["null", "string"]
},
"phone": {
"type": ["null", "string"]
},
"email": {
"type": ["null", "string"]
},
"address_kana": {
"type": ["null", "string"]
},
"address_kanji": {
"type": ["null", "string"]
},
"first_name_kana": {
"type": ["null", "string"]
},
"gender": {
"type": ["null", "string"]
},
"full_name_aliases": {
"type": ["null", "string"]
},
"id_number_secondary_provided": {
"type": ["null", "string"]
},
"first_name_kanji": {
"type": ["null", "string"]
},
"nationality": {
"type": ["null", "string"]
},
"political_exposure": {
"type": ["null", "string"]
},
"registered_address": {
"type": ["null", "string"]
},
"account": {
"type": ["null", "string"]
},
"address": {
"type": ["null", "object"],
"properties": {
"city": {
"type": ["null", "string"]
},
"country": {
"type": ["null", "string"]
},
"line1": {
"type": ["null", "string"]
},
"line2": {
"type": ["null", "string"]
},
"postal_code": {
"type": ["null", "string"]
},
"state": {
"type": ["null", "string"]
}
}
},
"created": {
"type": ["null", "integer"]
},
"dob": {
"type": ["null", "object"],
"properties": {
"day": {
"type": ["null", "integer"]
},
"month": {
"type": ["null", "integer"]
},
"year": {
"type": ["null", "integer"]
}
}
},
"first_name": {
"type": ["null", "string"]
},
"future_requirements": {
"type": ["null", "object"],
"properties": {
"alternatives": {
"type": ["null", "array"],
"items": {
"type": ["null", "string", "object"],
"properties": {
"flat_amount": {
"type": ["null", "integer"]
},
"unit_amount": {
"type": ["null", "integer"]
},
"up_to": {
"type": ["null", "integer"]
},
"alternative_fields_due": {
"type": ["null", "array"],
"items": {
"type": ["null", "string"]
}
},
"original_fields_due": {
"type": ["null", "array"],
"items": {
"type": ["null", "string"]
}
}
}
}
},
"currently_due": {
"type": ["null", "array"],
"items": {
"type": ["null", "string", "object"],
"properties": {
"flat_amount": {
"type": ["null", "integer"]
},
"unit_amount": {
"type": ["null", "integer"]
},
"up_to": {
"type": ["null", "integer"]
}
}
}
},
"errors": {
"type": ["null", "array"],
"items": {
"type": ["null", "string", "object"],
"properties": {
"flat_amount": {
"type": ["null", "integer"]
},
"unit_amount": {
"type": ["null", "integer"]
},
"up_to": {
"type": ["null", "integer"]
}
}
}
},
"eventually_due": {
"type": ["null", "array"],
"items": {
"type": ["null", "string", "object"],
"properties": {
"flat_amount": {
"type": ["null", "integer"]
},
"unit_amount": {
"type": ["null", "integer"]
},
"up_to": {
"type": ["null", "integer"]
}
}
}
},
"past_due": {
"type": ["null", "array"],
"items": {
"type": ["null", "string", "object"],
"properties": {
"flat_amount": {
"type": ["null", "integer"]
},
"unit_amount": {
"type": ["null", "integer"]
},
"up_to": {
"type": ["null", "integer"]
}
}
}
},
"pending_verification": {
"type": ["null", "array"],
"items": {
"type": ["null", "string", "object"],
"properties": {
"flat_amount": {
"type": ["null", "integer"]
},
"unit_amount": {
"type": ["null", "integer"]
},
"up_to": {
"type": ["null", "integer"]
}
}
}
}
}
},
"id_number_provided": {
"type": ["null", "boolean"]
},
"last_name": {
"type": ["null", "string"]
},
"metadata": {
"type": ["null", "object"],
"properties": {
"id_number_provided": {
"type": ["null", "boolean"]
}
}
},
"relationship": {
"type": ["null", "object"],
"properties": {
"director": {
"type": ["null", "boolean"]
},
"executive": {
"type": ["null", "boolean"]
},
"owner": {
"type": ["null", "boolean"]
},
"percent_ownership": {
"type": ["null", "string"]
},
"representative": {
"type": ["null", "boolean"]
},
"title": {
"type": ["null", "string"]
}
}
},
"requirements": {
"type": ["null", "object"],
"properties": {
"alternatives": {
"type": ["null", "array"],
"items": {
"type": ["null", "string", "object"],
"properties": {
"flat_amount": {
"type": ["null", "integer"]
},
"unit_amount": {
"type": ["null", "integer"]
},
"up_to": {
"type": ["null", "integer"]
},
"alternative_fields_due": {
"type": ["null", "array"],
"items": {
"type": ["null", "string"]
}
},
"original_fields_due": {
"type": ["null", "array"],
"items": {
"type": ["null", "string"]
}
}
}
}
},
"currently_due": {
"type": ["null", "array"],
"items": {
"type": ["null", "string", "object"],
"properties": {
"flat_amount": {
"type": ["null", "integer"]
},
"unit_amount": {
"type": ["null", "integer"]
},
"up_to": {
"type": ["null", "integer"]
}
}
}
},
"errors": {
"type": ["null", "array"],
"items": {
"type": ["null", "string", "object"],
"properties": {
"flat_amount": {
"type": ["null", "integer"]
},
"unit_amount": {
"type": ["null", "integer"]
},
"up_to": {
"type": ["null", "integer"]
}
}
}
},
"eventually_due": {
"type": ["null", "array"],
"items": {
"type": ["null", "string", "object"],
"properties": {
"flat_amount": {
"type": ["null", "integer"]
},
"unit_amount": {
"type": ["null", "integer"]
},
"up_to": {
"type": ["null", "integer"]
}
}
}
},
"past_due": {
"type": ["null", "array"],
"items": {
"type": ["null", "string", "object"],
"properties": {
"flat_amount": {
"type": ["null", "integer"]
},
"unit_amount": {
"type": ["null", "integer"]
},
"up_to": {
"type": ["null", "integer"]
}
}
}
},
"pending_verification": {
"type": ["null", "array"],
"items": {
"type": ["null", "string", "object"],
"properties": {
"flat_amount": {
"type": ["null", "integer"]
},
"unit_amount": {
"type": ["null", "integer"]
},
"up_to": {
"type": ["null", "integer"]
}
}
}
}
}
},
"ssn_last_4_provided": {
"type": ["null", "boolean"]
},
"verification": {
"type": ["null", "object"],
"properties": {
"additional_document": {
"type": ["null", "object"],
"properties": {
"back": {
"type": ["null", "string"]
},
"details": {
"type": ["null", "string"]
},
"details_code": {
"type": ["null", "string"]
},
"front": {
"type": ["null", "string"]
}
}
},
"details": {
"type": ["null", "string"]
},
"details_code": {
"type": ["null", "string"]
},
"document": {
"type": ["null", "object"],
"properties": {
"back": {
"type": ["null", "string"]
},
"details": {
"type": ["null", "string"]
},
"details_code": {
"type": ["null", "string"]
},
"front": {
"type": ["null", "string"]
}
}
},
"status": {
"type": ["null", "string"]
}
}
}
}
}

View File

@@ -40,6 +40,7 @@ from source_stripe.streams import (
PaymentIntents,
PaymentMethods,
Payouts,
Persons,
Plans,
Products,
PromotionCodes,
@@ -106,6 +107,7 @@ class SourceStripe(AbstractSource):
PaymentIntents(**incremental_args),
PaymentMethods(**args),
Payouts(**incremental_args),
Persons(**incremental_args),
Plans(**incremental_args),
Products(**incremental_args),
PromotionCodes(**incremental_args),

View File

@@ -807,6 +807,28 @@ class Accounts(BasePaginationStripeStream):
return "accounts"
class Persons(IncrementalStripeStream):
"""
API docs: https://stripe.com/docs/api/persons/list
"""
name = "persons"
cursor_field = "created"
def path(self, stream_slice: Mapping[str, Any] = None, **kwargs):
return f"accounts/{stream_slice['id']}/persons"
def stream_slices(
self, *, sync_mode: SyncMode, cursor_field: List[str] = None, stream_state: Mapping[str, Any] = None
) -> Iterable[Optional[Mapping[str, Any]]]:
parent_stream = Accounts(authenticator=self.authenticator, account_id=self.account_id, start_date=self.start_date)
slices = parent_stream.stream_slices(sync_mode=SyncMode.full_refresh)
for _slice in slices:
for account in parent_stream.read_records(sync_mode=SyncMode.full_refresh, stream_slice=_slice):
# we use `get` here because some attributes may not be returned by some API versions
yield account
class CreditNotes(StripeStream):
"""
API docs: https://stripe.com/docs/api/credit_notes/list
@@ -892,6 +914,7 @@ class SetupAttempts(IncrementalStripeStream, HttpSubStream):
def stream_slices(
self, *, sync_mode: SyncMode, cursor_field: List[str] = None, stream_state: Mapping[str, Any] = None
) -> Iterable[Optional[Mapping[str, Any]]]:
incremental_slices = list(
IncrementalStripeStream.stream_slices(self, sync_mode=sync_mode, cursor_field=cursor_field, stream_state=stream_state)
)

View File

@@ -42,7 +42,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) == 43
assert len(streams) == 44
@pytest.fixture(name="config")

View File

@@ -27,6 +27,7 @@ from source_stripe.streams import (
Invoices,
PaymentIntents,
Payouts,
Persons,
Plans,
Products,
PromotionCodes,
@@ -172,6 +173,7 @@ def config_fixture():
(InvoiceLineItems, {"stream_slice": {"invoice_id": "I1"}}, "invoices/I1/lines"),
(InvoiceItems, {}, "invoiceitems"),
(Payouts, {}, "payouts"),
(Persons, {"stream_slice": {"id": "A1"}}, "accounts/A1/persons"),
(Plans, {}, "plans"),
(Products, {}, "products"),
(Subscriptions, {}, "subscriptions"),

View File

@@ -71,6 +71,7 @@ The Stripe source connector supports the following streams:
- [Payment Methods](https://stripe.com/docs/api/payment_methods/list)
- [Payouts](https://stripe.com/docs/api/payouts/list) \(Incremental\)
- [Promotion Code](https://stripe.com/docs/api/promotion_codes/list) \(Incremental\)
- [Persons](https://stripe.com/docs/api/persons/list) \(Incremental\)
- [Plans](https://stripe.com/docs/api/plans/list) \(Incremental\)
- [Products](https://stripe.com/docs/api/products/list) \(Incremental\)
- [Refunds](https://stripe.com/docs/api/refunds/list) \(Incremental\)
@@ -101,6 +102,7 @@ The Stripe connector should not run into Stripe API limitations under normal usa
| Version | Date | Pull Request | Subject |
| :------ | :--------- | :------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |
| 3.12.0 | 2023-05-20 | [26208](https://github.com/airbytehq/airbyte/pull/26208) | Add new stream `Persons` |
| 3.11.0 | 2023-06-26 | [27734](https://github.com/airbytehq/airbyte/pull/27734) | License Update: Elv2 stream |
| 3.10.0 | 2023-06-22 | [27132](https://github.com/airbytehq/airbyte/pull/27132) | Add `CreditNotes` stream |
| 3.9.1 | 2023-06-20 | [27522](https://github.com/airbytehq/airbyte/pull/27522) | Fix formatting |