Skip to content

Commit

Permalink
Source Stripe: implement slicing (#15292)
Browse files Browse the repository at this point in the history
* #45 oncall - source Stripe: implement slicing

* #45 source stripe: upd changelog

* #45 source stripe: upd changelog

* #45 source stripe: make slice range configurable

* #45 source stripe: move generating a single slice into a mixin

* auto-bump connector version [ci skip]

Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
  • Loading branch information
2 people authored and girarda committed Aug 11, 2022
1 parent 2151b77 commit 6ea5290
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@
- name: Stripe
sourceDefinitionId: e094cb9a-26de-4645-8761-65c0c425d1de
dockerRepository: airbyte/source-stripe
dockerImageTag: 0.1.35
dockerImageTag: 0.1.36
documentationUrl: https://docs.airbyte.io/integrations/sources/stripe
icon: stripe.svg
sourceType: api
Expand Down
19 changes: 18 additions & 1 deletion airbyte-config/init/src/main/resources/seed/source_specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9345,7 +9345,7 @@
type: "string"
path_in_connector_config:
- "client_secret"
- dockerImage: "airbyte/source-stripe:0.1.35"
- dockerImage: "airbyte/source-stripe:0.1.36"
spec:
documentationUrl: "https://docs.airbyte.io/integrations/sources/stripe"
connectionSpecification:
Expand Down Expand Up @@ -9389,6 +9389,23 @@
\ is frequently updated after creation. More info <a href=\"https://docs.airbyte.com/integrations/sources/stripe#requirements\"\
>here</a>"
order: 3
slice_range:
type: "integer"
title: "Data request time increment in days (Optional)"
default: 365
minimum: 1
examples:
- 1
- 3
- 10
- 30
- 180
- 360
description: "The time increment used by the connector when requesting data\
\ from the Stripe API. The bigger the value is, the less requests will\
\ be made and faster the sync will be. On the other hand, the more seldom\
\ the state is persisted."
order: 4
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
Expand Down
6 changes: 3 additions & 3 deletions airbyte-integrations/connectors/source-stripe/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ FROM python:3.9-slim
RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/*

WORKDIR /airbyte/integration_code
COPY source_stripe ./source_stripe
COPY main.py ./
COPY setup.py ./
RUN pip install .
COPY source_stripe ./source_stripe
COPY main.py ./

ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.35
LABEL io.airbyte.version=0.1.36
LABEL io.airbyte.name=airbyte/source-stripe
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"charges": { "created": 161703040300 },
"coupons": { "created": 161703040300 },
"events": { "created": 161749384700 },
"customers": { "created": 160083796900 },
"plans": { "created": 159484835000 },
"invoices": { "created": 161749017500 },
"invoice_items": { "date": 159494698100 },
"transfers": { "created": 161099582400 },
"subscriptions": { "created": 159968687300 },
"balance_transactions": { "created": 161706755600 },
"payouts": { "created": 161706755600 },
"disputes": { "created": 161099630500 },
"products": { "created": 158551134100 },
"refunds": { "created": 161959562900 },
"payment_intents": { "created": 161959562900 },
"promotion_codes": { "created": 163534157100 },
"charges": { "created": 10000000000 },
"coupons": { "created": 10000000000 },
"events": { "created": 10000000000 },
"customers": { "created": 10000000000 },
"plans": { "created": 10000000000 },
"invoices": { "created": 10000000000 },
"invoice_items": { "date": 10000000000 },
"transfers": { "created": 10000000000 },
"subscriptions": { "created": 10000000000 },
"balance_transactions": { "created": 10000000000 },
"payouts": { "created": 10000000000 },
"disputes": { "created": 10000000000 },
"products": { "created": 10000000000 },
"refunds": { "created": 10000000000 },
"payment_intents": { "created": 10000000000 },
"promotion_codes": { "created": 10000000000 },
"checkout_sessions": { "expires_at": 10000000000 },
"checkout_sessions_line_items": { "checkout_session_expires_at": 10000000000 }
}

This file was deleted.

2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-stripe/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from setuptools import find_packages, setup

MAIN_REQUIREMENTS = ["airbyte-cdk~=0.1", "stripe==2.56.0", "pendulum==1.2.0"]
MAIN_REQUIREMENTS = ["airbyte-cdk~=0.1", "stripe==2.56.0", "pendulum==2.1.2"]

TEST_REQUIREMENTS = [
"pytest~=6.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) ->
def streams(self, config: Mapping[str, Any]) -> List[Stream]:
authenticator = TokenAuthenticator(config["client_secret"])
start_date = pendulum.parse(config["start_date"]).int_timestamp
args = {"authenticator": authenticator, "account_id": config["account_id"], "start_date": start_date}
args = {
"authenticator": authenticator,
"account_id": config["account_id"],
"start_date": start_date,
"slice_range": config.get("slice_range"),
}
incremental_args = {**args, "lookback_window_days": config.get("lookback_window_days")}
return [
BalanceTransactions(**incremental_args),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,14 @@ connectionSpecification:
after creation. More info <a
href="https://docs.airbyte.com/integrations/sources/stripe#requirements">here</a>
order: 3
slice_range:
type: integer
title: Data request time increment in days (Optional)
default: 365
minimum: 1
examples: [1, 3, 10, 30, 180, 360]
description: >-
The time increment used by the connector when requesting data from the Stripe API. The bigger the value is,
the less requests will be made and faster the sync will be. On the other hand, the more seldom
the state is persisted.
order: 4
Loading

0 comments on commit 6ea5290

Please sign in to comment.