paid-python 0.4.1a0__py3-none-any.whl → 0.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. paid/__init__.py +42 -4
  2. paid/agents/client.py +32 -0
  3. paid/agents/raw_client.py +32 -0
  4. paid/client.py +25 -2
  5. paid/core/client_wrapper.py +2 -3
  6. paid/customers/client.py +168 -36
  7. paid/customers/raw_client.py +217 -36
  8. paid/errors/__init__.py +2 -1
  9. paid/errors/internal_server_error.py +11 -0
  10. paid/orders/lines/client.py +0 -4
  11. paid/plans/__init__.py +4 -0
  12. paid/plans/client.py +261 -0
  13. paid/plans/raw_client.py +345 -0
  14. paid/products/__init__.py +7 -0
  15. paid/products/client.py +788 -0
  16. paid/products/raw_client.py +807 -0
  17. paid/products/types/__init__.py +7 -0
  18. paid/products/types/product_create_type.py +5 -0
  19. paid/traces/__init__.py +4 -0
  20. paid/traces/client.py +218 -0
  21. paid/traces/raw_client.py +226 -0
  22. paid/tracing/context_manager.py +9 -4
  23. paid/types/__init__.py +32 -2
  24. paid/types/cost_trace.py +6 -1
  25. paid/types/customer.py +4 -3
  26. paid/types/customer_update.py +4 -2
  27. paid/types/order_line_attribute_create_one.py +5 -0
  28. paid/types/order_line_create.py +26 -5
  29. paid/types/pagination_meta.py +26 -0
  30. paid/types/plan.py +81 -0
  31. paid/types/plan_plan_products_item.py +35 -0
  32. paid/types/plan_plan_products_item_plan_product_attribute_item.py +34 -0
  33. paid/types/product.py +56 -0
  34. paid/types/product_type.py +5 -0
  35. paid/types/product_update.py +36 -0
  36. paid/types/product_update_type.py +5 -0
  37. paid/types/signal.py +17 -5
  38. paid/types/signal_v_2.py +56 -0
  39. paid/types/trace.py +69 -0
  40. paid/types/traces_response.py +26 -0
  41. paid/types/{order_line_attribute_create.py → usage_pagination_meta.py} +16 -8
  42. paid/types/usage_summaries_response.py +26 -0
  43. paid/types/usage_summary.py +121 -0
  44. paid/types/usage_summary_order.py +26 -0
  45. paid/types/usage_summary_order_line.py +26 -0
  46. paid/usage/__init__.py +3 -0
  47. paid/usage/client.py +206 -0
  48. paid/usage/raw_client.py +283 -0
  49. paid/usage/types/__init__.py +7 -0
  50. paid/usage/types/usage_check_usage_response.py +53 -0
  51. {paid_python-0.4.1a0.dist-info → paid_python-0.5.0.dist-info}/METADATA +20 -20
  52. {paid_python-0.4.1a0.dist-info → paid_python-0.5.0.dist-info}/RECORD +54 -25
  53. {paid_python-0.4.1a0.dist-info → paid_python-0.5.0.dist-info}/LICENSE +0 -0
  54. {paid_python-0.4.1a0.dist-info → paid_python-0.5.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,807 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from json.decoder import JSONDecodeError
5
+
6
+ from ..core.api_error import ApiError
7
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8
+ from ..core.http_response import AsyncHttpResponse, HttpResponse
9
+ from ..core.jsonable_encoder import jsonable_encoder
10
+ from ..core.pydantic_utilities import parse_obj_as
11
+ from ..core.request_options import RequestOptions
12
+ from ..core.serialization import convert_and_respect_annotation_metadata
13
+ from ..types.agent_attribute import AgentAttribute
14
+ from ..types.product import Product
15
+ from ..types.product_update_type import ProductUpdateType
16
+ from .types.product_create_type import ProductCreateType
17
+
18
+ # this is used as the default value for optional parameters
19
+ OMIT = typing.cast(typing.Any, ...)
20
+
21
+
22
+ class RawProductsClient:
23
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
24
+ self._client_wrapper = client_wrapper
25
+
26
+ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[typing.List[Product]]:
27
+ """
28
+ Parameters
29
+ ----------
30
+ request_options : typing.Optional[RequestOptions]
31
+ Request-specific configuration.
32
+
33
+ Returns
34
+ -------
35
+ HttpResponse[typing.List[Product]]
36
+ Success response
37
+ """
38
+ _response = self._client_wrapper.httpx_client.request(
39
+ "products",
40
+ method="GET",
41
+ request_options=request_options,
42
+ )
43
+ try:
44
+ if 200 <= _response.status_code < 300:
45
+ _data = typing.cast(
46
+ typing.List[Product],
47
+ parse_obj_as(
48
+ type_=typing.List[Product], # type: ignore
49
+ object_=_response.json(),
50
+ ),
51
+ )
52
+ return HttpResponse(response=_response, data=_data)
53
+ _response_json = _response.json()
54
+ except JSONDecodeError:
55
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
56
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
57
+
58
+ def create(
59
+ self,
60
+ *,
61
+ name: str,
62
+ description: typing.Optional[str] = OMIT,
63
+ external_id: typing.Optional[str] = OMIT,
64
+ type: typing.Optional[ProductCreateType] = OMIT,
65
+ active: typing.Optional[bool] = OMIT,
66
+ product_code: typing.Optional[str] = OMIT,
67
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
68
+ request_options: typing.Optional[RequestOptions] = None,
69
+ ) -> HttpResponse[Product]:
70
+ """
71
+ Parameters
72
+ ----------
73
+ name : str
74
+
75
+ description : typing.Optional[str]
76
+
77
+ external_id : typing.Optional[str]
78
+
79
+ type : typing.Optional[ProductCreateType]
80
+
81
+ active : typing.Optional[bool]
82
+
83
+ product_code : typing.Optional[str]
84
+
85
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
86
+
87
+ request_options : typing.Optional[RequestOptions]
88
+ Request-specific configuration.
89
+
90
+ Returns
91
+ -------
92
+ HttpResponse[Product]
93
+ Success response
94
+ """
95
+ _response = self._client_wrapper.httpx_client.request(
96
+ "products",
97
+ method="POST",
98
+ json={
99
+ "name": name,
100
+ "description": description,
101
+ "externalId": external_id,
102
+ "type": type,
103
+ "active": active,
104
+ "productCode": product_code,
105
+ "metadata": metadata,
106
+ },
107
+ headers={
108
+ "content-type": "application/json",
109
+ },
110
+ request_options=request_options,
111
+ omit=OMIT,
112
+ )
113
+ try:
114
+ if 200 <= _response.status_code < 300:
115
+ _data = typing.cast(
116
+ Product,
117
+ parse_obj_as(
118
+ type_=Product, # type: ignore
119
+ object_=_response.json(),
120
+ ),
121
+ )
122
+ return HttpResponse(response=_response, data=_data)
123
+ _response_json = _response.json()
124
+ except JSONDecodeError:
125
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
126
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
127
+
128
+ def get(self, product_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[Product]:
129
+ """
130
+ Parameters
131
+ ----------
132
+ product_id : str
133
+
134
+ request_options : typing.Optional[RequestOptions]
135
+ Request-specific configuration.
136
+
137
+ Returns
138
+ -------
139
+ HttpResponse[Product]
140
+ Success response
141
+ """
142
+ _response = self._client_wrapper.httpx_client.request(
143
+ f"products/{jsonable_encoder(product_id)}",
144
+ method="GET",
145
+ request_options=request_options,
146
+ )
147
+ try:
148
+ if 200 <= _response.status_code < 300:
149
+ _data = typing.cast(
150
+ Product,
151
+ parse_obj_as(
152
+ type_=Product, # type: ignore
153
+ object_=_response.json(),
154
+ ),
155
+ )
156
+ return HttpResponse(response=_response, data=_data)
157
+ _response_json = _response.json()
158
+ except JSONDecodeError:
159
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
160
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
161
+
162
+ def update(
163
+ self,
164
+ product_id: str,
165
+ *,
166
+ name: typing.Optional[str] = OMIT,
167
+ description: typing.Optional[str] = OMIT,
168
+ external_id: typing.Optional[str] = OMIT,
169
+ type: typing.Optional[ProductUpdateType] = OMIT,
170
+ active: typing.Optional[bool] = OMIT,
171
+ product_code: typing.Optional[str] = OMIT,
172
+ product_attribute: typing.Optional[typing.Sequence[AgentAttribute]] = OMIT,
173
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
174
+ request_options: typing.Optional[RequestOptions] = None,
175
+ ) -> HttpResponse[Product]:
176
+ """
177
+ Parameters
178
+ ----------
179
+ product_id : str
180
+
181
+ name : typing.Optional[str]
182
+
183
+ description : typing.Optional[str]
184
+
185
+ external_id : typing.Optional[str]
186
+
187
+ type : typing.Optional[ProductUpdateType]
188
+
189
+ active : typing.Optional[bool]
190
+
191
+ product_code : typing.Optional[str]
192
+
193
+ product_attribute : typing.Optional[typing.Sequence[AgentAttribute]]
194
+ Pricing attributes for this product
195
+
196
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
197
+
198
+ request_options : typing.Optional[RequestOptions]
199
+ Request-specific configuration.
200
+
201
+ Returns
202
+ -------
203
+ HttpResponse[Product]
204
+ Success response
205
+ """
206
+ _response = self._client_wrapper.httpx_client.request(
207
+ f"products/{jsonable_encoder(product_id)}",
208
+ method="PUT",
209
+ json={
210
+ "name": name,
211
+ "description": description,
212
+ "externalId": external_id,
213
+ "type": type,
214
+ "active": active,
215
+ "productCode": product_code,
216
+ "ProductAttribute": convert_and_respect_annotation_metadata(
217
+ object_=product_attribute, annotation=typing.Sequence[AgentAttribute], direction="write"
218
+ ),
219
+ "metadata": metadata,
220
+ },
221
+ headers={
222
+ "content-type": "application/json",
223
+ },
224
+ request_options=request_options,
225
+ omit=OMIT,
226
+ )
227
+ try:
228
+ if 200 <= _response.status_code < 300:
229
+ _data = typing.cast(
230
+ Product,
231
+ parse_obj_as(
232
+ type_=Product, # type: ignore
233
+ object_=_response.json(),
234
+ ),
235
+ )
236
+ return HttpResponse(response=_response, data=_data)
237
+ _response_json = _response.json()
238
+ except JSONDecodeError:
239
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
240
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
241
+
242
+ def delete(self, product_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]:
243
+ """
244
+ Parameters
245
+ ----------
246
+ product_id : str
247
+
248
+ request_options : typing.Optional[RequestOptions]
249
+ Request-specific configuration.
250
+
251
+ Returns
252
+ -------
253
+ HttpResponse[None]
254
+ """
255
+ _response = self._client_wrapper.httpx_client.request(
256
+ f"products/{jsonable_encoder(product_id)}",
257
+ method="DELETE",
258
+ request_options=request_options,
259
+ )
260
+ try:
261
+ if 200 <= _response.status_code < 300:
262
+ return HttpResponse(response=_response, data=None)
263
+ _response_json = _response.json()
264
+ except JSONDecodeError:
265
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
266
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
267
+
268
+ def get_by_external_id(
269
+ self, external_id: str, *, request_options: typing.Optional[RequestOptions] = None
270
+ ) -> HttpResponse[Product]:
271
+ """
272
+ Parameters
273
+ ----------
274
+ external_id : str
275
+
276
+ request_options : typing.Optional[RequestOptions]
277
+ Request-specific configuration.
278
+
279
+ Returns
280
+ -------
281
+ HttpResponse[Product]
282
+ Success response
283
+ """
284
+ _response = self._client_wrapper.httpx_client.request(
285
+ f"products/external/{jsonable_encoder(external_id)}",
286
+ method="GET",
287
+ request_options=request_options,
288
+ )
289
+ try:
290
+ if 200 <= _response.status_code < 300:
291
+ _data = typing.cast(
292
+ Product,
293
+ parse_obj_as(
294
+ type_=Product, # type: ignore
295
+ object_=_response.json(),
296
+ ),
297
+ )
298
+ return HttpResponse(response=_response, data=_data)
299
+ _response_json = _response.json()
300
+ except JSONDecodeError:
301
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
302
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
303
+
304
+ def update_by_external_id(
305
+ self,
306
+ external_id_: str,
307
+ *,
308
+ name: typing.Optional[str] = OMIT,
309
+ description: typing.Optional[str] = OMIT,
310
+ external_id: typing.Optional[str] = OMIT,
311
+ type: typing.Optional[ProductUpdateType] = OMIT,
312
+ active: typing.Optional[bool] = OMIT,
313
+ product_code: typing.Optional[str] = OMIT,
314
+ product_attribute: typing.Optional[typing.Sequence[AgentAttribute]] = OMIT,
315
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
316
+ request_options: typing.Optional[RequestOptions] = None,
317
+ ) -> HttpResponse[Product]:
318
+ """
319
+ Parameters
320
+ ----------
321
+ external_id_ : str
322
+
323
+ name : typing.Optional[str]
324
+
325
+ description : typing.Optional[str]
326
+
327
+ external_id : typing.Optional[str]
328
+
329
+ type : typing.Optional[ProductUpdateType]
330
+
331
+ active : typing.Optional[bool]
332
+
333
+ product_code : typing.Optional[str]
334
+
335
+ product_attribute : typing.Optional[typing.Sequence[AgentAttribute]]
336
+ Pricing attributes for this product
337
+
338
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
339
+
340
+ request_options : typing.Optional[RequestOptions]
341
+ Request-specific configuration.
342
+
343
+ Returns
344
+ -------
345
+ HttpResponse[Product]
346
+ Success response
347
+ """
348
+ _response = self._client_wrapper.httpx_client.request(
349
+ f"products/external/{jsonable_encoder(external_id_)}",
350
+ method="PUT",
351
+ json={
352
+ "name": name,
353
+ "description": description,
354
+ "externalId": external_id,
355
+ "type": type,
356
+ "active": active,
357
+ "productCode": product_code,
358
+ "ProductAttribute": convert_and_respect_annotation_metadata(
359
+ object_=product_attribute, annotation=typing.Sequence[AgentAttribute], direction="write"
360
+ ),
361
+ "metadata": metadata,
362
+ },
363
+ headers={
364
+ "content-type": "application/json",
365
+ },
366
+ request_options=request_options,
367
+ omit=OMIT,
368
+ )
369
+ try:
370
+ if 200 <= _response.status_code < 300:
371
+ _data = typing.cast(
372
+ Product,
373
+ parse_obj_as(
374
+ type_=Product, # type: ignore
375
+ object_=_response.json(),
376
+ ),
377
+ )
378
+ return HttpResponse(response=_response, data=_data)
379
+ _response_json = _response.json()
380
+ except JSONDecodeError:
381
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
382
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
383
+
384
+ def delete_by_external_id(
385
+ self, external_id: str, *, request_options: typing.Optional[RequestOptions] = None
386
+ ) -> HttpResponse[None]:
387
+ """
388
+ Parameters
389
+ ----------
390
+ external_id : str
391
+
392
+ request_options : typing.Optional[RequestOptions]
393
+ Request-specific configuration.
394
+
395
+ Returns
396
+ -------
397
+ HttpResponse[None]
398
+ """
399
+ _response = self._client_wrapper.httpx_client.request(
400
+ f"products/external/{jsonable_encoder(external_id)}",
401
+ method="DELETE",
402
+ request_options=request_options,
403
+ )
404
+ try:
405
+ if 200 <= _response.status_code < 300:
406
+ return HttpResponse(response=_response, data=None)
407
+ _response_json = _response.json()
408
+ except JSONDecodeError:
409
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
410
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
411
+
412
+
413
+ class AsyncRawProductsClient:
414
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
415
+ self._client_wrapper = client_wrapper
416
+
417
+ async def list(
418
+ self, *, request_options: typing.Optional[RequestOptions] = None
419
+ ) -> AsyncHttpResponse[typing.List[Product]]:
420
+ """
421
+ Parameters
422
+ ----------
423
+ request_options : typing.Optional[RequestOptions]
424
+ Request-specific configuration.
425
+
426
+ Returns
427
+ -------
428
+ AsyncHttpResponse[typing.List[Product]]
429
+ Success response
430
+ """
431
+ _response = await self._client_wrapper.httpx_client.request(
432
+ "products",
433
+ method="GET",
434
+ request_options=request_options,
435
+ )
436
+ try:
437
+ if 200 <= _response.status_code < 300:
438
+ _data = typing.cast(
439
+ typing.List[Product],
440
+ parse_obj_as(
441
+ type_=typing.List[Product], # type: ignore
442
+ object_=_response.json(),
443
+ ),
444
+ )
445
+ return AsyncHttpResponse(response=_response, data=_data)
446
+ _response_json = _response.json()
447
+ except JSONDecodeError:
448
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
449
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
450
+
451
+ async def create(
452
+ self,
453
+ *,
454
+ name: str,
455
+ description: typing.Optional[str] = OMIT,
456
+ external_id: typing.Optional[str] = OMIT,
457
+ type: typing.Optional[ProductCreateType] = OMIT,
458
+ active: typing.Optional[bool] = OMIT,
459
+ product_code: typing.Optional[str] = OMIT,
460
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
461
+ request_options: typing.Optional[RequestOptions] = None,
462
+ ) -> AsyncHttpResponse[Product]:
463
+ """
464
+ Parameters
465
+ ----------
466
+ name : str
467
+
468
+ description : typing.Optional[str]
469
+
470
+ external_id : typing.Optional[str]
471
+
472
+ type : typing.Optional[ProductCreateType]
473
+
474
+ active : typing.Optional[bool]
475
+
476
+ product_code : typing.Optional[str]
477
+
478
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
479
+
480
+ request_options : typing.Optional[RequestOptions]
481
+ Request-specific configuration.
482
+
483
+ Returns
484
+ -------
485
+ AsyncHttpResponse[Product]
486
+ Success response
487
+ """
488
+ _response = await self._client_wrapper.httpx_client.request(
489
+ "products",
490
+ method="POST",
491
+ json={
492
+ "name": name,
493
+ "description": description,
494
+ "externalId": external_id,
495
+ "type": type,
496
+ "active": active,
497
+ "productCode": product_code,
498
+ "metadata": metadata,
499
+ },
500
+ headers={
501
+ "content-type": "application/json",
502
+ },
503
+ request_options=request_options,
504
+ omit=OMIT,
505
+ )
506
+ try:
507
+ if 200 <= _response.status_code < 300:
508
+ _data = typing.cast(
509
+ Product,
510
+ parse_obj_as(
511
+ type_=Product, # type: ignore
512
+ object_=_response.json(),
513
+ ),
514
+ )
515
+ return AsyncHttpResponse(response=_response, data=_data)
516
+ _response_json = _response.json()
517
+ except JSONDecodeError:
518
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
519
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
520
+
521
+ async def get(
522
+ self, product_id: str, *, request_options: typing.Optional[RequestOptions] = None
523
+ ) -> AsyncHttpResponse[Product]:
524
+ """
525
+ Parameters
526
+ ----------
527
+ product_id : str
528
+
529
+ request_options : typing.Optional[RequestOptions]
530
+ Request-specific configuration.
531
+
532
+ Returns
533
+ -------
534
+ AsyncHttpResponse[Product]
535
+ Success response
536
+ """
537
+ _response = await self._client_wrapper.httpx_client.request(
538
+ f"products/{jsonable_encoder(product_id)}",
539
+ method="GET",
540
+ request_options=request_options,
541
+ )
542
+ try:
543
+ if 200 <= _response.status_code < 300:
544
+ _data = typing.cast(
545
+ Product,
546
+ parse_obj_as(
547
+ type_=Product, # type: ignore
548
+ object_=_response.json(),
549
+ ),
550
+ )
551
+ return AsyncHttpResponse(response=_response, data=_data)
552
+ _response_json = _response.json()
553
+ except JSONDecodeError:
554
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
555
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
556
+
557
+ async def update(
558
+ self,
559
+ product_id: str,
560
+ *,
561
+ name: typing.Optional[str] = OMIT,
562
+ description: typing.Optional[str] = OMIT,
563
+ external_id: typing.Optional[str] = OMIT,
564
+ type: typing.Optional[ProductUpdateType] = OMIT,
565
+ active: typing.Optional[bool] = OMIT,
566
+ product_code: typing.Optional[str] = OMIT,
567
+ product_attribute: typing.Optional[typing.Sequence[AgentAttribute]] = OMIT,
568
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
569
+ request_options: typing.Optional[RequestOptions] = None,
570
+ ) -> AsyncHttpResponse[Product]:
571
+ """
572
+ Parameters
573
+ ----------
574
+ product_id : str
575
+
576
+ name : typing.Optional[str]
577
+
578
+ description : typing.Optional[str]
579
+
580
+ external_id : typing.Optional[str]
581
+
582
+ type : typing.Optional[ProductUpdateType]
583
+
584
+ active : typing.Optional[bool]
585
+
586
+ product_code : typing.Optional[str]
587
+
588
+ product_attribute : typing.Optional[typing.Sequence[AgentAttribute]]
589
+ Pricing attributes for this product
590
+
591
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
592
+
593
+ request_options : typing.Optional[RequestOptions]
594
+ Request-specific configuration.
595
+
596
+ Returns
597
+ -------
598
+ AsyncHttpResponse[Product]
599
+ Success response
600
+ """
601
+ _response = await self._client_wrapper.httpx_client.request(
602
+ f"products/{jsonable_encoder(product_id)}",
603
+ method="PUT",
604
+ json={
605
+ "name": name,
606
+ "description": description,
607
+ "externalId": external_id,
608
+ "type": type,
609
+ "active": active,
610
+ "productCode": product_code,
611
+ "ProductAttribute": convert_and_respect_annotation_metadata(
612
+ object_=product_attribute, annotation=typing.Sequence[AgentAttribute], direction="write"
613
+ ),
614
+ "metadata": metadata,
615
+ },
616
+ headers={
617
+ "content-type": "application/json",
618
+ },
619
+ request_options=request_options,
620
+ omit=OMIT,
621
+ )
622
+ try:
623
+ if 200 <= _response.status_code < 300:
624
+ _data = typing.cast(
625
+ Product,
626
+ parse_obj_as(
627
+ type_=Product, # type: ignore
628
+ object_=_response.json(),
629
+ ),
630
+ )
631
+ return AsyncHttpResponse(response=_response, data=_data)
632
+ _response_json = _response.json()
633
+ except JSONDecodeError:
634
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
635
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
636
+
637
+ async def delete(
638
+ self, product_id: str, *, request_options: typing.Optional[RequestOptions] = None
639
+ ) -> AsyncHttpResponse[None]:
640
+ """
641
+ Parameters
642
+ ----------
643
+ product_id : str
644
+
645
+ request_options : typing.Optional[RequestOptions]
646
+ Request-specific configuration.
647
+
648
+ Returns
649
+ -------
650
+ AsyncHttpResponse[None]
651
+ """
652
+ _response = await self._client_wrapper.httpx_client.request(
653
+ f"products/{jsonable_encoder(product_id)}",
654
+ method="DELETE",
655
+ request_options=request_options,
656
+ )
657
+ try:
658
+ if 200 <= _response.status_code < 300:
659
+ return AsyncHttpResponse(response=_response, data=None)
660
+ _response_json = _response.json()
661
+ except JSONDecodeError:
662
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
663
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
664
+
665
+ async def get_by_external_id(
666
+ self, external_id: str, *, request_options: typing.Optional[RequestOptions] = None
667
+ ) -> AsyncHttpResponse[Product]:
668
+ """
669
+ Parameters
670
+ ----------
671
+ external_id : str
672
+
673
+ request_options : typing.Optional[RequestOptions]
674
+ Request-specific configuration.
675
+
676
+ Returns
677
+ -------
678
+ AsyncHttpResponse[Product]
679
+ Success response
680
+ """
681
+ _response = await self._client_wrapper.httpx_client.request(
682
+ f"products/external/{jsonable_encoder(external_id)}",
683
+ method="GET",
684
+ request_options=request_options,
685
+ )
686
+ try:
687
+ if 200 <= _response.status_code < 300:
688
+ _data = typing.cast(
689
+ Product,
690
+ parse_obj_as(
691
+ type_=Product, # type: ignore
692
+ object_=_response.json(),
693
+ ),
694
+ )
695
+ return AsyncHttpResponse(response=_response, data=_data)
696
+ _response_json = _response.json()
697
+ except JSONDecodeError:
698
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
699
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
700
+
701
+ async def update_by_external_id(
702
+ self,
703
+ external_id_: str,
704
+ *,
705
+ name: typing.Optional[str] = OMIT,
706
+ description: typing.Optional[str] = OMIT,
707
+ external_id: typing.Optional[str] = OMIT,
708
+ type: typing.Optional[ProductUpdateType] = OMIT,
709
+ active: typing.Optional[bool] = OMIT,
710
+ product_code: typing.Optional[str] = OMIT,
711
+ product_attribute: typing.Optional[typing.Sequence[AgentAttribute]] = OMIT,
712
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
713
+ request_options: typing.Optional[RequestOptions] = None,
714
+ ) -> AsyncHttpResponse[Product]:
715
+ """
716
+ Parameters
717
+ ----------
718
+ external_id_ : str
719
+
720
+ name : typing.Optional[str]
721
+
722
+ description : typing.Optional[str]
723
+
724
+ external_id : typing.Optional[str]
725
+
726
+ type : typing.Optional[ProductUpdateType]
727
+
728
+ active : typing.Optional[bool]
729
+
730
+ product_code : typing.Optional[str]
731
+
732
+ product_attribute : typing.Optional[typing.Sequence[AgentAttribute]]
733
+ Pricing attributes for this product
734
+
735
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
736
+
737
+ request_options : typing.Optional[RequestOptions]
738
+ Request-specific configuration.
739
+
740
+ Returns
741
+ -------
742
+ AsyncHttpResponse[Product]
743
+ Success response
744
+ """
745
+ _response = await self._client_wrapper.httpx_client.request(
746
+ f"products/external/{jsonable_encoder(external_id_)}",
747
+ method="PUT",
748
+ json={
749
+ "name": name,
750
+ "description": description,
751
+ "externalId": external_id,
752
+ "type": type,
753
+ "active": active,
754
+ "productCode": product_code,
755
+ "ProductAttribute": convert_and_respect_annotation_metadata(
756
+ object_=product_attribute, annotation=typing.Sequence[AgentAttribute], direction="write"
757
+ ),
758
+ "metadata": metadata,
759
+ },
760
+ headers={
761
+ "content-type": "application/json",
762
+ },
763
+ request_options=request_options,
764
+ omit=OMIT,
765
+ )
766
+ try:
767
+ if 200 <= _response.status_code < 300:
768
+ _data = typing.cast(
769
+ Product,
770
+ parse_obj_as(
771
+ type_=Product, # type: ignore
772
+ object_=_response.json(),
773
+ ),
774
+ )
775
+ return AsyncHttpResponse(response=_response, data=_data)
776
+ _response_json = _response.json()
777
+ except JSONDecodeError:
778
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
779
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
780
+
781
+ async def delete_by_external_id(
782
+ self, external_id: str, *, request_options: typing.Optional[RequestOptions] = None
783
+ ) -> AsyncHttpResponse[None]:
784
+ """
785
+ Parameters
786
+ ----------
787
+ external_id : str
788
+
789
+ request_options : typing.Optional[RequestOptions]
790
+ Request-specific configuration.
791
+
792
+ Returns
793
+ -------
794
+ AsyncHttpResponse[None]
795
+ """
796
+ _response = await self._client_wrapper.httpx_client.request(
797
+ f"products/external/{jsonable_encoder(external_id)}",
798
+ method="DELETE",
799
+ request_options=request_options,
800
+ )
801
+ try:
802
+ if 200 <= _response.status_code < 300:
803
+ return AsyncHttpResponse(response=_response, data=None)
804
+ _response_json = _response.json()
805
+ except JSONDecodeError:
806
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
807
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)