Debian Codegraph @

stripe/radar/_value_list_item.py

raw
1 # -*- coding: utf-8 -*-
2 # File generated from our OpenAPI spec
3 from stripe._createable_api_resource import CreateableAPIResource
4 from stripe._deletable_api_resource import DeletableAPIResource
5 from stripe._list_object import ListObject
6 from stripe._listable_api_resource import ListableAPIResource
7 from stripe._util import class_method_variant, sanitize_id
8 from typing import ClassVar, Optional, cast, overload
9 from typing_extensions import Literal, Unpack, TYPE_CHECKING
10
11 if TYPE_CHECKING:
12 from stripe.params.radar._value_list_item_create_params import (
13 ValueListItemCreateParams,
14 )
15 from stripe.params.radar._value_list_item_delete_params import (
16 ValueListItemDeleteParams,
17 )
18 from stripe.params.radar._value_list_item_list_params import (
19 ValueListItemListParams,
20 )
21 from stripe.params.radar._value_list_item_retrieve_params import (
22 ValueListItemRetrieveParams,
23 )
24
25
26 class ValueListItem(
27 CreateableAPIResource["ValueListItem"],
28 DeletableAPIResource["ValueListItem"],
29 ListableAPIResource["ValueListItem"],
30 ):
31 """
32 Value list items allow you to add specific values to a given Radar value list, which can then be used in rules.
33
34 Related guide: [Managing list items](https://docs.stripe.com/radar/lists#managing-list-items)
35 """
36
37 OBJECT_NAME: ClassVar[Literal["radar.value_list_item"]] = (
38 "radar.value_list_item"
39 )
40 created: int
41 """
42 Time at which the object was created. Measured in seconds since the Unix epoch.
43 """
44 created_by: str
45 """
46 The name or email address of the user who added this item to the value list.
47 """
48 deleted: Optional[Literal[True]]
49 """
50 Always true for a deleted object
51 """
52 id: str
53 """
54 Unique identifier for the object.
55 """
56 livemode: bool
57 """
58 Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
59 """
60 object: Literal["radar.value_list_item"]
61 """
62 String representing the object's type. Objects of the same type share the same value.
63 """
64 value: str
65 """
66 The value of the item.
67 """
68 value_list: str
69 """
70 The identifier of the value list this item belongs to.
71 """
72
73 @classmethod
74 def create(
75 cls, **params: Unpack["ValueListItemCreateParams"]
76 ) -> "ValueListItem":
77 """
78 Creates a new ValueListItem object, which is added to the specified parent value list.
79 """
80 return cast(
81 "ValueListItem",
82 cls._static_request(
83 "post",
84 cls.class_url(),
85 params=params,
86 ),
87 )
88
89 @classmethod
90 async def create_async(
91 cls, **params: Unpack["ValueListItemCreateParams"]
92 ) -> "ValueListItem":
93 """
94 Creates a new ValueListItem object, which is added to the specified parent value list.
95 """
96 return cast(
97 "ValueListItem",
98 await cls._static_request_async(
99 "post",
100 cls.class_url(),
101 params=params,
102 ),
103 )
104
105 @classmethod
106 def _cls_delete(
107 cls, sid: str, **params: Unpack["ValueListItemDeleteParams"]
108 ) -> "ValueListItem":
109 """
110 Deletes a ValueListItem object, removing it from its parent value list.
111 """
112 url = "%s/%s" % (cls.class_url(), sanitize_id(sid))
113 return cast(
114 "ValueListItem",
115 cls._static_request(
116 "delete",
117 url,
118 params=params,
119 ),
120 )
121
122 @overload
123 @staticmethod
124 def delete(
125 sid: str, **params: Unpack["ValueListItemDeleteParams"]
126 ) -> "ValueListItem":
127 """
128 Deletes a ValueListItem object, removing it from its parent value list.
129 """
130 ...
131
132 @overload
133 def delete(
134 self, **params: Unpack["ValueListItemDeleteParams"]
135 ) -> "ValueListItem":
136 """
137 Deletes a ValueListItem object, removing it from its parent value list.
138 """
139 ...
140
141 @class_method_variant("_cls_delete")
142 def delete( # pyright: ignore[reportGeneralTypeIssues]
143 self, **params: Unpack["ValueListItemDeleteParams"]
144 ) -> "ValueListItem":
145 """
146 Deletes a ValueListItem object, removing it from its parent value list.
147 """
148 return self._request_and_refresh(
149 "delete",
150 self.instance_url(),
151 params=params,
152 )
153
154 @classmethod
155 async def _cls_delete_async(
156 cls, sid: str, **params: Unpack["ValueListItemDeleteParams"]
157 ) -> "ValueListItem":
158 """
159 Deletes a ValueListItem object, removing it from its parent value list.
160 """
161 url = "%s/%s" % (cls.class_url(), sanitize_id(sid))
162 return cast(
163 "ValueListItem",
164 await cls._static_request_async(
165 "delete",
166 url,
167 params=params,
168 ),
169 )
170
171 @overload
172 @staticmethod
173 async def delete_async(
174 sid: str, **params: Unpack["ValueListItemDeleteParams"]
175 ) -> "ValueListItem":
176 """
177 Deletes a ValueListItem object, removing it from its parent value list.
178 """
179 ...
180
181 @overload
182 async def delete_async(
183 self, **params: Unpack["ValueListItemDeleteParams"]
184 ) -> "ValueListItem":
185 """
186 Deletes a ValueListItem object, removing it from its parent value list.
187 """
188 ...
189
190 @class_method_variant("_cls_delete_async")
191 async def delete_async( # pyright: ignore[reportGeneralTypeIssues]
192 self, **params: Unpack["ValueListItemDeleteParams"]
193 ) -> "ValueListItem":
194 """
195 Deletes a ValueListItem object, removing it from its parent value list.
196 """
197 return await self._request_and_refresh_async(
198 "delete",
199 self.instance_url(),
200 params=params,
201 )
202
203 @classmethod
204 def list(
205 cls, **params: Unpack["ValueListItemListParams"]
206 ) -> ListObject["ValueListItem"]:
207 """
208 Returns a list of ValueListItem objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first.
209 """
210 result = cls._static_request(
211 "get",
212 cls.class_url(),
213 params=params,
214 )
215 if not isinstance(result, ListObject):
216 raise TypeError(
217 "Expected list object from API, got %s"
218 % (type(result).__name__)
219 )
220
221 return result
222
223 @classmethod
224 async def list_async(
225 cls, **params: Unpack["ValueListItemListParams"]
226 ) -> ListObject["ValueListItem"]:
227 """
228 Returns a list of ValueListItem objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first.
229 """
230 result = await cls._static_request_async(
231 "get",
232 cls.class_url(),
233 params=params,
234 )
235 if not isinstance(result, ListObject):
236 raise TypeError(
237 "Expected list object from API, got %s"
238 % (type(result).__name__)
239 )
240
241 return result
242
243 @classmethod
244 def retrieve(
245 cls, id: str, **params: Unpack["ValueListItemRetrieveParams"]
246 ) -> "ValueListItem":
247 """
248 Retrieves a ValueListItem object.
249 """
250 instance = cls(id, **params)
251 instance.refresh()
252 return instance
253
254 @classmethod
255 async def retrieve_async(
256 cls, id: str, **params: Unpack["ValueListItemRetrieveParams"]
257 ) -> "ValueListItem":
258 """
259 Retrieves a ValueListItem object.
260 """
261 instance = cls(id, **params)
262 await instance.refresh_async()
263 return instance