Skip to content

Commit

Permalink
Move StripeClient usage collection onto StripeService (#1223)
Browse files Browse the repository at this point in the history
  • Loading branch information
anniel-stripe authored Feb 5, 2024
1 parent 66c96bf commit bd1c587
Show file tree
Hide file tree
Showing 135 changed files with 569 additions and 464 deletions.
6 changes: 3 additions & 3 deletions stripe/_account_capability_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def list(
"""
return cast(
ListObject[Capability],
self._requestor.request(
self._request(
"get",
"/v1/accounts/{account}/capabilities".format(
account=sanitize_id(account),
Expand All @@ -69,7 +69,7 @@ def retrieve(
"""
return cast(
Capability,
self._requestor.request(
self._request(
"get",
"/v1/accounts/{account}/capabilities/{capability}".format(
account=sanitize_id(account),
Expand All @@ -94,7 +94,7 @@ def update(
"""
return cast(
Capability,
self._requestor.request(
self._request(
"post",
"/v1/accounts/{account}/capabilities/{capability}".format(
account=sanitize_id(account),
Expand Down
10 changes: 5 additions & 5 deletions stripe/_account_external_account_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def delete(
"""
return cast(
Union[BankAccount, Card],
self._requestor.request(
self._request(
"delete",
"/v1/accounts/{account}/external_accounts/{id}".format(
account=sanitize_id(account),
Expand All @@ -239,7 +239,7 @@ def retrieve(
"""
return cast(
Union[BankAccount, Card],
self._requestor.request(
self._request(
"get",
"/v1/accounts/{account}/external_accounts/{id}".format(
account=sanitize_id(account),
Expand All @@ -266,7 +266,7 @@ def update(
"""
return cast(
Union[BankAccount, Card],
self._requestor.request(
self._request(
"post",
"/v1/accounts/{account}/external_accounts/{id}".format(
account=sanitize_id(account),
Expand All @@ -290,7 +290,7 @@ def list(
"""
return cast(
ListObject[Union[BankAccount, Card]],
self._requestor.request(
self._request(
"get",
"/v1/accounts/{account}/external_accounts".format(
account=sanitize_id(account),
Expand All @@ -313,7 +313,7 @@ def create(
"""
return cast(
Union[BankAccount, Card],
self._requestor.request(
self._request(
"post",
"/v1/accounts/{account}/external_accounts".format(
account=sanitize_id(account),
Expand Down
2 changes: 1 addition & 1 deletion stripe/_account_link_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def create(
"""
return cast(
AccountLink,
self._requestor.request(
self._request(
"post",
"/v1/account_links",
api_mode="V1",
Expand Down
2 changes: 1 addition & 1 deletion stripe/_account_login_link_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def create(
"""
return cast(
LoginLink,
self._requestor.request(
self._request(
"post",
"/v1/accounts/{account}/login_links".format(
account=sanitize_id(account),
Expand Down
10 changes: 5 additions & 5 deletions stripe/_account_person_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ def delete(
"""
return cast(
Person,
self._requestor.request(
self._request(
"delete",
"/v1/accounts/{account}/persons/{person}".format(
account=sanitize_id(account),
Expand All @@ -850,7 +850,7 @@ def retrieve(
"""
return cast(
Person,
self._requestor.request(
self._request(
"get",
"/v1/accounts/{account}/persons/{person}".format(
account=sanitize_id(account),
Expand All @@ -875,7 +875,7 @@ def update(
"""
return cast(
Person,
self._requestor.request(
self._request(
"post",
"/v1/accounts/{account}/persons/{person}".format(
account=sanitize_id(account),
Expand All @@ -899,7 +899,7 @@ def list(
"""
return cast(
ListObject[Person],
self._requestor.request(
self._request(
"get",
"/v1/accounts/{account}/persons".format(
account=sanitize_id(account),
Expand All @@ -922,7 +922,7 @@ def create(
"""
return cast(
Person,
self._requestor.request(
self._request(
"post",
"/v1/accounts/{account}/persons".format(
account=sanitize_id(account),
Expand Down
14 changes: 7 additions & 7 deletions stripe/_account_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3032,7 +3032,7 @@ def delete(
"""
return cast(
Account,
self._requestor.request(
self._request(
"delete",
"/v1/accounts/{account}".format(account=sanitize_id(account)),
api_mode="V1",
Expand All @@ -3053,7 +3053,7 @@ def retrieve(
"""
return cast(
Account,
self._requestor.request(
self._request(
"get",
"/v1/accounts/{account}".format(account=sanitize_id(account)),
api_mode="V1",
Expand Down Expand Up @@ -3082,7 +3082,7 @@ def update(
"""
return cast(
Account,
self._requestor.request(
self._request(
"post",
"/v1/accounts/{account}".format(account=sanitize_id(account)),
api_mode="V1",
Expand All @@ -3102,7 +3102,7 @@ def retrieve_current(
"""
return cast(
Account,
self._requestor.request(
self._request(
"get",
"/v1/account",
api_mode="V1",
Expand All @@ -3122,7 +3122,7 @@ def list(
"""
return cast(
ListObject[Account],
self._requestor.request(
self._request(
"get",
"/v1/accounts",
api_mode="V1",
Expand All @@ -3147,7 +3147,7 @@ def create(
"""
return cast(
Account,
self._requestor.request(
self._request(
"post",
"/v1/accounts",
api_mode="V1",
Expand All @@ -3170,7 +3170,7 @@ def reject(
"""
return cast(
Account,
self._requestor.request(
self._request(
"post",
"/v1/accounts/{account}/reject".format(
account=sanitize_id(account),
Expand Down
2 changes: 1 addition & 1 deletion stripe/_account_session_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def create(
"""
return cast(
AccountSession,
self._requestor.request(
self._request(
"post",
"/v1/account_sessions",
api_mode="V1",
Expand Down
4 changes: 1 addition & 3 deletions stripe/_api_requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,9 @@ def __init__(
self,
options: RequestorOptions = RequestorOptions(),
client: Optional[HTTPClient] = None,
usage: Optional[List[str]] = None,
):
self._options = options
self._client = client
self._usage = usage or []

# In the case of client=None, we should use the current value of stripe.default_http_client
# or lazily initialize it. Since stripe.default_http_client can change throughout the lifetime of
Expand Down Expand Up @@ -173,7 +171,7 @@ def request(
api_mode=api_mode,
base_address=base_address,
options=options,
_usage=self._usage + (_usage or []),
_usage=_usage,
)
resp = requestor._interpret_response(rbody, rcode, rheaders)

Expand Down
8 changes: 4 additions & 4 deletions stripe/_apple_pay_domain_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def delete(
"""
return cast(
ApplePayDomain,
self._requestor.request(
self._request(
"delete",
"/v1/apple_pay/domains/{domain}".format(
domain=sanitize_id(domain),
Expand All @@ -79,7 +79,7 @@ def retrieve(
"""
return cast(
ApplePayDomain,
self._requestor.request(
self._request(
"get",
"/v1/apple_pay/domains/{domain}".format(
domain=sanitize_id(domain),
Expand All @@ -101,7 +101,7 @@ def list(
"""
return cast(
ListObject[ApplePayDomain],
self._requestor.request(
self._request(
"get",
"/v1/apple_pay/domains",
api_mode="V1",
Expand All @@ -121,7 +121,7 @@ def create(
"""
return cast(
ApplePayDomain,
self._requestor.request(
self._request(
"post",
"/v1/apple_pay/domains",
api_mode="V1",
Expand Down
8 changes: 4 additions & 4 deletions stripe/_application_fee_refund_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def retrieve(
"""
return cast(
ApplicationFeeRefund,
self._requestor.request(
self._request(
"get",
"/v1/application_fees/{fee}/refunds/{id}".format(
fee=sanitize_id(fee),
Expand All @@ -97,7 +97,7 @@ def update(
"""
return cast(
ApplicationFeeRefund,
self._requestor.request(
self._request(
"post",
"/v1/application_fees/{fee}/refunds/{id}".format(
fee=sanitize_id(fee),
Expand All @@ -121,7 +121,7 @@ def list(
"""
return cast(
ListObject[ApplicationFeeRefund],
self._requestor.request(
self._request(
"get",
"/v1/application_fees/{id}/refunds".format(id=sanitize_id(id)),
api_mode="V1",
Expand Down Expand Up @@ -150,7 +150,7 @@ def create(
"""
return cast(
ApplicationFeeRefund,
self._requestor.request(
self._request(
"post",
"/v1/application_fees/{id}/refunds".format(id=sanitize_id(id)),
api_mode="V1",
Expand Down
4 changes: 2 additions & 2 deletions stripe/_application_fee_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def list(
"""
return cast(
ListObject[ApplicationFee],
self._requestor.request(
self._request(
"get",
"/v1/application_fees",
api_mode="V1",
Expand All @@ -93,7 +93,7 @@ def retrieve(
"""
return cast(
ApplicationFee,
self._requestor.request(
self._request(
"get",
"/v1/application_fees/{id}".format(id=sanitize_id(id)),
api_mode="V1",
Expand Down
2 changes: 1 addition & 1 deletion stripe/_balance_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def retrieve(
"""
return cast(
Balance,
self._requestor.request(
self._request(
"get",
"/v1/balance",
api_mode="V1",
Expand Down
4 changes: 2 additions & 2 deletions stripe/_balance_transaction_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def list(
"""
return cast(
ListObject[BalanceTransaction],
self._requestor.request(
self._request(
"get",
"/v1/balance_transactions",
api_mode="V1",
Expand All @@ -104,7 +104,7 @@ def retrieve(
"""
return cast(
BalanceTransaction,
self._requestor.request(
self._request(
"get",
"/v1/balance_transactions/{id}".format(id=sanitize_id(id)),
api_mode="V1",
Expand Down
12 changes: 6 additions & 6 deletions stripe/_charge_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def list(
"""
return cast(
ListObject[Charge],
self._requestor.request(
self._request(
"get",
"/v1/charges",
api_mode="V1",
Expand All @@ -394,7 +394,7 @@ def create(
"""
return cast(
Charge,
self._requestor.request(
self._request(
"post",
"/v1/charges",
api_mode="V1",
Expand All @@ -415,7 +415,7 @@ def retrieve(
"""
return cast(
Charge,
self._requestor.request(
self._request(
"get",
"/v1/charges/{charge}".format(charge=sanitize_id(charge)),
api_mode="V1",
Expand All @@ -436,7 +436,7 @@ def update(
"""
return cast(
Charge,
self._requestor.request(
self._request(
"post",
"/v1/charges/{charge}".format(charge=sanitize_id(charge)),
api_mode="V1",
Expand All @@ -459,7 +459,7 @@ def search(
"""
return cast(
SearchResultObject[Charge],
self._requestor.request(
self._request(
"get",
"/v1/charges/search",
api_mode="V1",
Expand All @@ -484,7 +484,7 @@ def capture(
"""
return cast(
Charge,
self._requestor.request(
self._request(
"post",
"/v1/charges/{charge}/capture".format(
charge=sanitize_id(charge),
Expand Down
Loading

0 comments on commit bd1c587

Please sign in to comment.