Debian Codegraph @

stripe/test_helpers/_treasury_service.py

raw
1 # -*- coding: utf-8 -*-
2 # File generated from our OpenAPI spec
3 from stripe._stripe_service import StripeService
4 from importlib import import_module
5 from typing_extensions import TYPE_CHECKING
6
7 if TYPE_CHECKING:
8 from stripe.test_helpers.treasury._inbound_transfer_service import (
9 InboundTransferService,
10 )
11 from stripe.test_helpers.treasury._outbound_payment_service import (
12 OutboundPaymentService,
13 )
14 from stripe.test_helpers.treasury._outbound_transfer_service import (
15 OutboundTransferService,
16 )
17 from stripe.test_helpers.treasury._received_credit_service import (
18 ReceivedCreditService,
19 )
20 from stripe.test_helpers.treasury._received_debit_service import (
21 ReceivedDebitService,
22 )
23
24 _subservices = {
25 "inbound_transfers": [
26 "stripe.test_helpers.treasury._inbound_transfer_service",
27 "InboundTransferService",
28 ],
29 "outbound_payments": [
30 "stripe.test_helpers.treasury._outbound_payment_service",
31 "OutboundPaymentService",
32 ],
33 "outbound_transfers": [
34 "stripe.test_helpers.treasury._outbound_transfer_service",
35 "OutboundTransferService",
36 ],
37 "received_credits": [
38 "stripe.test_helpers.treasury._received_credit_service",
39 "ReceivedCreditService",
40 ],
41 "received_debits": [
42 "stripe.test_helpers.treasury._received_debit_service",
43 "ReceivedDebitService",
44 ],
45 }
46
47
48 class TreasuryService(StripeService):
49 inbound_transfers: "InboundTransferService"
50 outbound_payments: "OutboundPaymentService"
51 outbound_transfers: "OutboundTransferService"
52 received_credits: "ReceivedCreditService"
53 received_debits: "ReceivedDebitService"
54
55 def __init__(self, requestor):
56 super().__init__(requestor)
57
58 def __getattr__(self, name):
59 try:
60 import_from, service = _subservices[name]
61 service_class = getattr(
62 import_module(import_from),
63 service,
64 )
65 setattr(
66 self,
67 name,
68 service_class(self._requestor),
69 )
70 return getattr(self, name)
71 except KeyError:
72 raise AttributeError()