Debian Codegraph @

stripe/radar/_value_list.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._updateable_api_resource import UpdateableAPIResource
8 from stripe._util import class_method_variant, sanitize_id
9 from typing import ClassVar, Dict, Optional, cast, overload
10 from typing_extensions import Literal, Unpack, TYPE_CHECKING
11
12 if TYPE_CHECKING:
13 from stripe.params.radar._value_list_create_params import (
14 ValueListCreateParams,
15 )
16 from stripe.params.radar._value_list_delete_params import (
17 ValueListDeleteParams,
18 )
19 from stripe.params.radar._value_list_list_params import ValueListListParams
20 from stripe.params.radar._value_list_modify_params import (
21 ValueListModifyParams,
22 )
23 from stripe.params.radar._value_list_retrieve_params import (
24 ValueListRetrieveParams,
25 )
26 from stripe.radar._value_list_item import ValueListItem
27
28
29 class ValueList(
30 CreateableAPIResource["ValueList"],
31 DeletableAPIResource["ValueList"],
32 ListableAPIResource["ValueList"],
33 UpdateableAPIResource["ValueList"],
34 ):
35 """
36 Value lists allow you to group values together which can then be referenced in rules.
37
38 Related guide: [Default Stripe lists](https://docs.stripe.com/radar/lists#managing-list-items)
39 """
40
41 OBJECT_NAME: ClassVar[Literal["radar.value_list"]] = "radar.value_list"
42 alias: str
43 """
44 The name of the value list for use in rules.
45 """
46 created: int
47 """
48 Time at which the object was created. Measured in seconds since the Unix epoch.
49 """
50 created_by: str
51 """
52 The name or email address of the user who created this value list.
53 """
54 deleted: Optional[Literal[True]]
55 """
56 Always true for a deleted object
57 """
58 id: str
59 """
60 Unique identifier for the object.
61 """
62 item_type: Literal[
63 "card_bin",
64 "card_fingerprint",
65 "case_sensitive_string",
66 "country",
67 "customer_id",
68 "email",
69 "ip_address",
70 "sepa_debit_fingerprint",
71 "string",
72 "us_bank_account_fingerprint",
73 ]
74 """
75 The type of items in the value list. One of `card_fingerprint`, `card_bin`, `email`, `ip_address`, `country`, `string`, `case_sensitive_string`, `customer_id`, `sepa_debit_fingerprint`, or `us_bank_account_fingerprint`.
76 """
77 list_items: ListObject["ValueListItem"]
78 """
79 List of items contained within this value list.
80 """
81 livemode: bool
82 """
83 Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
84 """
85 metadata: Dict[str, str]
86 """
87 Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
88 """
89 name: str
90 """
91 The name of the value list.
92 """
93 object: Literal["radar.value_list"]
94 """
95 String representing the object's type. Objects of the same type share the same value.
96 """
97
98 @classmethod
99 def create(cls, **params: Unpack["ValueListCreateParams"]) -> "ValueList":
100 """
101 Creates a new ValueList object, which can then be referenced in rules.
102 """
103 return cast(
104 "ValueList",
105 cls._static_request(
106 "post",
107 cls.class_url(),
108 params=params,
109 ),
110 )
111
112 @classmethod
113 async def create_async(
114 cls, **params: Unpack["ValueListCreateParams"]
115 ) -> "ValueList":
116 """
117 Creates a new ValueList object, which can then be referenced in rules.
118 """
119 return cast(
120 "ValueList",
121 await cls._static_request_async(
122 "post",
123 cls.class_url(),
124 params=params,
125 ),
126 )
127
128 @classmethod
129 def _cls_delete(
130 cls, sid: str, **params: Unpack["ValueListDeleteParams"]
131 ) -> "ValueList":
132 """
133 Deletes a ValueList object, also deleting any items contained within the value list. To be deleted, a value list must not be referenced in any rules.
134 """
135 url = "%s/%s" % (cls.class_url(), sanitize_id(sid))
136 return cast(
137 "ValueList",
138 cls._static_request(
139 "delete",
140 url,
141 params=params,
142 ),
143 )
144
145 @overload
146 @staticmethod
147 def delete(
148 sid: str, **params: Unpack["ValueListDeleteParams"]
149 ) -> "ValueList":
150 """
151 Deletes a ValueList object, also deleting any items contained within the value list. To be deleted, a value list must not be referenced in any rules.
152 """
153 ...
154
155 @overload
156 def delete(self, **params: Unpack["ValueListDeleteParams"]) -> "ValueList":
157 """
158 Deletes a ValueList object, also deleting any items contained within the value list. To be deleted, a value list must not be referenced in any rules.
159 """
160 ...
161
162 @class_method_variant("_cls_delete")
163 def delete( # pyright: ignore[reportGeneralTypeIssues]
164 self, **params: Unpack["ValueListDeleteParams"]
165 ) -> "ValueList":
166 """
167 Deletes a ValueList object, also deleting any items contained within the value list. To be deleted, a value list must not be referenced in any rules.
168 """
169 return self._request_and_refresh(
170 "delete",
171 self.instance_url(),
172 params=params,
173 )
174
175 @classmethod
176 async def _cls_delete_async(
177 cls, sid: str, **params: Unpack["ValueListDeleteParams"]
178 ) -> "ValueList":
179 """
180 Deletes a ValueList object, also deleting any items contained within the value list. To be deleted, a value list must not be referenced in any rules.
181 """
182 url = "%s/%s" % (cls.class_url(), sanitize_id(sid))
183 return cast(
184 "ValueList",
185 await cls._static_request_async(
186 "delete",
187 url,
188 params=params,
189 ),
190 )
191
192 @overload
193 @staticmethod
194 async def delete_async(
195 sid: str, **params: Unpack["ValueListDeleteParams"]
196 ) -> "ValueList":
197 """
198 Deletes a ValueList object, also deleting any items contained within the value list. To be deleted, a value list must not be referenced in any rules.
199 """
200 ...
201
202 @overload
203 async def delete_async(
204 self, **params: Unpack["ValueListDeleteParams"]
205 ) -> "ValueList":
206 """
207 Deletes a ValueList object, also deleting any items contained within the value list. To be deleted, a value list must not be referenced in any rules.
208 """
209 ...
210
211 @class_method_variant("_cls_delete_async")
212 async def delete_async( # pyright: ignore[reportGeneralTypeIssues]
213 self, **params: Unpack["ValueListDeleteParams"]
214 ) -> "ValueList":
215 """
216 Deletes a ValueList object, also deleting any items contained within the value list. To be deleted, a value list must not be referenced in any rules.
217 """
218 return await self._request_and_refresh_async(
219 "delete",
220 self.instance_url(),
221 params=params,
222 )
223
224 @classmethod
225 def list(
226 cls, **params: Unpack["ValueListListParams"]
227 ) -> ListObject["ValueList"]:
228 """
229 Returns a list of ValueList objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first.
230 """
231 result = cls._static_request(
232 "get",
233 cls.class_url(),
234 params=params,
235 )
236 if not isinstance(result, ListObject):
237 raise TypeError(
238 "Expected list object from API, got %s"
239 % (type(result).__name__)
240 )
241
242 return result
243
244 @classmethod
245 async def list_async(
246 cls, **params: Unpack["ValueListListParams"]
247 ) -> ListObject["ValueList"]:
248 """
249 Returns a list of ValueList objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first.
250 """
251 result = await cls._static_request_async(
252 "get",
253 cls.class_url(),
254 params=params,
255 )
256 if not isinstance(result, ListObject):
257 raise TypeError(
258 "Expected list object from API, got %s"
259 % (type(result).__name__)
260 )
261
262 return result
263
264 @classmethod
265 def modify(
266 cls, id: str, **params: Unpack["ValueListModifyParams"]
267 ) -> "ValueList":
268 """
269 Updates a ValueList object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. Note that item_type is immutable.
270 """
271 url = "%s/%s" % (cls.class_url(), sanitize_id(id))
272 return cast(
273 "ValueList",
274 cls._static_request(
275 "post",
276 url,
277 params=params,
278 ),
279 )
280
281 @classmethod
282 async def modify_async(
283 cls, id: str, **params: Unpack["ValueListModifyParams"]
284 ) -> "ValueList":
285 """
286 Updates a ValueList object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. Note that item_type is immutable.
287 """
288 url = "%s/%s" % (cls.class_url(), sanitize_id(id))
289 return cast(
290 "ValueList",
291 await cls._static_request_async(
292 "post",
293 url,
294 params=params,
295 ),
296 )
297
298 @classmethod
299 def retrieve(
300 cls, id: str, **params: Unpack["ValueListRetrieveParams"]
301 ) -> "ValueList":
302 """
303 Retrieves a ValueList object.
304 """
305 instance = cls(id, **params)
306 instance.refresh()
307 return instance
308
309 @classmethod
310 async def retrieve_async(
311 cls, id: str, **params: Unpack["ValueListRetrieveParams"]
312 ) -> "ValueList":
313 """
314 Retrieves a ValueList object.
315 """
316 instance = cls(id, **params)
317 await instance.refresh_async()
318 return instance