paid-python 0.6.0__py3-none-any.whl → 1.0.0a1__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 (140) hide show
  1. paid/__init__.py +65 -95
  2. paid/client.py +17 -494
  3. paid/contacts/client.py +415 -133
  4. paid/contacts/raw_client.py +1046 -118
  5. paid/core/client_wrapper.py +9 -10
  6. paid/customers/client.py +270 -566
  7. paid/customers/raw_client.py +731 -537
  8. paid/environment.py +1 -1
  9. paid/errors/bad_request_error.py +2 -2
  10. paid/errors/forbidden_error.py +2 -2
  11. paid/errors/internal_server_error.py +2 -2
  12. paid/errors/not_found_error.py +2 -2
  13. paid/invoices/client.py +369 -0
  14. paid/invoices/raw_client.py +692 -0
  15. paid/orders/__init__.py +0 -3
  16. paid/orders/client.py +371 -128
  17. paid/orders/raw_client.py +829 -121
  18. paid/products/__init__.py +0 -3
  19. paid/products/client.py +129 -265
  20. paid/products/raw_client.py +563 -233
  21. paid/signals/client.py +130 -0
  22. paid/signals/raw_client.py +190 -0
  23. paid/tracing/autoinstrumentation.py +12 -6
  24. paid/tracing/context_manager.py +2 -6
  25. paid/tracing/distributed_tracing.py +3 -3
  26. paid/tracing/signal.py +3 -3
  27. paid/tracing/wrappers/openai_agents/openaiAgentsHook.py +1 -1
  28. paid/types/__init__.py +62 -86
  29. paid/types/attribution.py +8 -0
  30. paid/types/{agent_attribute.py → bulk_signals_response.py} +4 -5
  31. paid/types/contact.py +12 -20
  32. paid/types/{address.py → contact_billing_address.py} +6 -7
  33. paid/types/{traces_response.py → contact_list_response.py} +5 -9
  34. paid/types/customer.py +15 -22
  35. paid/types/customer_attribution.py +8 -0
  36. paid/types/customer_billing_address.py +26 -0
  37. paid/types/{usage_summary_order.py → customer_by_external_id.py} +3 -5
  38. paid/types/{usage_summary_order_line.py → customer_by_id.py} +3 -5
  39. paid/types/customer_creation_state.py +5 -0
  40. paid/types/customer_list_response.py +22 -0
  41. paid/types/empty_response.py +17 -0
  42. paid/types/{error.py → error_response.py} +4 -7
  43. paid/types/invoice.py +57 -0
  44. paid/types/invoice_line.py +42 -0
  45. paid/types/invoice_line_payment_status.py +7 -0
  46. paid/types/invoice_lines_response.py +22 -0
  47. paid/types/invoice_list_response.py +22 -0
  48. paid/types/invoice_payment_status.py +5 -0
  49. paid/types/invoice_source.py +5 -0
  50. paid/types/invoice_status.py +7 -0
  51. paid/types/invoice_tax_status.py +7 -0
  52. paid/types/order.py +30 -29
  53. paid/types/order_creation_state.py +5 -0
  54. paid/types/order_line.py +6 -24
  55. paid/types/order_lines_response.py +22 -0
  56. paid/types/order_list_response.py +22 -0
  57. paid/types/pagination.py +24 -0
  58. paid/types/product.py +4 -29
  59. paid/types/{tier.py → product_by_external_id.py} +5 -4
  60. paid/types/{cost_amount.py → product_by_id.py} +5 -12
  61. paid/types/product_list_response.py +22 -0
  62. paid/types/signal.py +8 -34
  63. paid/types/{agent.py → update_contact_request.py} +10 -11
  64. paid/types/update_customer_request.py +38 -0
  65. paid/types/{product_update.py → update_product_request.py} +2 -12
  66. {paid_python-0.6.0.dist-info → paid_python-1.0.0a1.dist-info}/METADATA +27 -11
  67. paid_python-1.0.0a1.dist-info/RECORD +110 -0
  68. opentelemetry/instrumentation/openai/__init__.py +0 -54
  69. opentelemetry/instrumentation/openai/shared/__init__.py +0 -399
  70. opentelemetry/instrumentation/openai/shared/audio_wrappers.py +0 -247
  71. opentelemetry/instrumentation/openai/shared/chat_wrappers.py +0 -1192
  72. opentelemetry/instrumentation/openai/shared/completion_wrappers.py +0 -292
  73. opentelemetry/instrumentation/openai/shared/config.py +0 -15
  74. opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py +0 -311
  75. opentelemetry/instrumentation/openai/shared/event_emitter.py +0 -108
  76. opentelemetry/instrumentation/openai/shared/event_models.py +0 -41
  77. opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py +0 -68
  78. opentelemetry/instrumentation/openai/shared/span_utils.py +0 -0
  79. opentelemetry/instrumentation/openai/utils.py +0 -213
  80. opentelemetry/instrumentation/openai/v0/__init__.py +0 -176
  81. opentelemetry/instrumentation/openai/v1/__init__.py +0 -394
  82. opentelemetry/instrumentation/openai/v1/assistant_wrappers.py +0 -329
  83. opentelemetry/instrumentation/openai/v1/event_handler_wrapper.py +0 -134
  84. opentelemetry/instrumentation/openai/v1/responses_wrappers.py +0 -1113
  85. opentelemetry/instrumentation/openai/version.py +0 -1
  86. paid/agents/client.py +0 -880
  87. paid/agents/raw_client.py +0 -785
  88. paid/orders/lines/client.py +0 -144
  89. paid/orders/lines/raw_client.py +0 -129
  90. paid/plans/__init__.py +0 -4
  91. paid/plans/client.py +0 -332
  92. paid/plans/raw_client.py +0 -464
  93. paid/products/types/__init__.py +0 -7
  94. paid/products/types/product_create_type.py +0 -5
  95. paid/traces/__init__.py +0 -4
  96. paid/traces/client.py +0 -218
  97. paid/traces/raw_client.py +0 -226
  98. paid/types/agent_price_point.py +0 -27
  99. paid/types/agent_price_point_tiers.py +0 -23
  100. paid/types/agent_update.py +0 -29
  101. paid/types/api_error.py +0 -29
  102. paid/types/billing_frequency.py +0 -5
  103. paid/types/charge_type.py +0 -5
  104. paid/types/cost_trace.py +0 -55
  105. paid/types/cost_traces_response.py +0 -26
  106. paid/types/creation_source.py +0 -5
  107. paid/types/creation_state.py +0 -5
  108. paid/types/customer_update.py +0 -40
  109. paid/types/entitlement_usage.py +0 -48
  110. paid/types/order_line_attribute.py +0 -27
  111. paid/types/order_line_attribute_create_one.py +0 -5
  112. paid/types/order_line_attribute_pricing.py +0 -33
  113. paid/types/order_line_create.py +0 -72
  114. paid/types/pagination_meta.py +0 -84
  115. paid/types/plan.py +0 -81
  116. paid/types/plan_group.py +0 -60
  117. paid/types/plan_plan_products_item.py +0 -35
  118. paid/types/plan_plan_products_item_plan_product_attribute_item.py +0 -34
  119. paid/types/price_point.py +0 -25
  120. paid/types/pricing.py +0 -31
  121. paid/types/pricing_model_type.py +0 -7
  122. paid/types/product_type.py +0 -5
  123. paid/types/product_update_type.py +0 -5
  124. paid/types/salutation.py +0 -5
  125. paid/types/signal_v_2.py +0 -56
  126. paid/types/tax_exempt_status.py +0 -5
  127. paid/types/trace.py +0 -69
  128. paid/types/usage_pagination_meta.py +0 -43
  129. paid/types/usage_summaries_response.py +0 -26
  130. paid/types/usage_summary.py +0 -121
  131. paid/usage/__init__.py +0 -7
  132. paid/usage/client.py +0 -321
  133. paid/usage/raw_client.py +0 -387
  134. paid/usage/types/__init__.py +0 -7
  135. paid/usage/types/usage_check_usage_response.py +0 -53
  136. paid_python-0.6.0.dist-info/RECORD +0 -153
  137. /paid/{agents → invoices}/__init__.py +0 -0
  138. /paid/{orders/lines → signals}/__init__.py +0 -0
  139. {paid_python-0.6.0.dist-info → paid_python-1.0.0a1.dist-info}/LICENSE +0 -0
  140. {paid_python-0.6.0.dist-info → paid_python-1.0.0a1.dist-info}/WHEEL +0 -0
paid/plans/raw_client.py DELETED
@@ -1,464 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import datetime as dt
4
- import typing
5
- from json.decoder import JSONDecodeError
6
-
7
- from ..core.api_error import ApiError
8
- from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
- from ..core.datetime_utils import serialize_datetime
10
- from ..core.http_response import AsyncHttpResponse, HttpResponse
11
- from ..core.jsonable_encoder import jsonable_encoder
12
- from ..core.pydantic_utilities import parse_obj_as
13
- from ..core.request_options import RequestOptions
14
- from ..errors.bad_request_error import BadRequestError
15
- from ..errors.forbidden_error import ForbiddenError
16
- from ..errors.not_found_error import NotFoundError
17
- from ..types.error import Error
18
- from ..types.plan import Plan
19
- from ..types.plan_group import PlanGroup
20
- from ..types.usage_summaries_response import UsageSummariesResponse
21
-
22
-
23
- class RawPlansClient:
24
- def __init__(self, *, client_wrapper: SyncClientWrapper):
25
- self._client_wrapper = client_wrapper
26
-
27
- def get_by_id(self, plan_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[Plan]:
28
- """
29
- Parameters
30
- ----------
31
- plan_id : str
32
- The ID of the plan
33
-
34
- request_options : typing.Optional[RequestOptions]
35
- Request-specific configuration.
36
-
37
- Returns
38
- -------
39
- HttpResponse[Plan]
40
- Success response
41
- """
42
- _response = self._client_wrapper.httpx_client.request(
43
- f"plans/{jsonable_encoder(plan_id)}",
44
- method="GET",
45
- request_options=request_options,
46
- )
47
- try:
48
- if 200 <= _response.status_code < 300:
49
- _data = typing.cast(
50
- Plan,
51
- parse_obj_as(
52
- type_=Plan, # type: ignore
53
- object_=_response.json(),
54
- ),
55
- )
56
- return HttpResponse(response=_response, data=_data)
57
- if _response.status_code == 403:
58
- raise ForbiddenError(
59
- headers=dict(_response.headers),
60
- body=typing.cast(
61
- Error,
62
- parse_obj_as(
63
- type_=Error, # type: ignore
64
- object_=_response.json(),
65
- ),
66
- ),
67
- )
68
- if _response.status_code == 404:
69
- raise NotFoundError(
70
- headers=dict(_response.headers),
71
- body=typing.cast(
72
- Error,
73
- parse_obj_as(
74
- type_=Error, # type: ignore
75
- object_=_response.json(),
76
- ),
77
- ),
78
- )
79
- _response_json = _response.json()
80
- except JSONDecodeError:
81
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
82
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
83
-
84
- def get_usage(
85
- self,
86
- plan_id: str,
87
- *,
88
- external_id: str,
89
- limit: typing.Optional[int] = None,
90
- offset: typing.Optional[int] = None,
91
- start_time: typing.Optional[dt.datetime] = None,
92
- end_time: typing.Optional[dt.datetime] = None,
93
- request_options: typing.Optional[RequestOptions] = None,
94
- ) -> HttpResponse[UsageSummariesResponse]:
95
- """
96
- Parameters
97
- ----------
98
- plan_id : str
99
- The ID of the plan
100
-
101
- external_id : str
102
- The external ID of the customer
103
-
104
- limit : typing.Optional[int]
105
- Maximum number of usage summaries to return (1-1000)
106
-
107
- offset : typing.Optional[int]
108
- Number of usage summaries to skip for pagination
109
-
110
- start_time : typing.Optional[dt.datetime]
111
- Filter usage summaries starting from this time (ISO 8601 format). Returns summaries that overlap with the time range.
112
-
113
- end_time : typing.Optional[dt.datetime]
114
- Filter usage summaries up to this time (ISO 8601 format). Returns summaries that overlap with the time range.
115
-
116
- request_options : typing.Optional[RequestOptions]
117
- Request-specific configuration.
118
-
119
- Returns
120
- -------
121
- HttpResponse[UsageSummariesResponse]
122
- Success response
123
- """
124
- _response = self._client_wrapper.httpx_client.request(
125
- f"plans/{jsonable_encoder(plan_id)}/usage",
126
- method="GET",
127
- params={
128
- "externalId": external_id,
129
- "limit": limit,
130
- "offset": offset,
131
- "startTime": serialize_datetime(start_time) if start_time is not None else None,
132
- "endTime": serialize_datetime(end_time) if end_time is not None else None,
133
- },
134
- request_options=request_options,
135
- )
136
- try:
137
- if 200 <= _response.status_code < 300:
138
- _data = typing.cast(
139
- UsageSummariesResponse,
140
- parse_obj_as(
141
- type_=UsageSummariesResponse, # type: ignore
142
- object_=_response.json(),
143
- ),
144
- )
145
- return HttpResponse(response=_response, data=_data)
146
- if _response.status_code == 400:
147
- raise BadRequestError(
148
- headers=dict(_response.headers),
149
- body=typing.cast(
150
- Error,
151
- parse_obj_as(
152
- type_=Error, # type: ignore
153
- object_=_response.json(),
154
- ),
155
- ),
156
- )
157
- if _response.status_code == 403:
158
- raise ForbiddenError(
159
- headers=dict(_response.headers),
160
- body=typing.cast(
161
- Error,
162
- parse_obj_as(
163
- type_=Error, # type: ignore
164
- object_=_response.json(),
165
- ),
166
- ),
167
- )
168
- if _response.status_code == 404:
169
- raise NotFoundError(
170
- headers=dict(_response.headers),
171
- body=typing.cast(
172
- Error,
173
- parse_obj_as(
174
- type_=Error, # type: ignore
175
- object_=_response.json(),
176
- ),
177
- ),
178
- )
179
- _response_json = _response.json()
180
- except JSONDecodeError:
181
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
182
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
183
-
184
- def get_group_by_id(
185
- self, plan_group_id: str, *, request_options: typing.Optional[RequestOptions] = None
186
- ) -> HttpResponse[PlanGroup]:
187
- """
188
- Parameters
189
- ----------
190
- plan_group_id : str
191
- The ID of the plan group
192
-
193
- request_options : typing.Optional[RequestOptions]
194
- Request-specific configuration.
195
-
196
- Returns
197
- -------
198
- HttpResponse[PlanGroup]
199
- Success response
200
- """
201
- _response = self._client_wrapper.httpx_client.request(
202
- f"plans/group/{jsonable_encoder(plan_group_id)}",
203
- method="GET",
204
- request_options=request_options,
205
- )
206
- try:
207
- if 200 <= _response.status_code < 300:
208
- _data = typing.cast(
209
- PlanGroup,
210
- parse_obj_as(
211
- type_=PlanGroup, # type: ignore
212
- object_=_response.json(),
213
- ),
214
- )
215
- return HttpResponse(response=_response, data=_data)
216
- if _response.status_code == 403:
217
- raise ForbiddenError(
218
- headers=dict(_response.headers),
219
- body=typing.cast(
220
- Error,
221
- parse_obj_as(
222
- type_=Error, # type: ignore
223
- object_=_response.json(),
224
- ),
225
- ),
226
- )
227
- if _response.status_code == 404:
228
- raise NotFoundError(
229
- headers=dict(_response.headers),
230
- body=typing.cast(
231
- Error,
232
- parse_obj_as(
233
- type_=Error, # type: ignore
234
- object_=_response.json(),
235
- ),
236
- ),
237
- )
238
- _response_json = _response.json()
239
- except JSONDecodeError:
240
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
241
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
242
-
243
-
244
- class AsyncRawPlansClient:
245
- def __init__(self, *, client_wrapper: AsyncClientWrapper):
246
- self._client_wrapper = client_wrapper
247
-
248
- async def get_by_id(
249
- self, plan_id: str, *, request_options: typing.Optional[RequestOptions] = None
250
- ) -> AsyncHttpResponse[Plan]:
251
- """
252
- Parameters
253
- ----------
254
- plan_id : str
255
- The ID of the plan
256
-
257
- request_options : typing.Optional[RequestOptions]
258
- Request-specific configuration.
259
-
260
- Returns
261
- -------
262
- AsyncHttpResponse[Plan]
263
- Success response
264
- """
265
- _response = await self._client_wrapper.httpx_client.request(
266
- f"plans/{jsonable_encoder(plan_id)}",
267
- method="GET",
268
- request_options=request_options,
269
- )
270
- try:
271
- if 200 <= _response.status_code < 300:
272
- _data = typing.cast(
273
- Plan,
274
- parse_obj_as(
275
- type_=Plan, # type: ignore
276
- object_=_response.json(),
277
- ),
278
- )
279
- return AsyncHttpResponse(response=_response, data=_data)
280
- if _response.status_code == 403:
281
- raise ForbiddenError(
282
- headers=dict(_response.headers),
283
- body=typing.cast(
284
- Error,
285
- parse_obj_as(
286
- type_=Error, # type: ignore
287
- object_=_response.json(),
288
- ),
289
- ),
290
- )
291
- if _response.status_code == 404:
292
- raise NotFoundError(
293
- headers=dict(_response.headers),
294
- body=typing.cast(
295
- Error,
296
- parse_obj_as(
297
- type_=Error, # type: ignore
298
- object_=_response.json(),
299
- ),
300
- ),
301
- )
302
- _response_json = _response.json()
303
- except JSONDecodeError:
304
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
305
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
306
-
307
- async def get_usage(
308
- self,
309
- plan_id: str,
310
- *,
311
- external_id: str,
312
- limit: typing.Optional[int] = None,
313
- offset: typing.Optional[int] = None,
314
- start_time: typing.Optional[dt.datetime] = None,
315
- end_time: typing.Optional[dt.datetime] = None,
316
- request_options: typing.Optional[RequestOptions] = None,
317
- ) -> AsyncHttpResponse[UsageSummariesResponse]:
318
- """
319
- Parameters
320
- ----------
321
- plan_id : str
322
- The ID of the plan
323
-
324
- external_id : str
325
- The external ID of the customer
326
-
327
- limit : typing.Optional[int]
328
- Maximum number of usage summaries to return (1-1000)
329
-
330
- offset : typing.Optional[int]
331
- Number of usage summaries to skip for pagination
332
-
333
- start_time : typing.Optional[dt.datetime]
334
- Filter usage summaries starting from this time (ISO 8601 format). Returns summaries that overlap with the time range.
335
-
336
- end_time : typing.Optional[dt.datetime]
337
- Filter usage summaries up to this time (ISO 8601 format). Returns summaries that overlap with the time range.
338
-
339
- request_options : typing.Optional[RequestOptions]
340
- Request-specific configuration.
341
-
342
- Returns
343
- -------
344
- AsyncHttpResponse[UsageSummariesResponse]
345
- Success response
346
- """
347
- _response = await self._client_wrapper.httpx_client.request(
348
- f"plans/{jsonable_encoder(plan_id)}/usage",
349
- method="GET",
350
- params={
351
- "externalId": external_id,
352
- "limit": limit,
353
- "offset": offset,
354
- "startTime": serialize_datetime(start_time) if start_time is not None else None,
355
- "endTime": serialize_datetime(end_time) if end_time is not None else None,
356
- },
357
- request_options=request_options,
358
- )
359
- try:
360
- if 200 <= _response.status_code < 300:
361
- _data = typing.cast(
362
- UsageSummariesResponse,
363
- parse_obj_as(
364
- type_=UsageSummariesResponse, # type: ignore
365
- object_=_response.json(),
366
- ),
367
- )
368
- return AsyncHttpResponse(response=_response, data=_data)
369
- if _response.status_code == 400:
370
- raise BadRequestError(
371
- headers=dict(_response.headers),
372
- body=typing.cast(
373
- Error,
374
- parse_obj_as(
375
- type_=Error, # type: ignore
376
- object_=_response.json(),
377
- ),
378
- ),
379
- )
380
- if _response.status_code == 403:
381
- raise ForbiddenError(
382
- headers=dict(_response.headers),
383
- body=typing.cast(
384
- Error,
385
- parse_obj_as(
386
- type_=Error, # type: ignore
387
- object_=_response.json(),
388
- ),
389
- ),
390
- )
391
- if _response.status_code == 404:
392
- raise NotFoundError(
393
- headers=dict(_response.headers),
394
- body=typing.cast(
395
- Error,
396
- parse_obj_as(
397
- type_=Error, # type: ignore
398
- object_=_response.json(),
399
- ),
400
- ),
401
- )
402
- _response_json = _response.json()
403
- except JSONDecodeError:
404
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
405
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
406
-
407
- async def get_group_by_id(
408
- self, plan_group_id: str, *, request_options: typing.Optional[RequestOptions] = None
409
- ) -> AsyncHttpResponse[PlanGroup]:
410
- """
411
- Parameters
412
- ----------
413
- plan_group_id : str
414
- The ID of the plan group
415
-
416
- request_options : typing.Optional[RequestOptions]
417
- Request-specific configuration.
418
-
419
- Returns
420
- -------
421
- AsyncHttpResponse[PlanGroup]
422
- Success response
423
- """
424
- _response = await self._client_wrapper.httpx_client.request(
425
- f"plans/group/{jsonable_encoder(plan_group_id)}",
426
- method="GET",
427
- request_options=request_options,
428
- )
429
- try:
430
- if 200 <= _response.status_code < 300:
431
- _data = typing.cast(
432
- PlanGroup,
433
- parse_obj_as(
434
- type_=PlanGroup, # type: ignore
435
- object_=_response.json(),
436
- ),
437
- )
438
- return AsyncHttpResponse(response=_response, data=_data)
439
- if _response.status_code == 403:
440
- raise ForbiddenError(
441
- headers=dict(_response.headers),
442
- body=typing.cast(
443
- Error,
444
- parse_obj_as(
445
- type_=Error, # type: ignore
446
- object_=_response.json(),
447
- ),
448
- ),
449
- )
450
- if _response.status_code == 404:
451
- raise NotFoundError(
452
- headers=dict(_response.headers),
453
- body=typing.cast(
454
- Error,
455
- parse_obj_as(
456
- type_=Error, # type: ignore
457
- object_=_response.json(),
458
- ),
459
- ),
460
- )
461
- _response_json = _response.json()
462
- except JSONDecodeError:
463
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
464
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
@@ -1,7 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- # isort: skip_file
4
-
5
- from .product_create_type import ProductCreateType
6
-
7
- __all__ = ["ProductCreateType"]
@@ -1,5 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import typing
4
-
5
- ProductCreateType = typing.Union[typing.Literal["agent", "product", "prepaidCreditBundle"], typing.Any]
paid/traces/__init__.py DELETED
@@ -1,4 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- # isort: skip_file
4
-
paid/traces/client.py DELETED
@@ -1,218 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import datetime as dt
4
- import typing
5
-
6
- from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
7
- from ..core.request_options import RequestOptions
8
- from ..types.traces_response import TracesResponse
9
- from .raw_client import AsyncRawTracesClient, RawTracesClient
10
-
11
-
12
- class TracesClient:
13
- def __init__(self, *, client_wrapper: SyncClientWrapper):
14
- self._raw_client = RawTracesClient(client_wrapper=client_wrapper)
15
-
16
- @property
17
- def with_raw_response(self) -> RawTracesClient:
18
- """
19
- Retrieves a raw implementation of this client that returns raw responses.
20
-
21
- Returns
22
- -------
23
- RawTracesClient
24
- """
25
- return self._raw_client
26
-
27
- def get_traces(
28
- self,
29
- *,
30
- limit: typing.Optional[int] = None,
31
- offset: typing.Optional[int] = None,
32
- start_time: typing.Optional[dt.datetime] = None,
33
- end_time: typing.Optional[dt.datetime] = None,
34
- external_customer_id: typing.Optional[str] = None,
35
- external_product_id: typing.Optional[str] = None,
36
- external_agent_id: typing.Optional[str] = None,
37
- metadata: typing.Optional[str] = None,
38
- request_options: typing.Optional[RequestOptions] = None,
39
- ) -> TracesResponse:
40
- """
41
- Parameters
42
- ----------
43
- limit : typing.Optional[int]
44
- Maximum number of traces to return (1-1000)
45
-
46
- offset : typing.Optional[int]
47
- Number of traces to skip for pagination
48
-
49
- start_time : typing.Optional[dt.datetime]
50
- Filter traces starting from this time (ISO 8601 format)
51
-
52
- end_time : typing.Optional[dt.datetime]
53
- Filter traces up to this time (ISO 8601 format)
54
-
55
- external_customer_id : typing.Optional[str]
56
- Filter traces by external customer ID
57
-
58
- external_product_id : typing.Optional[str]
59
- Filter traces by external product ID
60
-
61
- external_agent_id : typing.Optional[str]
62
- DEPRECATED: Use externalProductId instead. Filter traces by external agent ID
63
-
64
- metadata : typing.Optional[str]
65
- Filter traces by metadata fields. Must be a valid JSON object (e.g., {"key1":"value1","key2":"value2"}). All specified fields must match (AND logic).
66
-
67
- request_options : typing.Optional[RequestOptions]
68
- Request-specific configuration.
69
-
70
- Returns
71
- -------
72
- TracesResponse
73
- Success response
74
-
75
- Examples
76
- --------
77
- import datetime
78
-
79
- from paid import Paid
80
-
81
- client = Paid(
82
- token="YOUR_TOKEN",
83
- )
84
- client.traces.get_traces(
85
- limit=1,
86
- offset=1,
87
- start_time=datetime.datetime.fromisoformat(
88
- "2024-01-15 09:30:00+00:00",
89
- ),
90
- end_time=datetime.datetime.fromisoformat(
91
- "2024-01-15 09:30:00+00:00",
92
- ),
93
- external_customer_id="externalCustomerId",
94
- external_product_id="externalProductId",
95
- external_agent_id="externalAgentId",
96
- metadata="metadata",
97
- )
98
- """
99
- _response = self._raw_client.get_traces(
100
- limit=limit,
101
- offset=offset,
102
- start_time=start_time,
103
- end_time=end_time,
104
- external_customer_id=external_customer_id,
105
- external_product_id=external_product_id,
106
- external_agent_id=external_agent_id,
107
- metadata=metadata,
108
- request_options=request_options,
109
- )
110
- return _response.data
111
-
112
-
113
- class AsyncTracesClient:
114
- def __init__(self, *, client_wrapper: AsyncClientWrapper):
115
- self._raw_client = AsyncRawTracesClient(client_wrapper=client_wrapper)
116
-
117
- @property
118
- def with_raw_response(self) -> AsyncRawTracesClient:
119
- """
120
- Retrieves a raw implementation of this client that returns raw responses.
121
-
122
- Returns
123
- -------
124
- AsyncRawTracesClient
125
- """
126
- return self._raw_client
127
-
128
- async def get_traces(
129
- self,
130
- *,
131
- limit: typing.Optional[int] = None,
132
- offset: typing.Optional[int] = None,
133
- start_time: typing.Optional[dt.datetime] = None,
134
- end_time: typing.Optional[dt.datetime] = None,
135
- external_customer_id: typing.Optional[str] = None,
136
- external_product_id: typing.Optional[str] = None,
137
- external_agent_id: typing.Optional[str] = None,
138
- metadata: typing.Optional[str] = None,
139
- request_options: typing.Optional[RequestOptions] = None,
140
- ) -> TracesResponse:
141
- """
142
- Parameters
143
- ----------
144
- limit : typing.Optional[int]
145
- Maximum number of traces to return (1-1000)
146
-
147
- offset : typing.Optional[int]
148
- Number of traces to skip for pagination
149
-
150
- start_time : typing.Optional[dt.datetime]
151
- Filter traces starting from this time (ISO 8601 format)
152
-
153
- end_time : typing.Optional[dt.datetime]
154
- Filter traces up to this time (ISO 8601 format)
155
-
156
- external_customer_id : typing.Optional[str]
157
- Filter traces by external customer ID
158
-
159
- external_product_id : typing.Optional[str]
160
- Filter traces by external product ID
161
-
162
- external_agent_id : typing.Optional[str]
163
- DEPRECATED: Use externalProductId instead. Filter traces by external agent ID
164
-
165
- metadata : typing.Optional[str]
166
- Filter traces by metadata fields. Must be a valid JSON object (e.g., {"key1":"value1","key2":"value2"}). All specified fields must match (AND logic).
167
-
168
- request_options : typing.Optional[RequestOptions]
169
- Request-specific configuration.
170
-
171
- Returns
172
- -------
173
- TracesResponse
174
- Success response
175
-
176
- Examples
177
- --------
178
- import asyncio
179
- import datetime
180
-
181
- from paid import AsyncPaid
182
-
183
- client = AsyncPaid(
184
- token="YOUR_TOKEN",
185
- )
186
-
187
-
188
- async def main() -> None:
189
- await client.traces.get_traces(
190
- limit=1,
191
- offset=1,
192
- start_time=datetime.datetime.fromisoformat(
193
- "2024-01-15 09:30:00+00:00",
194
- ),
195
- end_time=datetime.datetime.fromisoformat(
196
- "2024-01-15 09:30:00+00:00",
197
- ),
198
- external_customer_id="externalCustomerId",
199
- external_product_id="externalProductId",
200
- external_agent_id="externalAgentId",
201
- metadata="metadata",
202
- )
203
-
204
-
205
- asyncio.run(main())
206
- """
207
- _response = await self._raw_client.get_traces(
208
- limit=limit,
209
- offset=offset,
210
- start_time=start_time,
211
- end_time=end_time,
212
- external_customer_id=external_customer_id,
213
- external_product_id=external_product_id,
214
- external_agent_id=external_agent_id,
215
- metadata=metadata,
216
- request_options=request_options,
217
- )
218
- return _response.data