Skip to content

Commit

Permalink
Beta: add _async methods for StripeClient (#1228)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardm-stripe authored Feb 8, 2024
1 parent e8845a7 commit 7b60ca9
Show file tree
Hide file tree
Showing 165 changed files with 25,362 additions and 2,987 deletions.
73 changes: 73 additions & 0 deletions stripe/_account_capability_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,29 @@ def list(
),
)

async def list_async(
self,
account: str,
params: "AccountCapabilityService.ListParams" = {},
options: RequestOptions = {},
) -> ListObject[Capability]:
"""
Returns a list of capabilities associated with the account. The capabilities are returned sorted by creation date, with the most recent capability appearing first.
"""
return cast(
ListObject[Capability],
await self._request_async(
"get",
"/v1/accounts/{account}/capabilities".format(
account=sanitize_id(account),
),
api_mode="V1",
base_address="api",
params=params,
options=options,
),
)

def retrieve(
self,
account: str,
Expand All @@ -82,6 +105,31 @@ def retrieve(
),
)

async def retrieve_async(
self,
account: str,
capability: str,
params: "AccountCapabilityService.RetrieveParams" = {},
options: RequestOptions = {},
) -> Capability:
"""
Retrieves information about the specified Account Capability.
"""
return cast(
Capability,
await self._request_async(
"get",
"/v1/accounts/{account}/capabilities/{capability}".format(
account=sanitize_id(account),
capability=sanitize_id(capability),
),
api_mode="V1",
base_address="api",
params=params,
options=options,
),
)

def update(
self,
account: str,
Expand All @@ -106,3 +154,28 @@ def update(
options=options,
),
)

async def update_async(
self,
account: str,
capability: str,
params: "AccountCapabilityService.UpdateParams" = {},
options: RequestOptions = {},
) -> Capability:
"""
Updates an existing Account Capability. Request or remove a capability by updating its requested parameter.
"""
return cast(
Capability,
await self._request_async(
"post",
"/v1/accounts/{account}/capabilities/{capability}".format(
account=sanitize_id(account),
capability=sanitize_id(capability),
),
api_mode="V1",
base_address="api",
params=params,
options=options,
),
)
123 changes: 123 additions & 0 deletions stripe/_account_external_account_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,31 @@ def delete(
),
)

async def delete_async(
self,
account: str,
id: str,
params: "AccountExternalAccountService.DeleteParams" = {},
options: RequestOptions = {},
) -> Union[BankAccount, Card]:
"""
Delete a specified external account for a given account.
"""
return cast(
Union[BankAccount, Card],
await self._request_async(
"delete",
"/v1/accounts/{account}/external_accounts/{id}".format(
account=sanitize_id(account),
id=sanitize_id(id),
),
api_mode="V1",
base_address="api",
params=params,
options=options,
),
)

def retrieve(
self,
account: str,
Expand All @@ -252,6 +277,31 @@ def retrieve(
),
)

async def retrieve_async(
self,
account: str,
id: str,
params: "AccountExternalAccountService.RetrieveParams" = {},
options: RequestOptions = {},
) -> Union[BankAccount, Card]:
"""
Retrieve a specified external account for a given account.
"""
return cast(
Union[BankAccount, Card],
await self._request_async(
"get",
"/v1/accounts/{account}/external_accounts/{id}".format(
account=sanitize_id(account),
id=sanitize_id(id),
),
api_mode="V1",
base_address="api",
params=params,
options=options,
),
)

def update(
self,
account: str,
Expand Down Expand Up @@ -279,6 +329,33 @@ def update(
),
)

async def update_async(
self,
account: str,
id: str,
params: "AccountExternalAccountService.UpdateParams" = {},
options: RequestOptions = {},
) -> Union[BankAccount, Card]:
"""
Updates the metadata, account holder name, account holder type of a bank account belonging to a [Custom account](https://stripe.com/docs/connect/custom-accounts), and optionally sets it as the default for its currency. Other bank account details are not editable by design.
You can re-enable a disabled bank account by performing an update call without providing any arguments or changes.
"""
return cast(
Union[BankAccount, Card],
await self._request_async(
"post",
"/v1/accounts/{account}/external_accounts/{id}".format(
account=sanitize_id(account),
id=sanitize_id(id),
),
api_mode="V1",
base_address="api",
params=params,
options=options,
),
)

def list(
self,
account: str,
Expand All @@ -302,6 +379,29 @@ def list(
),
)

async def list_async(
self,
account: str,
params: "AccountExternalAccountService.ListParams" = {},
options: RequestOptions = {},
) -> ListObject[Union[BankAccount, Card]]:
"""
List external accounts for an account.
"""
return cast(
ListObject[Union[BankAccount, Card]],
await self._request_async(
"get",
"/v1/accounts/{account}/external_accounts".format(
account=sanitize_id(account),
),
api_mode="V1",
base_address="api",
params=params,
options=options,
),
)

def create(
self,
account: str,
Expand All @@ -324,3 +424,26 @@ def create(
options=options,
),
)

async def create_async(
self,
account: str,
params: "AccountExternalAccountService.CreateParams",
options: RequestOptions = {},
) -> Union[BankAccount, Card]:
"""
Create an external account for a given account.
"""
return cast(
Union[BankAccount, Card],
await self._request_async(
"post",
"/v1/accounts/{account}/external_accounts".format(
account=sanitize_id(account),
),
api_mode="V1",
base_address="api",
params=params,
options=options,
),
)
20 changes: 20 additions & 0 deletions stripe/_account_link_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,23 @@ def create(
options=options,
),
)

async def create_async(
self,
params: "AccountLinkService.CreateParams",
options: RequestOptions = {},
) -> AccountLink:
"""
Creates an AccountLink object that includes a single-use Stripe URL that the platform can redirect their user to in order to take them through the Connect Onboarding flow.
"""
return cast(
AccountLink,
await self._request_async(
"post",
"/v1/account_links",
api_mode="V1",
base_address="api",
params=params,
options=options,
),
)
25 changes: 25 additions & 0 deletions stripe/_account_login_link_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,28 @@ def create(
options=options,
),
)

async def create_async(
self,
account: str,
params: "AccountLoginLinkService.CreateParams" = {},
options: RequestOptions = {},
) -> LoginLink:
"""
Creates a single-use login link for an Express account to access their Stripe dashboard.
You may only create login links for [Express accounts](https://stripe.com/docs/connect/express-accounts) connected to your platform.
"""
return cast(
LoginLink,
await self._request_async(
"post",
"/v1/accounts/{account}/login_links".format(
account=sanitize_id(account),
),
api_mode="V1",
base_address="api",
params=params,
options=options,
),
)
72 changes: 69 additions & 3 deletions stripe/_account_notice_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,27 @@ def list(
"""
return cast(
ListObject[AccountNotice],
self._requestor.request(
self._request(
"get",
"/v1/account_notices",
api_mode="V1",
base_address="api",
params=params,
options=options,
),
)

async def list_async(
self,
params: "AccountNoticeService.ListParams" = {},
options: RequestOptions = {},
) -> ListObject[AccountNotice]:
"""
Retrieves a list of AccountNotice objects. The objects are sorted in descending order by creation date, with the most-recently-created object appearing first.
"""
return cast(
ListObject[AccountNotice],
await self._request_async(
"get",
"/v1/account_notices",
api_mode="V1",
Expand All @@ -101,7 +121,30 @@ def retrieve(
"""
return cast(
AccountNotice,
self._requestor.request(
self._request(
"get",
"/v1/account_notices/{account_notice}".format(
account_notice=sanitize_id(account_notice),
),
api_mode="V1",
base_address="api",
params=params,
options=options,
),
)

async def retrieve_async(
self,
account_notice: str,
params: "AccountNoticeService.RetrieveParams" = {},
options: RequestOptions = {},
) -> AccountNotice:
"""
Retrieves an AccountNotice object.
"""
return cast(
AccountNotice,
await self._request_async(
"get",
"/v1/account_notices/{account_notice}".format(
account_notice=sanitize_id(account_notice),
Expand All @@ -124,7 +167,30 @@ def update(
"""
return cast(
AccountNotice,
self._requestor.request(
self._request(
"post",
"/v1/account_notices/{account_notice}".format(
account_notice=sanitize_id(account_notice),
),
api_mode="V1",
base_address="api",
params=params,
options=options,
),
)

async def update_async(
self,
account_notice: str,
params: "AccountNoticeService.UpdateParams",
options: RequestOptions = {},
) -> AccountNotice:
"""
Updates an AccountNotice object.
"""
return cast(
AccountNotice,
await self._request_async(
"post",
"/v1/account_notices/{account_notice}".format(
account_notice=sanitize_id(account_notice),
Expand Down
Loading

0 comments on commit 7b60ca9

Please sign in to comment.