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

Issue 32871/test other incremental stripe stream #33544

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,28 @@ class StripeRequestBuilder:
def application_fees_endpoint(cls, account_id: str, client_secret: str) -> "StripeRequestBuilder":
return cls("application_fees", account_id, client_secret)

@classmethod
def application_fees_refunds_endpoint(cls, application_fee_id: str, account_id: str, client_secret: str) -> "StripeRequestBuilder":
return cls(f"application_fees/{application_fee_id}/refunds", account_id, client_secret)

@classmethod
def customers_endpoint(cls, account_id: str, client_secret: str) -> "StripeRequestBuilder":
return cls("customers", account_id, client_secret)

@classmethod
def customers_sources_endpoint(cls, customer_id: str, account_id: str, client_secret: str) -> "StripeRequestBuilder":
# FIXME this endpoint is not available in the documentation and stripe mentions explicitly that the sources API is deprecated
# (see https://stripe.com/docs/sources/customers and https://github.com/airbytehq/airbyte/issues/33714)
return cls(f"customers/{customer_id}/sources", account_id, client_secret)

@classmethod
def events_endpoint(cls, account_id: str, client_secret: str) -> "StripeRequestBuilder":
return cls("events", account_id, client_secret)

@classmethod
def external_accounts_endpoint(cls, account_id: str, client_secret: str) -> "StripeRequestBuilder":
return cls(f"accounts/{account_id}/external_accounts", account_id, client_secret)

@classmethod
def issuing_authorizations_endpoint(cls, account_id: str, client_secret: str) -> "StripeRequestBuilder":
return cls("issuing/authorizations", account_id, client_secret)
Expand All @@ -29,6 +47,14 @@ def issuing_cards_endpoint(cls, account_id: str, client_secret: str) -> "StripeR
def issuing_transactions_endpoint(cls, account_id: str, client_secret: str) -> "StripeRequestBuilder":
return cls("issuing/transactions", account_id, client_secret)

@classmethod
def payment_methods_endpoint(cls, account_id: str, client_secret: str) -> "StripeRequestBuilder":
return cls("payment_methods", account_id, client_secret)

@classmethod
def radar_early_fraud_warnings_endpoint(cls, account_id: str, client_secret: str) -> "StripeRequestBuilder":
return cls("radar/early_fraud_warnings", account_id, client_secret)

@classmethod
def reviews_endpoint(cls, account_id: str, client_secret: str) -> "StripeRequestBuilder":
return cls("reviews", account_id, client_secret)
Expand All @@ -45,8 +71,10 @@ def __init__(self, resource: str, account_id: str, client_secret: str) -> None:
self._created_gte: Optional[datetime] = None
self._created_lte: Optional[datetime] = None
self._limit: Optional[int] = None
self._object: Optional[str] = None
self._starting_after_id: Optional[str] = None
self._types: List[str] = []
self._expands: List[str] = []

def with_created_gte(self, created_gte: datetime) -> "StripeRequestBuilder":
self._created_gte = created_gte
Expand All @@ -60,6 +88,10 @@ def with_limit(self, limit: int) -> "StripeRequestBuilder":
self._limit = limit
return self

def with_object(self, object_name: str) -> "StripeRequestBuilder":
self._object = object_name
return self

def with_starting_after(self, starting_after_id: str) -> "StripeRequestBuilder":
self._starting_after_id = starting_after_id
return self
Expand All @@ -72,6 +104,10 @@ def with_types(self, types: List[str]) -> "StripeRequestBuilder":
self._types = types
return self

def with_expands(self, expands: List[str]) -> "StripeRequestBuilder":
self._expands = expands
return self

def build(self) -> HttpRequest:
query_params = {}
if self._created_gte:
Expand All @@ -84,6 +120,10 @@ def build(self) -> HttpRequest:
query_params["starting_after"] = self._starting_after_id
if self._types:
query_params["types[]"] = self._types
if self._object:
query_params["object"] = self._object
if self._expands:
query_params["expand[]"] = self._expands

if self._any_query_params:
if query_params:
Expand Down