Debian Codegraph @

stripe/v2/core/_account_service.py

raw
1 # -*- coding: utf-8 -*-
2 # File generated from our OpenAPI spec
3 from stripe._stripe_service import StripeService
4 from stripe._util import sanitize_id
5 from typing import Optional, cast
6 from importlib import import_module
7 from typing_extensions import TYPE_CHECKING
8
9 if TYPE_CHECKING:
10 from stripe._request_options import RequestOptions
11 from stripe.params.v2.core._account_close_params import AccountCloseParams
12 from stripe.params.v2.core._account_create_params import (
13 AccountCreateParams,
14 )
15 from stripe.params.v2.core._account_list_params import AccountListParams
16 from stripe.params.v2.core._account_retrieve_params import (
17 AccountRetrieveParams,
18 )
19 from stripe.params.v2.core._account_update_params import (
20 AccountUpdateParams,
21 )
22 from stripe.v2._list_object import ListObject
23 from stripe.v2.core._account import Account
24 from stripe.v2.core.accounts._person_service import PersonService
25 from stripe.v2.core.accounts._person_token_service import (
26 PersonTokenService,
27 )
28
29 _subservices = {
30 "persons": ["stripe.v2.core.accounts._person_service", "PersonService"],
31 "person_tokens": [
32 "stripe.v2.core.accounts._person_token_service",
33 "PersonTokenService",
34 ],
35 }
36
37
38 class AccountService(StripeService):
39 persons: "PersonService"
40 person_tokens: "PersonTokenService"
41
42 def __init__(self, requestor):
43 super().__init__(requestor)
44
45 def __getattr__(self, name):
46 try:
47 import_from, service = _subservices[name]
48 service_class = getattr(
49 import_module(import_from),
50 service,
51 )
52 setattr(
53 self,
54 name,
55 service_class(self._requestor),
56 )
57 return getattr(self, name)
58 except KeyError:
59 raise AttributeError()
60
61 def list(
62 self,
63 params: Optional["AccountListParams"] = None,
64 options: Optional["RequestOptions"] = None,
65 ) -> "ListObject[Account]":
66 """
67 Returns a list of Accounts.
68 """
69 return cast(
70 "ListObject[Account]",
71 self._request(
72 "get",
73 "/v2/core/accounts",
74 base_address="api",
75 params=params,
76 options=options,
77 ),
78 )
79
80 async def list_async(
81 self,
82 params: Optional["AccountListParams"] = None,
83 options: Optional["RequestOptions"] = None,
84 ) -> "ListObject[Account]":
85 """
86 Returns a list of Accounts.
87 """
88 return cast(
89 "ListObject[Account]",
90 await self._request_async(
91 "get",
92 "/v2/core/accounts",
93 base_address="api",
94 params=params,
95 options=options,
96 ),
97 )
98
99 def create(
100 self,
101 params: Optional["AccountCreateParams"] = None,
102 options: Optional["RequestOptions"] = None,
103 ) -> "Account":
104 """
105 An Account is a representation of a company, individual or other entity that a user interacts with. Accounts contain identifying information about the entity, and configurations that store the features an account has access to. An account can be configured as any or all of the following configurations: Customer, Merchant and/or Recipient.
106 """
107 return cast(
108 "Account",
109 self._request(
110 "post",
111 "/v2/core/accounts",
112 base_address="api",
113 params=params,
114 options=options,
115 ),
116 )
117
118 async def create_async(
119 self,
120 params: Optional["AccountCreateParams"] = None,
121 options: Optional["RequestOptions"] = None,
122 ) -> "Account":
123 """
124 An Account is a representation of a company, individual or other entity that a user interacts with. Accounts contain identifying information about the entity, and configurations that store the features an account has access to. An account can be configured as any or all of the following configurations: Customer, Merchant and/or Recipient.
125 """
126 return cast(
127 "Account",
128 await self._request_async(
129 "post",
130 "/v2/core/accounts",
131 base_address="api",
132 params=params,
133 options=options,
134 ),
135 )
136
137 def retrieve(
138 self,
139 id: str,
140 params: Optional["AccountRetrieveParams"] = None,
141 options: Optional["RequestOptions"] = None,
142 ) -> "Account":
143 """
144 Retrieves the details of an Account.
145 """
146 return cast(
147 "Account",
148 self._request(
149 "get",
150 "/v2/core/accounts/{id}".format(id=sanitize_id(id)),
151 base_address="api",
152 params=params,
153 options=options,
154 ),
155 )
156
157 async def retrieve_async(
158 self,
159 id: str,
160 params: Optional["AccountRetrieveParams"] = None,
161 options: Optional["RequestOptions"] = None,
162 ) -> "Account":
163 """
164 Retrieves the details of an Account.
165 """
166 return cast(
167 "Account",
168 await self._request_async(
169 "get",
170 "/v2/core/accounts/{id}".format(id=sanitize_id(id)),
171 base_address="api",
172 params=params,
173 options=options,
174 ),
175 )
176
177 def update(
178 self,
179 id: str,
180 params: Optional["AccountUpdateParams"] = None,
181 options: Optional["RequestOptions"] = None,
182 ) -> "Account":
183 """
184 Updates the details of an Account.
185 """
186 return cast(
187 "Account",
188 self._request(
189 "post",
190 "/v2/core/accounts/{id}".format(id=sanitize_id(id)),
191 base_address="api",
192 params=params,
193 options=options,
194 ),
195 )
196
197 async def update_async(
198 self,
199 id: str,
200 params: Optional["AccountUpdateParams"] = None,
201 options: Optional["RequestOptions"] = None,
202 ) -> "Account":
203 """
204 Updates the details of an Account.
205 """
206 return cast(
207 "Account",
208 await self._request_async(
209 "post",
210 "/v2/core/accounts/{id}".format(id=sanitize_id(id)),
211 base_address="api",
212 params=params,
213 options=options,
214 ),
215 )
216
217 def close(
218 self,
219 id: str,
220 params: Optional["AccountCloseParams"] = None,
221 options: Optional["RequestOptions"] = None,
222 ) -> "Account":
223 """
224 Removes access to the Account and its associated resources. Closed Accounts can no longer be operated on, but limited information can still be retrieved through the API in order to be able to track their history.
225 """
226 return cast(
227 "Account",
228 self._request(
229 "post",
230 "/v2/core/accounts/{id}/close".format(id=sanitize_id(id)),
231 base_address="api",
232 params=params,
233 options=options,
234 ),
235 )
236
237 async def close_async(
238 self,
239 id: str,
240 params: Optional["AccountCloseParams"] = None,
241 options: Optional["RequestOptions"] = None,
242 ) -> "Account":
243 """
244 Removes access to the Account and its associated resources. Closed Accounts can no longer be operated on, but limited information can still be retrieved through the API in order to be able to track their history.
245 """
246 return cast(
247 "Account",
248 await self._request_async(
249 "post",
250 "/v2/core/accounts/{id}/close".format(id=sanitize_id(id)),
251 base_address="api",
252 params=params,
253 options=options,
254 ),
255 )