Debian Codegraph @

stripe/terminal/_location.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._stripe_object import StripeObject
8 from stripe._updateable_api_resource import UpdateableAPIResource
9 from stripe._util import class_method_variant, sanitize_id
10 from typing import ClassVar, Dict, Optional, cast, overload
11 from typing_extensions import Literal, Unpack, TYPE_CHECKING
12
13 if TYPE_CHECKING:
14 from stripe.params.terminal._location_create_params import (
15 LocationCreateParams,
16 )
17 from stripe.params.terminal._location_delete_params import (
18 LocationDeleteParams,
19 )
20 from stripe.params.terminal._location_list_params import LocationListParams
21 from stripe.params.terminal._location_modify_params import (
22 LocationModifyParams,
23 )
24 from stripe.params.terminal._location_retrieve_params import (
25 LocationRetrieveParams,
26 )
27
28
29 class Location(
30 CreateableAPIResource["Location"],
31 DeletableAPIResource["Location"],
32 ListableAPIResource["Location"],
33 UpdateableAPIResource["Location"],
34 ):
35 """
36 A Location represents a grouping of readers.
37
38 Related guide: [Fleet management](https://docs.stripe.com/terminal/fleet/locations)
39 """
40
41 OBJECT_NAME: ClassVar[Literal["terminal.location"]] = "terminal.location"
42
43 class Address(StripeObject):
44 city: Optional[str]
45 """
46 City, district, suburb, town, or village.
47 """
48 country: Optional[str]
49 """
50 Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
51 """
52 line1: Optional[str]
53 """
54 Address line 1, such as the street, PO Box, or company name.
55 """
56 line2: Optional[str]
57 """
58 Address line 2, such as the apartment, suite, unit, or building.
59 """
60 postal_code: Optional[str]
61 """
62 ZIP or postal code.
63 """
64 state: Optional[str]
65 """
66 State, county, province, or region ([ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2)).
67 """
68
69 class AddressKana(StripeObject):
70 city: Optional[str]
71 """
72 City/Ward.
73 """
74 country: Optional[str]
75 """
76 Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
77 """
78 line1: Optional[str]
79 """
80 Block/Building number.
81 """
82 line2: Optional[str]
83 """
84 Building details.
85 """
86 postal_code: Optional[str]
87 """
88 ZIP or postal code.
89 """
90 state: Optional[str]
91 """
92 Prefecture.
93 """
94 town: Optional[str]
95 """
96 Town/cho-me.
97 """
98
99 class AddressKanji(StripeObject):
100 city: Optional[str]
101 """
102 City/Ward.
103 """
104 country: Optional[str]
105 """
106 Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
107 """
108 line1: Optional[str]
109 """
110 Block/Building number.
111 """
112 line2: Optional[str]
113 """
114 Building details.
115 """
116 postal_code: Optional[str]
117 """
118 ZIP or postal code.
119 """
120 state: Optional[str]
121 """
122 Prefecture.
123 """
124 town: Optional[str]
125 """
126 Town/cho-me.
127 """
128
129 address: Address
130 address_kana: Optional[AddressKana]
131 address_kanji: Optional[AddressKanji]
132 configuration_overrides: Optional[str]
133 """
134 The ID of a configuration that will be used to customize all readers in this location.
135 """
136 deleted: Optional[Literal[True]]
137 """
138 Always true for a deleted object
139 """
140 display_name: str
141 """
142 The display name of the location.
143 """
144 display_name_kana: Optional[str]
145 """
146 The Kana variation of the display name of the location.
147 """
148 display_name_kanji: Optional[str]
149 """
150 The Kanji variation of the display name of the location.
151 """
152 id: str
153 """
154 Unique identifier for the object.
155 """
156 livemode: bool
157 """
158 Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
159 """
160 metadata: Dict[str, str]
161 """
162 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.
163 """
164 object: Literal["terminal.location"]
165 """
166 String representing the object's type. Objects of the same type share the same value.
167 """
168 phone: Optional[str]
169 """
170 The phone number of the location.
171 """
172
173 @classmethod
174 def create(cls, **params: Unpack["LocationCreateParams"]) -> "Location":
175 """
176 Creates a new Location object.
177 For further details, including which address fields are required in each country, see the [Manage locations](https://docs.stripe.com/docs/terminal/fleet/locations) guide.
178 """
179 return cast(
180 "Location",
181 cls._static_request(
182 "post",
183 cls.class_url(),
184 params=params,
185 ),
186 )
187
188 @classmethod
189 async def create_async(
190 cls, **params: Unpack["LocationCreateParams"]
191 ) -> "Location":
192 """
193 Creates a new Location object.
194 For further details, including which address fields are required in each country, see the [Manage locations](https://docs.stripe.com/docs/terminal/fleet/locations) guide.
195 """
196 return cast(
197 "Location",
198 await cls._static_request_async(
199 "post",
200 cls.class_url(),
201 params=params,
202 ),
203 )
204
205 @classmethod
206 def _cls_delete(
207 cls, sid: str, **params: Unpack["LocationDeleteParams"]
208 ) -> "Location":
209 """
210 Deletes a Location object.
211 """
212 url = "%s/%s" % (cls.class_url(), sanitize_id(sid))
213 return cast(
214 "Location",
215 cls._static_request(
216 "delete",
217 url,
218 params=params,
219 ),
220 )
221
222 @overload
223 @staticmethod
224 def delete(
225 sid: str, **params: Unpack["LocationDeleteParams"]
226 ) -> "Location":
227 """
228 Deletes a Location object.
229 """
230 ...
231
232 @overload
233 def delete(self, **params: Unpack["LocationDeleteParams"]) -> "Location":
234 """
235 Deletes a Location object.
236 """
237 ...
238
239 @class_method_variant("_cls_delete")
240 def delete( # pyright: ignore[reportGeneralTypeIssues]
241 self, **params: Unpack["LocationDeleteParams"]
242 ) -> "Location":
243 """
244 Deletes a Location object.
245 """
246 return self._request_and_refresh(
247 "delete",
248 self.instance_url(),
249 params=params,
250 )
251
252 @classmethod
253 async def _cls_delete_async(
254 cls, sid: str, **params: Unpack["LocationDeleteParams"]
255 ) -> "Location":
256 """
257 Deletes a Location object.
258 """
259 url = "%s/%s" % (cls.class_url(), sanitize_id(sid))
260 return cast(
261 "Location",
262 await cls._static_request_async(
263 "delete",
264 url,
265 params=params,
266 ),
267 )
268
269 @overload
270 @staticmethod
271 async def delete_async(
272 sid: str, **params: Unpack["LocationDeleteParams"]
273 ) -> "Location":
274 """
275 Deletes a Location object.
276 """
277 ...
278
279 @overload
280 async def delete_async(
281 self, **params: Unpack["LocationDeleteParams"]
282 ) -> "Location":
283 """
284 Deletes a Location object.
285 """
286 ...
287
288 @class_method_variant("_cls_delete_async")
289 async def delete_async( # pyright: ignore[reportGeneralTypeIssues]
290 self, **params: Unpack["LocationDeleteParams"]
291 ) -> "Location":
292 """
293 Deletes a Location object.
294 """
295 return await self._request_and_refresh_async(
296 "delete",
297 self.instance_url(),
298 params=params,
299 )
300
301 @classmethod
302 def list(
303 cls, **params: Unpack["LocationListParams"]
304 ) -> ListObject["Location"]:
305 """
306 Returns a list of Location objects.
307 """
308 result = cls._static_request(
309 "get",
310 cls.class_url(),
311 params=params,
312 )
313 if not isinstance(result, ListObject):
314 raise TypeError(
315 "Expected list object from API, got %s"
316 % (type(result).__name__)
317 )
318
319 return result
320
321 @classmethod
322 async def list_async(
323 cls, **params: Unpack["LocationListParams"]
324 ) -> ListObject["Location"]:
325 """
326 Returns a list of Location objects.
327 """
328 result = await cls._static_request_async(
329 "get",
330 cls.class_url(),
331 params=params,
332 )
333 if not isinstance(result, ListObject):
334 raise TypeError(
335 "Expected list object from API, got %s"
336 % (type(result).__name__)
337 )
338
339 return result
340
341 @classmethod
342 def modify(
343 cls, id: str, **params: Unpack["LocationModifyParams"]
344 ) -> "Location":
345 """
346 Updates a Location object by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
347 """
348 url = "%s/%s" % (cls.class_url(), sanitize_id(id))
349 return cast(
350 "Location",
351 cls._static_request(
352 "post",
353 url,
354 params=params,
355 ),
356 )
357
358 @classmethod
359 async def modify_async(
360 cls, id: str, **params: Unpack["LocationModifyParams"]
361 ) -> "Location":
362 """
363 Updates a Location object by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
364 """
365 url = "%s/%s" % (cls.class_url(), sanitize_id(id))
366 return cast(
367 "Location",
368 await cls._static_request_async(
369 "post",
370 url,
371 params=params,
372 ),
373 )
374
375 @classmethod
376 def retrieve(
377 cls, id: str, **params: Unpack["LocationRetrieveParams"]
378 ) -> "Location":
379 """
380 Retrieves a Location object.
381 """
382 instance = cls(id, **params)
383 instance.refresh()
384 return instance
385
386 @classmethod
387 async def retrieve_async(
388 cls, id: str, **params: Unpack["LocationRetrieveParams"]
389 ) -> "Location":
390 """
391 Retrieves a Location object.
392 """
393 instance = cls(id, **params)
394 await instance.refresh_async()
395 return instance
396
397 _inner_class_types = {
398 "address": Address,
399 "address_kana": AddressKana,
400 "address_kanji": AddressKanji,
401 }