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: fix schema #22312

Merged
merged 18 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
d1ad22b
#1141 source tiktok: chunk advertiser IDs
davydov-d Feb 2, 2023
dd4659c
#1141 source tiktok: upd changelog
davydov-d Feb 2, 2023
dc97c58
#1299 source stripe: fix Invoices schema
davydov-d Feb 2, 2023
95265e1
#1299 source stripe: upd changelog
davydov-d Feb 2, 2023
0bff217
#1299 source stripe: upd acceptance test config
davydov-d Feb 2, 2023
5be6831
Merge branch 'master' into ddavydov/#1299-source-stripe-fix-schema
davydov-d Feb 6, 2023
85f521f
source-stripe: no http url in openapi_spec.json
alafanechere Feb 13, 2023
06d9c8f
Merge branch 'master' into augustin/source-stripe/no-http-url
alafanechere Feb 14, 2023
c6311a7
Merge branch 'master' into ddavydov/#1299-source-stripe-fix-schema
davydov-d Feb 14, 2023
bb3bd1d
Merge branch 'master' into ddavydov/#1299-source-stripe-fix-schema
davydov-d Feb 14, 2023
9c126c4
#1299 source stripe: fix SAT config
davydov-d Feb 14, 2023
3c9feaf
Merge branch 'master' into ddavydov/#1299-source-stripe-fix-schema
davydov-d Feb 15, 2023
fc2cdce
#1299 source stripe: add allowedHosts
davydov-d Feb 15, 2023
9de61ce
Merge branch 'master' into ddavydov/#1299-source-stripe-fix-schema
davydov-d Feb 15, 2023
87f7198
Merge branch 'augustin/source-stripe/no-http-url' into ddavydov/#1299…
davydov-d Feb 15, 2023
36b4048
Merge branch 'master' into ddavydov/#1299-source-stripe-fix-schema
davydov-d Feb 15, 2023
f3ed1f0
auto-bump connector version
octavia-squidington-iii Feb 15, 2023
fd19c4b
Merge branch 'master' into ddavydov/#1299-source-stripe-fix-schema
davydov-d Feb 15, 2023
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
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 main.py ./
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=1.0.1
LABEL io.airbyte.version=2.0.0
LABEL io.airbyte.name=airbyte/source-stripe
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ tests:
discovery:
- config_path: "secrets/config.json"
backward_compatibility_tests_config:
disable_for_version: "0.1.37"
disable_for_version: "1.0.1"
- config_path: "secrets/connected_account_config.json"
backward_compatibility_tests_config:
disable_for_version: "0.1.37"
disable_for_version: "1.0.1"
basic_read:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/full_refresh_configured_catalog.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,26 @@
"paid": {
"type": ["null", "boolean"]
},
"discount": {
"type": ["null", "string"]
},
"discounts": {
"type": ["null", "array"],
"items": {
"type": [
"null",
"string"
]
}
},
"discount": {
"type": ["null", "object"],
"properties": {
"end": {
"type": ["null", "integer"]
"id": {
"type": ["null", "string"]
},
"object": {
"type": ["null", "string"]
},
"checkout_session": {
"type": ["null", "string"]
},
"coupon": {
"type": ["null", "object"],
Expand All @@ -96,9 +108,6 @@
"duration_in_months": {
"type": ["null", "integer"]
},
"percent_off_precise": {
"type": ["null", "number"]
},
"max_redemptions": {
"type": ["null", "integer"]
},
Expand Down Expand Up @@ -131,11 +140,20 @@
"customer": {
"type": ["null", "string"]
},
"start": {
"end": {
"type": ["null", "integer"]
},
"object": {
"type": ["null", "string"]
"invoice": {
"type": ["null", "integer"]
},
"invoice_item": {
"type": ["null", "integer"]
},
"promotion_code": {
"type": ["null", "integer"]
},
"start": {
"type": ["null", "integer"]
},
"subscription": {
"type": ["null", "string"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ COPY source_tiktok_marketing ./source_tiktok_marketing
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=2.0.1
LABEL io.airbyte.version=2.0.2
LABEL io.airbyte.name=airbyte/source-tiktok-marketing
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) ->
Tests if the input configuration can be used to successfully connect to the integration
"""
try:
next(Advertisers(**self._prepare_stream_args(config)).read_records(SyncMode.full_refresh))
advertisers = Advertisers(**self._prepare_stream_args(config))
for slice_ in advertisers.stream_slices():
next(advertisers.read_records(SyncMode.full_refresh, stream_slice=slice_))
except Exception as err:
return False, err
return True, None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def __init__(self, start_date: str, end_date: str, **kwargs):
def convert_array_param(arr: List[Union[str, int]]) -> str:
return json.dumps(arr)

def get_advertiser_ids(self) -> Iterable[int]:
def get_advertiser_ids(self) -> List[int]:
if self.is_sandbox:
# for sandbox: just return advertiser_id provided in spec
ids = [self._advertiser_id]
Expand Down Expand Up @@ -306,9 +306,8 @@ def is_finished(self):
def request_params(
self,
stream_state: Mapping[str, Any] = None,
next_page_token: Mapping[str, Any] = None,
stream_slice: Mapping[str, Any] = None,
**kwargs,
next_page_token: Mapping[str, Any] = None,
) -> MutableMapping[str, Any]:
params = {"page_size": self.page_size}
if self.fields:
Expand Down Expand Up @@ -412,17 +411,23 @@ def get_updated_state(self, current_stream_state: MutableMapping[str, Any], late
class Advertisers(FullRefreshTiktokStream):
"""Docs: https://ads.tiktok.com/marketing_api/docs?id=1708503202263042"""

def request_params(self, **kwargs) -> MutableMapping[str, Any]:
params = super().request_params(**kwargs)
params["advertiser_ids"] = self.convert_array_param(self.get_advertiser_ids())
return params
def request_params(
self,
stream_state: Mapping[str, Any] = None,
stream_slice: Mapping[str, Any] = None,
next_page_token: Mapping[str, Any] = None,
) -> MutableMapping[str, Any]:
stream_slice = stream_slice or {}
return {key: self.convert_array_param(value) for key, value in stream_slice.items()}

def path(self, *args, **kwargs) -> str:
return "advertiser/info/"

def stream_slices(self, **kwargs) -> Iterable[Optional[Mapping[str, Any]]]:
"""this stream must work with the default slice logic"""
yield None
ids = self.get_advertiser_ids()
start, end, step = 0, len(ids), 100
for i in range(start, end, step):
yield {"advertiser_ids": ids[i: min(end, i + step)]}


class Campaigns(IncrementalTiktokStream):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ def test_get_time_interval_past(pendulum_now_mock_past):
assert len(list(intervals)) == 1


@patch("source_tiktok_marketing.streams.AdvertiserIds.read_records", MagicMock(return_value=[{"advertiser_id": i} for i in range(354)]))
def test_stream_slices_advertisers():
slices = Advertisers(**CONFIG).stream_slices()
assert list(slices) == [None]
assert len(list(slices)) == 4 # math.ceil(354 / 100)


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,9 @@ def logger_mock_fixture():


def test_source_check_connection_ok(config, logger_mock):
with patch.object(Advertisers, "read_records", return_value=iter([1])):
assert SourceTiktokMarketing().check_connection(logger_mock, config=config) == (True, None)
with patch.object(Advertisers, "stream_slices"):
with patch.object(Advertisers, "read_records", return_value=iter([1])):
assert SourceTiktokMarketing().check_connection(logger_mock, config=config) == (True, None)


def test_source_check_connection_failed(config, logger_mock):
Expand Down
3 changes: 2 additions & 1 deletion docs/integrations/sources/stripe.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ The Stripe connector should not run into Stripe API limitations under normal usa

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------|
| 1.0.1 | 2023-01-27 | [22042](https://github.com/airbytehq/airbyte/pull/22042) | Set `AvailabilityStrategy` for streams explicitly to `None` |
| 2.0.0 | 2023-02-02 | [22312](https://github.com/airbytehq/airbyte/pull/22312) | Another fix of `Invoices` stream schema |
| 1.0.1 | 2023-01-27 | [22042](https://github.com/airbytehq/airbyte/pull/22042) | Set `AvailabilityStrategy` for streams explicitly to `None` |
| 1.0.0 | 2023-01-25 | [21858](https://github.com/airbytehq/airbyte/pull/21858) | Update the `Subscriptions` and `Invoices` stream schemas |
| 0.1.40 | 2022-10-20 | [18228](https://github.com/airbytehq/airbyte/pull/18228) | Update the `Payment Intents` stream schema |
| 0.1.39 | 2022-09-28 | [17304](https://github.com/airbytehq/airbyte/pull/17304) | Migrate to per-stream states. |
Expand Down
3 changes: 2 additions & 1 deletion docs/integrations/sources/tiktok-marketing.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,8 @@ The connector is restricted by [requests limitation](https://ads.tiktok.com/mark

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:----------------------------------------------------------------------------------------------|
| 2.0.1 | 2023-01-27 | [22044](https://github.com/airbytehq/airbyte/pull/22044) | Set `AvailabilityStrategy` for streams explicitly to `None` |
| 2.0.2 | 2023-02-02 | [22309](https://github.com/airbytehq/airbyte/pull/22309) | Chunk Advertiser IDs |
| 2.0.1 | 2023-01-27 | [22044](https://github.com/airbytehq/airbyte/pull/22044) | Set `AvailabilityStrategy` for streams explicitly to `None` |
| 2.0.0 | 2022-12-20 | [20415](https://github.com/airbytehq/airbyte/pull/20415) | Update schema types for `AudienceReports` and `BasicReports` streams. |
| 1.0.1 | 2022-12-16 | [20598](https://github.com/airbytehq/airbyte/pull/20598) | Remove Audience Reports with Hourly granularity due to deprecated dimension. |
| 1.0.0 | 2022-12-05 | [19758](https://github.com/airbytehq/airbyte/pull/19758) | Convert `mobile_app_id` from integer to string in AudienceReport streams. |
Expand Down