Debian Codegraph @

stripe/treasury/_financial_account.py

raw
1 # -*- coding: utf-8 -*-
2 # File generated from our OpenAPI spec
3 from stripe._createable_api_resource import CreateableAPIResource
4 from stripe._list_object import ListObject
5 from stripe._listable_api_resource import ListableAPIResource
6 from stripe._stripe_object import StripeObject
7 from stripe._updateable_api_resource import UpdateableAPIResource
8 from stripe._util import class_method_variant, sanitize_id
9 from typing import ClassVar, Dict, List, Optional, cast, overload
10 from typing_extensions import Literal, Unpack, TYPE_CHECKING
11
12 if TYPE_CHECKING:
13 from stripe.params.treasury._financial_account_close_params import (
14 FinancialAccountCloseParams,
15 )
16 from stripe.params.treasury._financial_account_create_params import (
17 FinancialAccountCreateParams,
18 )
19 from stripe.params.treasury._financial_account_list_params import (
20 FinancialAccountListParams,
21 )
22 from stripe.params.treasury._financial_account_modify_params import (
23 FinancialAccountModifyParams,
24 )
25 from stripe.params.treasury._financial_account_retrieve_features_params import (
26 FinancialAccountRetrieveFeaturesParams,
27 )
28 from stripe.params.treasury._financial_account_retrieve_params import (
29 FinancialAccountRetrieveParams,
30 )
31 from stripe.params.treasury._financial_account_update_features_params import (
32 FinancialAccountUpdateFeaturesParams,
33 )
34 from stripe.treasury._financial_account_features import (
35 FinancialAccountFeatures,
36 )
37
38
39 class FinancialAccount(
40 CreateableAPIResource["FinancialAccount"],
41 ListableAPIResource["FinancialAccount"],
42 UpdateableAPIResource["FinancialAccount"],
43 ):
44 """
45 Stripe Treasury provides users with a container for money called a FinancialAccount that is separate from their Payments balance.
46 FinancialAccounts serve as the source and destination of Treasury's money movement APIs.
47 """
48
49 OBJECT_NAME: ClassVar[Literal["treasury.financial_account"]] = (
50 "treasury.financial_account"
51 )
52
53 class Balance(StripeObject):
54 cash: Dict[str, int]
55 """
56 Funds the user can spend right now.
57 """
58 inbound_pending: Dict[str, int]
59 """
60 Funds not spendable yet, but will become available at a later time.
61 """
62 outbound_pending: Dict[str, int]
63 """
64 Funds in the account, but not spendable because they are being held for pending outbound flows.
65 """
66
67 class FinancialAddress(StripeObject):
68 class Aba(StripeObject):
69 account_holder_name: str
70 """
71 The name of the person or business that owns the bank account.
72 """
73 account_number: Optional[str]
74 """
75 The account number.
76 """
77 account_number_last4: str
78 """
79 The last four characters of the account number.
80 """
81 bank_name: str
82 """
83 Name of the bank.
84 """
85 routing_number: str
86 """
87 Routing number for the account.
88 """
89
90 aba: Optional[Aba]
91 """
92 ABA Records contain U.S. bank account details per the ABA format.
93 """
94 supported_networks: Optional[List[Literal["ach", "us_domestic_wire"]]]
95 """
96 The list of networks that the address supports
97 """
98 type: Literal["aba"]
99 """
100 The type of financial address
101 """
102 _inner_class_types = {"aba": Aba}
103
104 class PlatformRestrictions(StripeObject):
105 inbound_flows: Optional[Literal["restricted", "unrestricted"]]
106 """
107 Restricts all inbound money movement.
108 """
109 outbound_flows: Optional[Literal["restricted", "unrestricted"]]
110 """
111 Restricts all outbound money movement.
112 """
113
114 class StatusDetails(StripeObject):
115 class Closed(StripeObject):
116 reasons: List[
117 Literal["account_rejected", "closed_by_platform", "other"]
118 ]
119 """
120 The array that contains reasons for a FinancialAccount closure.
121 """
122
123 closed: Optional[Closed]
124 """
125 Details related to the closure of this FinancialAccount
126 """
127 _inner_class_types = {"closed": Closed}
128
129 active_features: Optional[
130 List[
131 Literal[
132 "card_issuing",
133 "deposit_insurance",
134 "financial_addresses.aba",
135 "financial_addresses.aba.forwarding",
136 "inbound_transfers.ach",
137 "intra_stripe_flows",
138 "outbound_payments.ach",
139 "outbound_payments.us_domestic_wire",
140 "outbound_transfers.ach",
141 "outbound_transfers.us_domestic_wire",
142 "remote_deposit_capture",
143 ]
144 ]
145 ]
146 """
147 The array of paths to active Features in the Features hash.
148 """
149 balance: Balance
150 """
151 Balance information for the FinancialAccount
152 """
153 country: str
154 """
155 Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
156 """
157 created: int
158 """
159 Time at which the object was created. Measured in seconds since the Unix epoch.
160 """
161 features: Optional["FinancialAccountFeatures"]
162 """
163 Encodes whether a FinancialAccount has access to a particular Feature, with a `status` enum and associated `status_details`.
164 Stripe or the platform can control Features via the requested field.
165 """
166 financial_addresses: List[FinancialAddress]
167 """
168 The set of credentials that resolve to a FinancialAccount.
169 """
170 id: str
171 """
172 Unique identifier for the object.
173 """
174 is_default: Optional[bool]
175 livemode: bool
176 """
177 Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
178 """
179 metadata: Optional[Dict[str, str]]
180 """
181 Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
182 """
183 nickname: Optional[str]
184 """
185 The nickname for the FinancialAccount.
186 """
187 object: Literal["treasury.financial_account"]
188 """
189 String representing the object's type. Objects of the same type share the same value.
190 """
191 pending_features: Optional[
192 List[
193 Literal[
194 "card_issuing",
195 "deposit_insurance",
196 "financial_addresses.aba",
197 "financial_addresses.aba.forwarding",
198 "inbound_transfers.ach",
199 "intra_stripe_flows",
200 "outbound_payments.ach",
201 "outbound_payments.us_domestic_wire",
202 "outbound_transfers.ach",
203 "outbound_transfers.us_domestic_wire",
204 "remote_deposit_capture",
205 ]
206 ]
207 ]
208 """
209 The array of paths to pending Features in the Features hash.
210 """
211 platform_restrictions: Optional[PlatformRestrictions]
212 """
213 The set of functionalities that the platform can restrict on the FinancialAccount.
214 """
215 restricted_features: Optional[
216 List[
217 Literal[
218 "card_issuing",
219 "deposit_insurance",
220 "financial_addresses.aba",
221 "financial_addresses.aba.forwarding",
222 "inbound_transfers.ach",
223 "intra_stripe_flows",
224 "outbound_payments.ach",
225 "outbound_payments.us_domestic_wire",
226 "outbound_transfers.ach",
227 "outbound_transfers.us_domestic_wire",
228 "remote_deposit_capture",
229 ]
230 ]
231 ]
232 """
233 The array of paths to restricted Features in the Features hash.
234 """
235 status: Literal["closed", "open"]
236 """
237 Status of this FinancialAccount.
238 """
239 status_details: StatusDetails
240 supported_currencies: List[str]
241 """
242 The currencies the FinancialAccount can hold a balance in. Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
243 """
244
245 @classmethod
246 def _cls_close(
247 cls,
248 financial_account: str,
249 **params: Unpack["FinancialAccountCloseParams"],
250 ) -> "FinancialAccount":
251 """
252 Closes a FinancialAccount. A FinancialAccount can only be closed if it has a zero balance, has no pending InboundTransfers, and has canceled all attached Issuing cards.
253 """
254 return cast(
255 "FinancialAccount",
256 cls._static_request(
257 "post",
258 "/v1/treasury/financial_accounts/{financial_account}/close".format(
259 financial_account=sanitize_id(financial_account)
260 ),
261 params=params,
262 ),
263 )
264
265 @overload
266 @staticmethod
267 def close(
268 financial_account: str, **params: Unpack["FinancialAccountCloseParams"]
269 ) -> "FinancialAccount":
270 """
271 Closes a FinancialAccount. A FinancialAccount can only be closed if it has a zero balance, has no pending InboundTransfers, and has canceled all attached Issuing cards.
272 """
273 ...
274
275 @overload
276 def close(
277 self, **params: Unpack["FinancialAccountCloseParams"]
278 ) -> "FinancialAccount":
279 """
280 Closes a FinancialAccount. A FinancialAccount can only be closed if it has a zero balance, has no pending InboundTransfers, and has canceled all attached Issuing cards.
281 """
282 ...
283
284 @class_method_variant("_cls_close")
285 def close( # pyright: ignore[reportGeneralTypeIssues]
286 self, **params: Unpack["FinancialAccountCloseParams"]
287 ) -> "FinancialAccount":
288 """
289 Closes a FinancialAccount. A FinancialAccount can only be closed if it has a zero balance, has no pending InboundTransfers, and has canceled all attached Issuing cards.
290 """
291 return cast(
292 "FinancialAccount",
293 self._request(
294 "post",
295 "/v1/treasury/financial_accounts/{financial_account}/close".format(
296 financial_account=sanitize_id(self.get("id"))
297 ),
298 params=params,
299 ),
300 )
301
302 @classmethod
303 async def _cls_close_async(
304 cls,
305 financial_account: str,
306 **params: Unpack["FinancialAccountCloseParams"],
307 ) -> "FinancialAccount":
308 """
309 Closes a FinancialAccount. A FinancialAccount can only be closed if it has a zero balance, has no pending InboundTransfers, and has canceled all attached Issuing cards.
310 """
311 return cast(
312 "FinancialAccount",
313 await cls._static_request_async(
314 "post",
315 "/v1/treasury/financial_accounts/{financial_account}/close".format(
316 financial_account=sanitize_id(financial_account)
317 ),
318 params=params,
319 ),
320 )
321
322 @overload
323 @staticmethod
324 async def close_async(
325 financial_account: str, **params: Unpack["FinancialAccountCloseParams"]
326 ) -> "FinancialAccount":
327 """
328 Closes a FinancialAccount. A FinancialAccount can only be closed if it has a zero balance, has no pending InboundTransfers, and has canceled all attached Issuing cards.
329 """
330 ...
331
332 @overload
333 async def close_async(
334 self, **params: Unpack["FinancialAccountCloseParams"]
335 ) -> "FinancialAccount":
336 """
337 Closes a FinancialAccount. A FinancialAccount can only be closed if it has a zero balance, has no pending InboundTransfers, and has canceled all attached Issuing cards.
338 """
339 ...
340
341 @class_method_variant("_cls_close_async")
342 async def close_async( # pyright: ignore[reportGeneralTypeIssues]
343 self, **params: Unpack["FinancialAccountCloseParams"]
344 ) -> "FinancialAccount":
345 """
346 Closes a FinancialAccount. A FinancialAccount can only be closed if it has a zero balance, has no pending InboundTransfers, and has canceled all attached Issuing cards.
347 """
348 return cast(
349 "FinancialAccount",
350 await self._request_async(
351 "post",
352 "/v1/treasury/financial_accounts/{financial_account}/close".format(
353 financial_account=sanitize_id(self.get("id"))
354 ),
355 params=params,
356 ),
357 )
358
359 @classmethod
360 def create(
361 cls, **params: Unpack["FinancialAccountCreateParams"]
362 ) -> "FinancialAccount":
363 """
364 Creates a new FinancialAccount. Each connected account can have up to three FinancialAccounts by default.
365 """
366 return cast(
367 "FinancialAccount",
368 cls._static_request(
369 "post",
370 cls.class_url(),
371 params=params,
372 ),
373 )
374
375 @classmethod
376 async def create_async(
377 cls, **params: Unpack["FinancialAccountCreateParams"]
378 ) -> "FinancialAccount":
379 """
380 Creates a new FinancialAccount. Each connected account can have up to three FinancialAccounts by default.
381 """
382 return cast(
383 "FinancialAccount",
384 await cls._static_request_async(
385 "post",
386 cls.class_url(),
387 params=params,
388 ),
389 )
390
391 @classmethod
392 def list(
393 cls, **params: Unpack["FinancialAccountListParams"]
394 ) -> ListObject["FinancialAccount"]:
395 """
396 Returns a list of FinancialAccounts.
397 """
398 result = cls._static_request(
399 "get",
400 cls.class_url(),
401 params=params,
402 )
403 if not isinstance(result, ListObject):
404 raise TypeError(
405 "Expected list object from API, got %s"
406 % (type(result).__name__)
407 )
408
409 return result
410
411 @classmethod
412 async def list_async(
413 cls, **params: Unpack["FinancialAccountListParams"]
414 ) -> ListObject["FinancialAccount"]:
415 """
416 Returns a list of FinancialAccounts.
417 """
418 result = await cls._static_request_async(
419 "get",
420 cls.class_url(),
421 params=params,
422 )
423 if not isinstance(result, ListObject):
424 raise TypeError(
425 "Expected list object from API, got %s"
426 % (type(result).__name__)
427 )
428
429 return result
430
431 @classmethod
432 def modify(
433 cls, id: str, **params: Unpack["FinancialAccountModifyParams"]
434 ) -> "FinancialAccount":
435 """
436 Updates the details of a FinancialAccount.
437 """
438 url = "%s/%s" % (cls.class_url(), sanitize_id(id))
439 return cast(
440 "FinancialAccount",
441 cls._static_request(
442 "post",
443 url,
444 params=params,
445 ),
446 )
447
448 @classmethod
449 async def modify_async(
450 cls, id: str, **params: Unpack["FinancialAccountModifyParams"]
451 ) -> "FinancialAccount":
452 """
453 Updates the details of a FinancialAccount.
454 """
455 url = "%s/%s" % (cls.class_url(), sanitize_id(id))
456 return cast(
457 "FinancialAccount",
458 await cls._static_request_async(
459 "post",
460 url,
461 params=params,
462 ),
463 )
464
465 @classmethod
466 def retrieve(
467 cls, id: str, **params: Unpack["FinancialAccountRetrieveParams"]
468 ) -> "FinancialAccount":
469 """
470 Retrieves the details of a FinancialAccount.
471 """
472 instance = cls(id, **params)
473 instance.refresh()
474 return instance
475
476 @classmethod
477 async def retrieve_async(
478 cls, id: str, **params: Unpack["FinancialAccountRetrieveParams"]
479 ) -> "FinancialAccount":
480 """
481 Retrieves the details of a FinancialAccount.
482 """
483 instance = cls(id, **params)
484 await instance.refresh_async()
485 return instance
486
487 @classmethod
488 def _cls_retrieve_features(
489 cls,
490 financial_account: str,
491 **params: Unpack["FinancialAccountRetrieveFeaturesParams"],
492 ) -> "FinancialAccountFeatures":
493 """
494 Retrieves Features information associated with the FinancialAccount.
495 """
496 return cast(
497 "FinancialAccountFeatures",
498 cls._static_request(
499 "get",
500 "/v1/treasury/financial_accounts/{financial_account}/features".format(
501 financial_account=sanitize_id(financial_account)
502 ),
503 params=params,
504 ),
505 )
506
507 @overload
508 @staticmethod
509 def retrieve_features(
510 financial_account: str,
511 **params: Unpack["FinancialAccountRetrieveFeaturesParams"],
512 ) -> "FinancialAccountFeatures":
513 """
514 Retrieves Features information associated with the FinancialAccount.
515 """
516 ...
517
518 @overload
519 def retrieve_features(
520 self, **params: Unpack["FinancialAccountRetrieveFeaturesParams"]
521 ) -> "FinancialAccountFeatures":
522 """
523 Retrieves Features information associated with the FinancialAccount.
524 """
525 ...
526
527 @class_method_variant("_cls_retrieve_features")
528 def retrieve_features( # pyright: ignore[reportGeneralTypeIssues]
529 self, **params: Unpack["FinancialAccountRetrieveFeaturesParams"]
530 ) -> "FinancialAccountFeatures":
531 """
532 Retrieves Features information associated with the FinancialAccount.
533 """
534 return cast(
535 "FinancialAccountFeatures",
536 self._request(
537 "get",
538 "/v1/treasury/financial_accounts/{financial_account}/features".format(
539 financial_account=sanitize_id(self.get("id"))
540 ),
541 params=params,
542 ),
543 )
544
545 @classmethod
546 async def _cls_retrieve_features_async(
547 cls,
548 financial_account: str,
549 **params: Unpack["FinancialAccountRetrieveFeaturesParams"],
550 ) -> "FinancialAccountFeatures":
551 """
552 Retrieves Features information associated with the FinancialAccount.
553 """
554 return cast(
555 "FinancialAccountFeatures",
556 await cls._static_request_async(
557 "get",
558 "/v1/treasury/financial_accounts/{financial_account}/features".format(
559 financial_account=sanitize_id(financial_account)
560 ),
561 params=params,
562 ),
563 )
564
565 @overload
566 @staticmethod
567 async def retrieve_features_async(
568 financial_account: str,
569 **params: Unpack["FinancialAccountRetrieveFeaturesParams"],
570 ) -> "FinancialAccountFeatures":
571 """
572 Retrieves Features information associated with the FinancialAccount.
573 """
574 ...
575
576 @overload
577 async def retrieve_features_async(
578 self, **params: Unpack["FinancialAccountRetrieveFeaturesParams"]
579 ) -> "FinancialAccountFeatures":
580 """
581 Retrieves Features information associated with the FinancialAccount.
582 """
583 ...
584
585 @class_method_variant("_cls_retrieve_features_async")
586 async def retrieve_features_async( # pyright: ignore[reportGeneralTypeIssues]
587 self, **params: Unpack["FinancialAccountRetrieveFeaturesParams"]
588 ) -> "FinancialAccountFeatures":
589 """
590 Retrieves Features information associated with the FinancialAccount.
591 """
592 return cast(
593 "FinancialAccountFeatures",
594 await self._request_async(
595 "get",
596 "/v1/treasury/financial_accounts/{financial_account}/features".format(
597 financial_account=sanitize_id(self.get("id"))
598 ),
599 params=params,
600 ),
601 )
602
603 @classmethod
604 def _cls_update_features(
605 cls,
606 financial_account: str,
607 **params: Unpack["FinancialAccountUpdateFeaturesParams"],
608 ) -> "FinancialAccountFeatures":
609 """
610 Updates the Features associated with a FinancialAccount.
611 """
612 return cast(
613 "FinancialAccountFeatures",
614 cls._static_request(
615 "post",
616 "/v1/treasury/financial_accounts/{financial_account}/features".format(
617 financial_account=sanitize_id(financial_account)
618 ),
619 params=params,
620 ),
621 )
622
623 @overload
624 @staticmethod
625 def update_features(
626 financial_account: str,
627 **params: Unpack["FinancialAccountUpdateFeaturesParams"],
628 ) -> "FinancialAccountFeatures":
629 """
630 Updates the Features associated with a FinancialAccount.
631 """
632 ...
633
634 @overload
635 def update_features(
636 self, **params: Unpack["FinancialAccountUpdateFeaturesParams"]
637 ) -> "FinancialAccountFeatures":
638 """
639 Updates the Features associated with a FinancialAccount.
640 """
641 ...
642
643 @class_method_variant("_cls_update_features")
644 def update_features( # pyright: ignore[reportGeneralTypeIssues]
645 self, **params: Unpack["FinancialAccountUpdateFeaturesParams"]
646 ) -> "FinancialAccountFeatures":
647 """
648 Updates the Features associated with a FinancialAccount.
649 """
650 return cast(
651 "FinancialAccountFeatures",
652 self._request(
653 "post",
654 "/v1/treasury/financial_accounts/{financial_account}/features".format(
655 financial_account=sanitize_id(self.get("id"))
656 ),
657 params=params,
658 ),
659 )
660
661 @classmethod
662 async def _cls_update_features_async(
663 cls,
664 financial_account: str,
665 **params: Unpack["FinancialAccountUpdateFeaturesParams"],
666 ) -> "FinancialAccountFeatures":
667 """
668 Updates the Features associated with a FinancialAccount.
669 """
670 return cast(
671 "FinancialAccountFeatures",
672 await cls._static_request_async(
673 "post",
674 "/v1/treasury/financial_accounts/{financial_account}/features".format(
675 financial_account=sanitize_id(financial_account)
676 ),
677 params=params,
678 ),
679 )
680
681 @overload
682 @staticmethod
683 async def update_features_async(
684 financial_account: str,
685 **params: Unpack["FinancialAccountUpdateFeaturesParams"],
686 ) -> "FinancialAccountFeatures":
687 """
688 Updates the Features associated with a FinancialAccount.
689 """
690 ...
691
692 @overload
693 async def update_features_async(
694 self, **params: Unpack["FinancialAccountUpdateFeaturesParams"]
695 ) -> "FinancialAccountFeatures":
696 """
697 Updates the Features associated with a FinancialAccount.
698 """
699 ...
700
701 @class_method_variant("_cls_update_features_async")
702 async def update_features_async( # pyright: ignore[reportGeneralTypeIssues]
703 self, **params: Unpack["FinancialAccountUpdateFeaturesParams"]
704 ) -> "FinancialAccountFeatures":
705 """
706 Updates the Features associated with a FinancialAccount.
707 """
708 return cast(
709 "FinancialAccountFeatures",
710 await self._request_async(
711 "post",
712 "/v1/treasury/financial_accounts/{financial_account}/features".format(
713 financial_account=sanitize_id(self.get("id"))
714 ),
715 params=params,
716 ),
717 )
718
719 _inner_class_types = {
720 "balance": Balance,
721 "financial_addresses": FinancialAddress,
722 "platform_restrictions": PlatformRestrictions,
723 "status_details": StatusDetails,
724 }