Debian Codegraph @

stripe/v2/_billing_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.v2.billing._meter_event_adjustment_service import (
9 MeterEventAdjustmentService,
10 )
11 from stripe.v2.billing._meter_event_service import MeterEventService
12 from stripe.v2.billing._meter_event_session_service import (
13 MeterEventSessionService,
14 )
15 from stripe.v2.billing._meter_event_stream_service import (
16 MeterEventStreamService,
17 )
18
19 _subservices = {
20 "meter_events": [
21 "stripe.v2.billing._meter_event_service",
22 "MeterEventService",
23 ],
24 "meter_event_adjustments": [
25 "stripe.v2.billing._meter_event_adjustment_service",
26 "MeterEventAdjustmentService",
27 ],
28 "meter_event_session": [
29 "stripe.v2.billing._meter_event_session_service",
30 "MeterEventSessionService",
31 ],
32 "meter_event_stream": [
33 "stripe.v2.billing._meter_event_stream_service",
34 "MeterEventStreamService",
35 ],
36 }
37
38
39 class BillingService(StripeService):
40 meter_events: "MeterEventService"
41 meter_event_adjustments: "MeterEventAdjustmentService"
42 meter_event_session: "MeterEventSessionService"
43 meter_event_stream: "MeterEventStreamService"
44
45 def __init__(self, requestor):
46 super().__init__(requestor)
47
48 def __getattr__(self, name):
49 try:
50 import_from, service = _subservices[name]
51 service_class = getattr(
52 import_module(import_from),
53 service,
54 )
55 setattr(
56 self,
57 name,
58 service_class(self._requestor),
59 )
60 return getattr(self, name)
61 except KeyError:
62 raise AttributeError()