Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/stripe/api_resources/bank_account.py: 47%
32 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
1# File generated from our OpenAPI spec
2from __future__ import absolute_import, division, print_function
4from stripe import error
5from stripe import util
6from stripe.api_resources.abstract import DeletableAPIResource
7from stripe.api_resources.abstract import UpdateableAPIResource
8from stripe.api_resources.abstract import VerifyMixin
9from stripe.api_resources.account import Account
10from stripe.api_resources.customer import Customer
11from stripe.six.moves.urllib.parse import quote_plus
14class BankAccount(DeletableAPIResource, UpdateableAPIResource, VerifyMixin):
15 OBJECT_NAME = "bank_account"
17 def instance_url(self):
18 token = util.utf8(self.id)
19 extn = quote_plus(token)
20 if hasattr(self, "customer"):
21 customer = util.utf8(self.customer)
23 base = Customer.class_url()
24 owner_extn = quote_plus(customer)
25 class_base = "sources"
27 elif hasattr(self, "account"):
28 account = util.utf8(self.account)
30 base = Account.class_url()
31 owner_extn = quote_plus(account)
32 class_base = "external_accounts"
34 else:
35 raise error.InvalidRequestError(
36 "Could not determine whether bank_account_id %s is "
37 "attached to a customer or an account." % token,
38 "id",
39 )
41 return "%s/%s/%s/%s" % (base, owner_extn, class_base, extn)
43 @classmethod
44 def modify(cls, sid, **params):
45 raise NotImplementedError(
46 "Can't modify a bank account without a customer or account ID. "
47 "Call save on customer.sources.retrieve('bank_account_id') or "
48 "account.external_accounts.retrieve('bank_account_id') instead."
49 )
51 @classmethod
52 def retrieve(
53 cls,
54 id,
55 api_key=None,
56 stripe_version=None,
57 stripe_account=None,
58 **params
59 ):
60 raise NotImplementedError(
61 "Can't retrieve a bank account without a customer or account ID. "
62 "Use customer.sources.retrieve('bank_account_id') or "
63 "account.external_accounts.retrieve('bank_account_id') instead."
64 )