Debian Codegraph @

stripe/climate/_product.py

raw
1 # -*- coding: utf-8 -*-
2 # File generated from our OpenAPI spec
3 from stripe._list_object import ListObject
4 from stripe._listable_api_resource import ListableAPIResource
5 from stripe._stripe_object import StripeObject
6 from typing import ClassVar, Dict, List, Optional
7 from typing_extensions import Literal, Unpack, TYPE_CHECKING
8
9 if TYPE_CHECKING:
10 from stripe.climate._supplier import Supplier
11 from stripe.params.climate._product_list_params import ProductListParams
12 from stripe.params.climate._product_retrieve_params import (
13 ProductRetrieveParams,
14 )
15
16
17 class Product(ListableAPIResource["Product"]):
18 """
19 A Climate product represents a type of carbon removal unit available for reservation.
20 You can retrieve it to see the current price and availability.
21 """
22
23 OBJECT_NAME: ClassVar[Literal["climate.product"]] = "climate.product"
24
25 class CurrentPricesPerMetricTon(StripeObject):
26 amount_fees: int
27 """
28 Fees for one metric ton of carbon removal in the currency's smallest unit.
29 """
30 amount_subtotal: int
31 """
32 Subtotal for one metric ton of carbon removal (excluding fees) in the currency's smallest unit.
33 """
34 amount_total: int
35 """
36 Total for one metric ton of carbon removal (including fees) in the currency's smallest unit.
37 """
38
39 created: int
40 """
41 Time at which the object was created. Measured in seconds since the Unix epoch.
42 """
43 current_prices_per_metric_ton: Dict[str, CurrentPricesPerMetricTon]
44 """
45 Current prices for a metric ton of carbon removal in a currency's smallest unit.
46 """
47 delivery_year: Optional[int]
48 """
49 The year in which the carbon removal is expected to be delivered.
50 """
51 id: str
52 """
53 Unique identifier for the object. For convenience, Climate product IDs are human-readable strings
54 that start with `climsku_`. See [carbon removal inventory](https://stripe.com/docs/climate/orders/carbon-removal-inventory)
55 for a list of available carbon removal products.
56 """
57 livemode: bool
58 """
59 Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
60 """
61 metric_tons_available: str
62 """
63 The quantity of metric tons available for reservation.
64 """
65 name: str
66 """
67 The Climate product's name.
68 """
69 object: Literal["climate.product"]
70 """
71 String representing the object's type. Objects of the same type share the same value.
72 """
73 suppliers: List["Supplier"]
74 """
75 The carbon removal suppliers that fulfill orders for this Climate product.
76 """
77
78 @classmethod
79 def list(
80 cls, **params: Unpack["ProductListParams"]
81 ) -> ListObject["Product"]:
82 """
83 Lists all available Climate product objects.
84 """
85 result = cls._static_request(
86 "get",
87 cls.class_url(),
88 params=params,
89 )
90 if not isinstance(result, ListObject):
91 raise TypeError(
92 "Expected list object from API, got %s"
93 % (type(result).__name__)
94 )
95
96 return result
97
98 @classmethod
99 async def list_async(
100 cls, **params: Unpack["ProductListParams"]
101 ) -> ListObject["Product"]:
102 """
103 Lists all available Climate product objects.
104 """
105 result = await cls._static_request_async(
106 "get",
107 cls.class_url(),
108 params=params,
109 )
110 if not isinstance(result, ListObject):
111 raise TypeError(
112 "Expected list object from API, got %s"
113 % (type(result).__name__)
114 )
115
116 return result
117
118 @classmethod
119 def retrieve(
120 cls, id: str, **params: Unpack["ProductRetrieveParams"]
121 ) -> "Product":
122 """
123 Retrieves the details of a Climate product with the given ID.
124 """
125 instance = cls(id, **params)
126 instance.refresh()
127 return instance
128
129 @classmethod
130 async def retrieve_async(
131 cls, id: str, **params: Unpack["ProductRetrieveParams"]
132 ) -> "Product":
133 """
134 Retrieves the details of a Climate product with the given ID.
135 """
136 instance = cls(id, **params)
137 await instance.refresh_async()
138 return instance
139
140 _inner_class_types = {
141 "current_prices_per_metric_ton": CurrentPricesPerMetricTon,
142 }