paid-python 0.4.1a0__py3-none-any.whl → 0.6.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 (57) hide show
  1. paid/__init__.py +44 -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/client.py +10 -0
  11. paid/orders/lines/client.py +0 -4
  12. paid/orders/raw_client.py +10 -0
  13. paid/plans/__init__.py +4 -0
  14. paid/plans/client.py +332 -0
  15. paid/plans/raw_client.py +464 -0
  16. paid/products/__init__.py +7 -0
  17. paid/products/client.py +788 -0
  18. paid/products/raw_client.py +807 -0
  19. paid/products/types/__init__.py +7 -0
  20. paid/products/types/product_create_type.py +5 -0
  21. paid/traces/__init__.py +4 -0
  22. paid/traces/client.py +218 -0
  23. paid/traces/raw_client.py +226 -0
  24. paid/tracing/context_manager.py +9 -4
  25. paid/types/__init__.py +34 -2
  26. paid/types/cost_trace.py +6 -1
  27. paid/types/customer.py +4 -3
  28. paid/types/customer_update.py +4 -2
  29. paid/types/order_line_attribute_create_one.py +5 -0
  30. paid/types/order_line_create.py +26 -5
  31. paid/types/pagination_meta.py +26 -0
  32. paid/types/plan.py +81 -0
  33. paid/types/plan_group.py +60 -0
  34. paid/types/plan_plan_products_item.py +35 -0
  35. paid/types/plan_plan_products_item_plan_product_attribute_item.py +34 -0
  36. paid/types/product.py +56 -0
  37. paid/types/product_type.py +5 -0
  38. paid/types/product_update.py +36 -0
  39. paid/types/product_update_type.py +5 -0
  40. paid/types/signal.py +17 -5
  41. paid/types/signal_v_2.py +56 -0
  42. paid/types/trace.py +69 -0
  43. paid/types/traces_response.py +26 -0
  44. paid/types/{order_line_attribute_create.py → usage_pagination_meta.py} +16 -8
  45. paid/types/usage_summaries_response.py +26 -0
  46. paid/types/usage_summary.py +121 -0
  47. paid/types/usage_summary_order.py +26 -0
  48. paid/types/usage_summary_order_line.py +26 -0
  49. paid/usage/__init__.py +3 -0
  50. paid/usage/client.py +206 -0
  51. paid/usage/raw_client.py +283 -0
  52. paid/usage/types/__init__.py +7 -0
  53. paid/usage/types/usage_check_usage_response.py +53 -0
  54. {paid_python-0.4.1a0.dist-info → paid_python-0.6.0.dist-info}/METADATA +20 -20
  55. {paid_python-0.4.1a0.dist-info → paid_python-0.6.0.dist-info}/RECORD +57 -27
  56. {paid_python-0.4.1a0.dist-info → paid_python-0.6.0.dist-info}/LICENSE +0 -0
  57. {paid_python-0.4.1a0.dist-info → paid_python-0.6.0.dist-info}/WHEEL +0 -0
paid/plans/client.py ADDED
@@ -0,0 +1,332 @@
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.plan import Plan
9
+ from ..types.plan_group import PlanGroup
10
+ from ..types.usage_summaries_response import UsageSummariesResponse
11
+ from .raw_client import AsyncRawPlansClient, RawPlansClient
12
+
13
+
14
+ class PlansClient:
15
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
16
+ self._raw_client = RawPlansClient(client_wrapper=client_wrapper)
17
+
18
+ @property
19
+ def with_raw_response(self) -> RawPlansClient:
20
+ """
21
+ Retrieves a raw implementation of this client that returns raw responses.
22
+
23
+ Returns
24
+ -------
25
+ RawPlansClient
26
+ """
27
+ return self._raw_client
28
+
29
+ def get_by_id(self, plan_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Plan:
30
+ """
31
+ Parameters
32
+ ----------
33
+ plan_id : str
34
+ The ID of the plan
35
+
36
+ request_options : typing.Optional[RequestOptions]
37
+ Request-specific configuration.
38
+
39
+ Returns
40
+ -------
41
+ Plan
42
+ Success response
43
+
44
+ Examples
45
+ --------
46
+ from paid import Paid
47
+
48
+ client = Paid(
49
+ token="YOUR_TOKEN",
50
+ )
51
+ client.plans.get_by_id(
52
+ plan_id="planId",
53
+ )
54
+ """
55
+ _response = self._raw_client.get_by_id(plan_id, request_options=request_options)
56
+ return _response.data
57
+
58
+ def get_usage(
59
+ self,
60
+ plan_id: str,
61
+ *,
62
+ external_id: str,
63
+ limit: typing.Optional[int] = None,
64
+ offset: typing.Optional[int] = None,
65
+ start_time: typing.Optional[dt.datetime] = None,
66
+ end_time: typing.Optional[dt.datetime] = None,
67
+ request_options: typing.Optional[RequestOptions] = None,
68
+ ) -> UsageSummariesResponse:
69
+ """
70
+ Parameters
71
+ ----------
72
+ plan_id : str
73
+ The ID of the plan
74
+
75
+ external_id : str
76
+ The external ID of the customer
77
+
78
+ limit : typing.Optional[int]
79
+ Maximum number of usage summaries to return (1-1000)
80
+
81
+ offset : typing.Optional[int]
82
+ Number of usage summaries to skip for pagination
83
+
84
+ start_time : typing.Optional[dt.datetime]
85
+ Filter usage summaries starting from this time (ISO 8601 format). Returns summaries that overlap with the time range.
86
+
87
+ end_time : typing.Optional[dt.datetime]
88
+ Filter usage summaries up to this time (ISO 8601 format). Returns summaries that overlap with the time range.
89
+
90
+ request_options : typing.Optional[RequestOptions]
91
+ Request-specific configuration.
92
+
93
+ Returns
94
+ -------
95
+ UsageSummariesResponse
96
+ Success response
97
+
98
+ Examples
99
+ --------
100
+ import datetime
101
+
102
+ from paid import Paid
103
+
104
+ client = Paid(
105
+ token="YOUR_TOKEN",
106
+ )
107
+ client.plans.get_usage(
108
+ plan_id="planId",
109
+ external_id="externalId",
110
+ limit=1,
111
+ offset=1,
112
+ start_time=datetime.datetime.fromisoformat(
113
+ "2024-01-15 09:30:00+00:00",
114
+ ),
115
+ end_time=datetime.datetime.fromisoformat(
116
+ "2024-01-15 09:30:00+00:00",
117
+ ),
118
+ )
119
+ """
120
+ _response = self._raw_client.get_usage(
121
+ plan_id,
122
+ external_id=external_id,
123
+ limit=limit,
124
+ offset=offset,
125
+ start_time=start_time,
126
+ end_time=end_time,
127
+ request_options=request_options,
128
+ )
129
+ return _response.data
130
+
131
+ def get_group_by_id(
132
+ self, plan_group_id: str, *, request_options: typing.Optional[RequestOptions] = None
133
+ ) -> PlanGroup:
134
+ """
135
+ Parameters
136
+ ----------
137
+ plan_group_id : str
138
+ The ID of the plan group
139
+
140
+ request_options : typing.Optional[RequestOptions]
141
+ Request-specific configuration.
142
+
143
+ Returns
144
+ -------
145
+ PlanGroup
146
+ Success response
147
+
148
+ Examples
149
+ --------
150
+ from paid import Paid
151
+
152
+ client = Paid(
153
+ token="YOUR_TOKEN",
154
+ )
155
+ client.plans.get_group_by_id(
156
+ plan_group_id="planGroupId",
157
+ )
158
+ """
159
+ _response = self._raw_client.get_group_by_id(plan_group_id, request_options=request_options)
160
+ return _response.data
161
+
162
+
163
+ class AsyncPlansClient:
164
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
165
+ self._raw_client = AsyncRawPlansClient(client_wrapper=client_wrapper)
166
+
167
+ @property
168
+ def with_raw_response(self) -> AsyncRawPlansClient:
169
+ """
170
+ Retrieves a raw implementation of this client that returns raw responses.
171
+
172
+ Returns
173
+ -------
174
+ AsyncRawPlansClient
175
+ """
176
+ return self._raw_client
177
+
178
+ async def get_by_id(self, plan_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Plan:
179
+ """
180
+ Parameters
181
+ ----------
182
+ plan_id : str
183
+ The ID of the plan
184
+
185
+ request_options : typing.Optional[RequestOptions]
186
+ Request-specific configuration.
187
+
188
+ Returns
189
+ -------
190
+ Plan
191
+ Success response
192
+
193
+ Examples
194
+ --------
195
+ import asyncio
196
+
197
+ from paid import AsyncPaid
198
+
199
+ client = AsyncPaid(
200
+ token="YOUR_TOKEN",
201
+ )
202
+
203
+
204
+ async def main() -> None:
205
+ await client.plans.get_by_id(
206
+ plan_id="planId",
207
+ )
208
+
209
+
210
+ asyncio.run(main())
211
+ """
212
+ _response = await self._raw_client.get_by_id(plan_id, request_options=request_options)
213
+ return _response.data
214
+
215
+ async def get_usage(
216
+ self,
217
+ plan_id: str,
218
+ *,
219
+ external_id: str,
220
+ limit: typing.Optional[int] = None,
221
+ offset: typing.Optional[int] = None,
222
+ start_time: typing.Optional[dt.datetime] = None,
223
+ end_time: typing.Optional[dt.datetime] = None,
224
+ request_options: typing.Optional[RequestOptions] = None,
225
+ ) -> UsageSummariesResponse:
226
+ """
227
+ Parameters
228
+ ----------
229
+ plan_id : str
230
+ The ID of the plan
231
+
232
+ external_id : str
233
+ The external ID of the customer
234
+
235
+ limit : typing.Optional[int]
236
+ Maximum number of usage summaries to return (1-1000)
237
+
238
+ offset : typing.Optional[int]
239
+ Number of usage summaries to skip for pagination
240
+
241
+ start_time : typing.Optional[dt.datetime]
242
+ Filter usage summaries starting from this time (ISO 8601 format). Returns summaries that overlap with the time range.
243
+
244
+ end_time : typing.Optional[dt.datetime]
245
+ Filter usage summaries up to this time (ISO 8601 format). Returns summaries that overlap with the time range.
246
+
247
+ request_options : typing.Optional[RequestOptions]
248
+ Request-specific configuration.
249
+
250
+ Returns
251
+ -------
252
+ UsageSummariesResponse
253
+ Success response
254
+
255
+ Examples
256
+ --------
257
+ import asyncio
258
+ import datetime
259
+
260
+ from paid import AsyncPaid
261
+
262
+ client = AsyncPaid(
263
+ token="YOUR_TOKEN",
264
+ )
265
+
266
+
267
+ async def main() -> None:
268
+ await client.plans.get_usage(
269
+ plan_id="planId",
270
+ external_id="externalId",
271
+ limit=1,
272
+ offset=1,
273
+ start_time=datetime.datetime.fromisoformat(
274
+ "2024-01-15 09:30:00+00:00",
275
+ ),
276
+ end_time=datetime.datetime.fromisoformat(
277
+ "2024-01-15 09:30:00+00:00",
278
+ ),
279
+ )
280
+
281
+
282
+ asyncio.run(main())
283
+ """
284
+ _response = await self._raw_client.get_usage(
285
+ plan_id,
286
+ external_id=external_id,
287
+ limit=limit,
288
+ offset=offset,
289
+ start_time=start_time,
290
+ end_time=end_time,
291
+ request_options=request_options,
292
+ )
293
+ return _response.data
294
+
295
+ async def get_group_by_id(
296
+ self, plan_group_id: str, *, request_options: typing.Optional[RequestOptions] = None
297
+ ) -> PlanGroup:
298
+ """
299
+ Parameters
300
+ ----------
301
+ plan_group_id : str
302
+ The ID of the plan group
303
+
304
+ request_options : typing.Optional[RequestOptions]
305
+ Request-specific configuration.
306
+
307
+ Returns
308
+ -------
309
+ PlanGroup
310
+ Success response
311
+
312
+ Examples
313
+ --------
314
+ import asyncio
315
+
316
+ from paid import AsyncPaid
317
+
318
+ client = AsyncPaid(
319
+ token="YOUR_TOKEN",
320
+ )
321
+
322
+
323
+ async def main() -> None:
324
+ await client.plans.get_group_by_id(
325
+ plan_group_id="planGroupId",
326
+ )
327
+
328
+
329
+ asyncio.run(main())
330
+ """
331
+ _response = await self._raw_client.get_group_by_id(plan_group_id, request_options=request_options)
332
+ return _response.data