paid-python 1.0.0a0__py3-none-any.whl → 1.0.0a2__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 (137) hide show
  1. paid/__init__.py +61 -122
  2. paid/client.py +16 -22
  3. paid/contacts/client.py +417 -133
  4. paid/contacts/raw_client.py +1048 -118
  5. paid/core/client_wrapper.py +8 -10
  6. paid/customers/__init__.py +0 -3
  7. paid/customers/client.py +394 -1112
  8. paid/customers/raw_client.py +656 -1054
  9. paid/environment.py +1 -1
  10. paid/errors/bad_request_error.py +2 -2
  11. paid/errors/forbidden_error.py +2 -2
  12. paid/errors/internal_server_error.py +2 -2
  13. paid/errors/not_found_error.py +2 -2
  14. paid/invoices/client.py +369 -0
  15. paid/{plans → invoices}/raw_client.py +312 -201
  16. paid/orders/__init__.py +0 -3
  17. paid/orders/client.py +281 -471
  18. paid/orders/raw_client.py +552 -537
  19. paid/products/__init__.py +0 -3
  20. paid/products/client.py +129 -265
  21. paid/products/raw_client.py +565 -233
  22. paid/signals/client.py +130 -0
  23. paid/signals/raw_client.py +190 -0
  24. paid/tracing/autoinstrumentation.py +12 -6
  25. paid/tracing/context_manager.py +2 -6
  26. paid/tracing/distributed_tracing.py +3 -3
  27. paid/tracing/signal.py +3 -3
  28. paid/tracing/wrappers/openai_agents/openaiAgentsHook.py +1 -1
  29. paid/types/__init__.py +58 -110
  30. paid/types/attribution.py +8 -0
  31. paid/types/{agent_attribute.py → bulk_signals_response.py} +4 -5
  32. paid/types/contact.py +12 -20
  33. paid/types/{address.py → contact_billing_address.py} +6 -7
  34. paid/types/{traces_response.py → contact_list_response.py} +5 -9
  35. paid/types/customer.py +15 -22
  36. paid/types/customer_attribution.py +8 -0
  37. paid/types/customer_billing_address.py +26 -0
  38. paid/types/{usage_summary_order.py → customer_by_external_id.py} +3 -5
  39. paid/types/{usage_summary_order_line.py → customer_by_id.py} +3 -5
  40. paid/types/customer_creation_state.py +5 -0
  41. paid/types/customer_list_response.py +22 -0
  42. paid/types/empty_response.py +17 -0
  43. paid/types/{error.py → error_response.py} +4 -7
  44. paid/types/invoice.py +33 -51
  45. paid/types/invoice_line.py +42 -0
  46. paid/types/invoice_line_payment_status.py +7 -0
  47. paid/types/invoice_lines_response.py +22 -0
  48. paid/types/invoice_list_response.py +22 -0
  49. paid/types/invoice_payment_status.py +5 -0
  50. paid/types/invoice_source.py +5 -0
  51. paid/types/invoice_status.py +3 -1
  52. paid/types/invoice_tax_status.py +7 -0
  53. paid/types/order.py +30 -29
  54. paid/types/order_creation_state.py +5 -0
  55. paid/types/order_line.py +6 -24
  56. paid/types/order_lines_response.py +22 -0
  57. paid/types/order_list_response.py +22 -0
  58. paid/types/pagination.py +24 -0
  59. paid/types/product.py +4 -29
  60. paid/types/{tier.py → product_by_external_id.py} +5 -4
  61. paid/types/{cost_amount.py → product_by_id.py} +5 -12
  62. paid/types/product_list_response.py +22 -0
  63. paid/types/signal.py +8 -34
  64. paid/types/{agent_update.py → update_contact_request.py} +10 -9
  65. paid/types/update_customer_request.py +38 -0
  66. paid/types/{product_update.py → update_product_request.py} +2 -12
  67. {paid_python-1.0.0a0.dist-info → paid_python-1.0.0a2.dist-info}/METADATA +23 -8
  68. paid_python-1.0.0a2.dist-info/RECORD +110 -0
  69. paid/agents/client.py +0 -880
  70. paid/agents/raw_client.py +0 -785
  71. paid/customers/types/__init__.py +0 -8
  72. paid/customers/types/customers_check_entitlement_request_view.py +0 -5
  73. paid/customers/types/customers_check_entitlement_response.py +0 -22
  74. paid/orders/lines/client.py +0 -144
  75. paid/orders/lines/raw_client.py +0 -129
  76. paid/plans/__init__.py +0 -4
  77. paid/plans/client.py +0 -403
  78. paid/products/types/__init__.py +0 -7
  79. paid/products/types/product_create_type.py +0 -5
  80. paid/traces/__init__.py +0 -4
  81. paid/traces/client.py +0 -218
  82. paid/traces/raw_client.py +0 -226
  83. paid/types/agent.py +0 -31
  84. paid/types/agent_price_point.py +0 -27
  85. paid/types/agent_price_point_tiers.py +0 -23
  86. paid/types/api_error.py +0 -29
  87. paid/types/billing_frequency.py +0 -5
  88. paid/types/cancel_renewal_response.py +0 -49
  89. paid/types/charge_type.py +0 -5
  90. paid/types/contact_create_for_customer.py +0 -37
  91. paid/types/cost_trace.py +0 -55
  92. paid/types/cost_traces_response.py +0 -26
  93. paid/types/creation_source.py +0 -5
  94. paid/types/creation_state.py +0 -5
  95. paid/types/customer_update.py +0 -40
  96. paid/types/entitlement_usage.py +0 -48
  97. paid/types/order_line_attribute.py +0 -27
  98. paid/types/order_line_attribute_create_one.py +0 -5
  99. paid/types/order_line_attribute_pricing.py +0 -33
  100. paid/types/order_line_create.py +0 -72
  101. paid/types/pagination_meta.py +0 -84
  102. paid/types/payment_method.py +0 -58
  103. paid/types/payment_method_card.py +0 -49
  104. paid/types/payment_method_type.py +0 -5
  105. paid/types/payment_method_us_bank_account.py +0 -36
  106. paid/types/payment_method_us_bank_account_account_type.py +0 -5
  107. paid/types/plan.py +0 -81
  108. paid/types/plan_group.py +0 -60
  109. paid/types/plan_plan_products_item.py +0 -41
  110. paid/types/plan_plan_products_item_plan_product_attribute_item.py +0 -34
  111. paid/types/plan_with_features.py +0 -69
  112. paid/types/plan_with_features_features_item.py +0 -34
  113. paid/types/price_point.py +0 -25
  114. paid/types/pricing.py +0 -31
  115. paid/types/pricing_model_type.py +0 -7
  116. paid/types/product_type.py +0 -5
  117. paid/types/product_update_type.py +0 -5
  118. paid/types/proration_attribute_update.py +0 -44
  119. paid/types/proration_detail.py +0 -49
  120. paid/types/proration_upgrade_response.py +0 -73
  121. paid/types/salutation.py +0 -5
  122. paid/types/signal_v_2.py +0 -56
  123. paid/types/tax_exempt_status.py +0 -5
  124. paid/types/trace.py +0 -69
  125. paid/types/usage_pagination_meta.py +0 -43
  126. paid/types/usage_summaries_response.py +0 -26
  127. paid/types/usage_summary.py +0 -121
  128. paid/usage/__init__.py +0 -7
  129. paid/usage/client.py +0 -321
  130. paid/usage/raw_client.py +0 -387
  131. paid/usage/types/__init__.py +0 -7
  132. paid/usage/types/usage_check_usage_response.py +0 -53
  133. paid_python-1.0.0a0.dist-info/RECORD +0 -152
  134. /paid/{agents → invoices}/__init__.py +0 -0
  135. /paid/{orders/lines → signals}/__init__.py +0 -0
  136. {paid_python-1.0.0a0.dist-info → paid_python-1.0.0a2.dist-info}/LICENSE +0 -0
  137. {paid_python-1.0.0a0.dist-info → paid_python-1.0.0a2.dist-info}/WHEEL +0 -0
@@ -1,78 +1,103 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- import datetime as dt
4
3
  import typing
5
4
  from json.decoder import JSONDecodeError
6
5
 
7
6
  from ..core.api_error import ApiError
8
7
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
- from ..core.datetime_utils import serialize_datetime
10
8
  from ..core.http_response import AsyncHttpResponse, HttpResponse
11
9
  from ..core.jsonable_encoder import jsonable_encoder
12
10
  from ..core.pydantic_utilities import parse_obj_as
13
11
  from ..core.request_options import RequestOptions
14
12
  from ..errors.bad_request_error import BadRequestError
15
13
  from ..errors.forbidden_error import ForbiddenError
14
+ from ..errors.internal_server_error import InternalServerError
16
15
  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.plan_with_features import PlanWithFeatures
21
- from ..types.usage_summaries_response import UsageSummariesResponse
16
+ from ..types.error_response import ErrorResponse
17
+ from ..types.invoice import Invoice
18
+ from ..types.invoice_lines_response import InvoiceLinesResponse
19
+ from ..types.invoice_list_response import InvoiceListResponse
22
20
 
21
+ # this is used as the default value for optional parameters
22
+ OMIT = typing.cast(typing.Any, ...)
23
23
 
24
- class RawPlansClient:
24
+
25
+ class RawInvoicesClient:
25
26
  def __init__(self, *, client_wrapper: SyncClientWrapper):
26
27
  self._client_wrapper = client_wrapper
27
28
 
28
- def get_by_id(self, plan_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[Plan]:
29
+ def list_invoices(
30
+ self,
31
+ *,
32
+ limit: typing.Optional[int] = None,
33
+ offset: typing.Optional[int] = None,
34
+ request_options: typing.Optional[RequestOptions] = None,
35
+ ) -> HttpResponse[InvoiceListResponse]:
29
36
  """
37
+ Get a list of invoices for the organization
38
+
30
39
  Parameters
31
40
  ----------
32
- plan_id : str
33
- The ID of the plan
41
+ limit : typing.Optional[int]
42
+
43
+ offset : typing.Optional[int]
34
44
 
35
45
  request_options : typing.Optional[RequestOptions]
36
46
  Request-specific configuration.
37
47
 
38
48
  Returns
39
49
  -------
40
- HttpResponse[Plan]
41
- Success response
50
+ HttpResponse[InvoiceListResponse]
51
+ 200
42
52
  """
43
53
  _response = self._client_wrapper.httpx_client.request(
44
- f"plans/{jsonable_encoder(plan_id)}",
54
+ "invoices/",
45
55
  method="GET",
56
+ params={
57
+ "limit": limit,
58
+ "offset": offset,
59
+ },
46
60
  request_options=request_options,
47
61
  )
48
62
  try:
49
63
  if 200 <= _response.status_code < 300:
50
64
  _data = typing.cast(
51
- Plan,
65
+ InvoiceListResponse,
52
66
  parse_obj_as(
53
- type_=Plan, # type: ignore
67
+ type_=InvoiceListResponse, # type: ignore
54
68
  object_=_response.json(),
55
69
  ),
56
70
  )
57
71
  return HttpResponse(response=_response, data=_data)
72
+ if _response.status_code == 400:
73
+ raise BadRequestError(
74
+ headers=dict(_response.headers),
75
+ body=typing.cast(
76
+ ErrorResponse,
77
+ parse_obj_as(
78
+ type_=ErrorResponse, # type: ignore
79
+ object_=_response.json(),
80
+ ),
81
+ ),
82
+ )
58
83
  if _response.status_code == 403:
59
84
  raise ForbiddenError(
60
85
  headers=dict(_response.headers),
61
86
  body=typing.cast(
62
- Error,
87
+ ErrorResponse,
63
88
  parse_obj_as(
64
- type_=Error, # type: ignore
89
+ type_=ErrorResponse, # type: ignore
65
90
  object_=_response.json(),
66
91
  ),
67
92
  ),
68
93
  )
69
- if _response.status_code == 404:
70
- raise NotFoundError(
94
+ if _response.status_code == 500:
95
+ raise InternalServerError(
71
96
  headers=dict(_response.headers),
72
97
  body=typing.cast(
73
- Error,
98
+ ErrorResponse,
74
99
  parse_obj_as(
75
- type_=Error, # type: ignore
100
+ type_=ErrorResponse, # type: ignore
76
101
  object_=_response.json(),
77
102
  ),
78
103
  ),
@@ -82,97 +107,68 @@ class RawPlansClient:
82
107
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
83
108
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
84
109
 
85
- def get_usage(
86
- self,
87
- plan_id: str,
88
- *,
89
- external_id: str,
90
- limit: typing.Optional[int] = None,
91
- offset: typing.Optional[int] = None,
92
- start_time: typing.Optional[dt.datetime] = None,
93
- end_time: typing.Optional[dt.datetime] = None,
94
- request_options: typing.Optional[RequestOptions] = None,
95
- ) -> HttpResponse[UsageSummariesResponse]:
110
+ def get_invoice_by_id(
111
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
112
+ ) -> HttpResponse[Invoice]:
96
113
  """
114
+ Get an invoice by ID
115
+
97
116
  Parameters
98
117
  ----------
99
- plan_id : str
100
- The ID of the plan
101
-
102
- external_id : str
103
- The external ID of the customer
104
-
105
- limit : typing.Optional[int]
106
- Maximum number of usage summaries to return (1-1000)
107
-
108
- offset : typing.Optional[int]
109
- Number of usage summaries to skip for pagination
110
-
111
- start_time : typing.Optional[dt.datetime]
112
- Filter usage summaries starting from this time (ISO 8601 format). Returns summaries that overlap with the time range.
113
-
114
- end_time : typing.Optional[dt.datetime]
115
- Filter usage summaries up to this time (ISO 8601 format). Returns summaries that overlap with the time range.
118
+ id : str
116
119
 
117
120
  request_options : typing.Optional[RequestOptions]
118
121
  Request-specific configuration.
119
122
 
120
123
  Returns
121
124
  -------
122
- HttpResponse[UsageSummariesResponse]
123
- Success response
125
+ HttpResponse[Invoice]
126
+ 200
124
127
  """
125
128
  _response = self._client_wrapper.httpx_client.request(
126
- f"plans/{jsonable_encoder(plan_id)}/usage",
129
+ f"invoices/{jsonable_encoder(id)}",
127
130
  method="GET",
128
- params={
129
- "externalId": external_id,
130
- "limit": limit,
131
- "offset": offset,
132
- "startTime": serialize_datetime(start_time) if start_time is not None else None,
133
- "endTime": serialize_datetime(end_time) if end_time is not None else None,
134
- },
135
131
  request_options=request_options,
136
132
  )
137
133
  try:
138
134
  if 200 <= _response.status_code < 300:
139
135
  _data = typing.cast(
140
- UsageSummariesResponse,
136
+ Invoice,
141
137
  parse_obj_as(
142
- type_=UsageSummariesResponse, # type: ignore
138
+ type_=Invoice, # type: ignore
143
139
  object_=_response.json(),
144
140
  ),
145
141
  )
146
142
  return HttpResponse(response=_response, data=_data)
147
- if _response.status_code == 400:
148
- raise BadRequestError(
143
+ if _response.status_code == 403:
144
+ raise ForbiddenError(
149
145
  headers=dict(_response.headers),
150
146
  body=typing.cast(
151
- Error,
147
+ ErrorResponse,
152
148
  parse_obj_as(
153
- type_=Error, # type: ignore
149
+ type_=ErrorResponse, # type: ignore
154
150
  object_=_response.json(),
155
151
  ),
156
152
  ),
157
153
  )
158
- if _response.status_code == 403:
159
- raise ForbiddenError(
154
+ if _response.status_code == 404:
155
+ raise NotFoundError(
160
156
  headers=dict(_response.headers),
161
157
  body=typing.cast(
162
- Error,
158
+ ErrorResponse,
163
159
  parse_obj_as(
164
- type_=Error, # type: ignore
160
+ type_=ErrorResponse, # type: ignore
165
161
  object_=_response.json(),
166
162
  ),
167
163
  ),
168
164
  )
169
- if _response.status_code == 404:
170
- raise NotFoundError(
165
+ if _response.status_code == 500:
166
+ raise InternalServerError(
171
167
  headers=dict(_response.headers),
172
168
  body=typing.cast(
173
- Error,
169
+ ErrorResponse,
174
170
  parse_obj_as(
175
- type_=Error, # type: ignore
171
+ type_=ErrorResponse, # type: ignore
176
172
  object_=_response.json(),
177
173
  ),
178
174
  ),
@@ -182,45 +178,70 @@ class RawPlansClient:
182
178
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
183
179
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
184
180
 
185
- def get_group_by_id(
186
- self, plan_group_id: str, *, request_options: typing.Optional[RequestOptions] = None
187
- ) -> HttpResponse[PlanGroup]:
181
+ def update_invoice_by_id(
182
+ self,
183
+ id: str,
184
+ *,
185
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
186
+ request_options: typing.Optional[RequestOptions] = None,
187
+ ) -> HttpResponse[Invoice]:
188
188
  """
189
+ Update an invoice by ID
190
+
189
191
  Parameters
190
192
  ----------
191
- plan_group_id : str
192
- The ID of the plan group
193
+ id : str
194
+
195
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
193
196
 
194
197
  request_options : typing.Optional[RequestOptions]
195
198
  Request-specific configuration.
196
199
 
197
200
  Returns
198
201
  -------
199
- HttpResponse[PlanGroup]
200
- Success response
202
+ HttpResponse[Invoice]
203
+ 200
201
204
  """
202
205
  _response = self._client_wrapper.httpx_client.request(
203
- f"plans/planGroup/{jsonable_encoder(plan_group_id)}",
204
- method="GET",
206
+ f"invoices/{jsonable_encoder(id)}",
207
+ method="PUT",
208
+ json={
209
+ "metadata": metadata,
210
+ },
211
+ headers={
212
+ "content-type": "application/json",
213
+ },
205
214
  request_options=request_options,
215
+ omit=OMIT,
206
216
  )
207
217
  try:
208
218
  if 200 <= _response.status_code < 300:
209
219
  _data = typing.cast(
210
- PlanGroup,
220
+ Invoice,
211
221
  parse_obj_as(
212
- type_=PlanGroup, # type: ignore
222
+ type_=Invoice, # type: ignore
213
223
  object_=_response.json(),
214
224
  ),
215
225
  )
216
226
  return HttpResponse(response=_response, data=_data)
227
+ if _response.status_code == 400:
228
+ raise BadRequestError(
229
+ headers=dict(_response.headers),
230
+ body=typing.cast(
231
+ ErrorResponse,
232
+ parse_obj_as(
233
+ type_=ErrorResponse, # type: ignore
234
+ object_=_response.json(),
235
+ ),
236
+ ),
237
+ )
217
238
  if _response.status_code == 403:
218
239
  raise ForbiddenError(
219
240
  headers=dict(_response.headers),
220
241
  body=typing.cast(
221
- Error,
242
+ ErrorResponse,
222
243
  parse_obj_as(
223
- type_=Error, # type: ignore
244
+ type_=ErrorResponse, # type: ignore
224
245
  object_=_response.json(),
225
246
  ),
226
247
  ),
@@ -229,9 +250,20 @@ class RawPlansClient:
229
250
  raise NotFoundError(
230
251
  headers=dict(_response.headers),
231
252
  body=typing.cast(
232
- Error,
253
+ ErrorResponse,
254
+ parse_obj_as(
255
+ type_=ErrorResponse, # type: ignore
256
+ object_=_response.json(),
257
+ ),
258
+ ),
259
+ )
260
+ if _response.status_code == 500:
261
+ raise InternalServerError(
262
+ headers=dict(_response.headers),
263
+ body=typing.cast(
264
+ ErrorResponse,
233
265
  parse_obj_as(
234
- type_=Error, # type: ignore
266
+ type_=ErrorResponse, # type: ignore
235
267
  object_=_response.json(),
236
268
  ),
237
269
  ),
@@ -241,34 +273,48 @@ class RawPlansClient:
241
273
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
242
274
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
243
275
 
244
- def get_group_plans(
245
- self, plan_group_id: str, *, request_options: typing.Optional[RequestOptions] = None
246
- ) -> HttpResponse[typing.List[PlanWithFeatures]]:
276
+ def get_invoice_lines(
277
+ self,
278
+ id: str,
279
+ *,
280
+ limit: typing.Optional[int] = None,
281
+ offset: typing.Optional[int] = None,
282
+ request_options: typing.Optional[RequestOptions] = None,
283
+ ) -> HttpResponse[InvoiceLinesResponse]:
247
284
  """
285
+ Get the invoice lines for an invoice by ID
286
+
248
287
  Parameters
249
288
  ----------
250
- plan_group_id : str
251
- The ID of the plan group
289
+ id : str
290
+
291
+ limit : typing.Optional[int]
292
+
293
+ offset : typing.Optional[int]
252
294
 
253
295
  request_options : typing.Optional[RequestOptions]
254
296
  Request-specific configuration.
255
297
 
256
298
  Returns
257
299
  -------
258
- HttpResponse[typing.List[PlanWithFeatures]]
259
- Success response
300
+ HttpResponse[InvoiceLinesResponse]
301
+ 200
260
302
  """
261
303
  _response = self._client_wrapper.httpx_client.request(
262
- f"plans/planGroup/{jsonable_encoder(plan_group_id)}/plans",
304
+ f"invoices/{jsonable_encoder(id)}/lines",
263
305
  method="GET",
306
+ params={
307
+ "limit": limit,
308
+ "offset": offset,
309
+ },
264
310
  request_options=request_options,
265
311
  )
266
312
  try:
267
313
  if 200 <= _response.status_code < 300:
268
314
  _data = typing.cast(
269
- typing.List[PlanWithFeatures],
315
+ InvoiceLinesResponse,
270
316
  parse_obj_as(
271
- type_=typing.List[PlanWithFeatures], # type: ignore
317
+ type_=InvoiceLinesResponse, # type: ignore
272
318
  object_=_response.json(),
273
319
  ),
274
320
  )
@@ -277,9 +323,9 @@ class RawPlansClient:
277
323
  raise ForbiddenError(
278
324
  headers=dict(_response.headers),
279
325
  body=typing.cast(
280
- Error,
326
+ ErrorResponse,
281
327
  parse_obj_as(
282
- type_=Error, # type: ignore
328
+ type_=ErrorResponse, # type: ignore
283
329
  object_=_response.json(),
284
330
  ),
285
331
  ),
@@ -288,9 +334,20 @@ class RawPlansClient:
288
334
  raise NotFoundError(
289
335
  headers=dict(_response.headers),
290
336
  body=typing.cast(
291
- Error,
337
+ ErrorResponse,
338
+ parse_obj_as(
339
+ type_=ErrorResponse, # type: ignore
340
+ object_=_response.json(),
341
+ ),
342
+ ),
343
+ )
344
+ if _response.status_code == 500:
345
+ raise InternalServerError(
346
+ headers=dict(_response.headers),
347
+ body=typing.cast(
348
+ ErrorResponse,
292
349
  parse_obj_as(
293
- type_=Error, # type: ignore
350
+ type_=ErrorResponse, # type: ignore
294
351
  object_=_response.json(),
295
352
  ),
296
353
  ),
@@ -301,60 +358,82 @@ class RawPlansClient:
301
358
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
302
359
 
303
360
 
304
- class AsyncRawPlansClient:
361
+ class AsyncRawInvoicesClient:
305
362
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
306
363
  self._client_wrapper = client_wrapper
307
364
 
308
- async def get_by_id(
309
- self, plan_id: str, *, request_options: typing.Optional[RequestOptions] = None
310
- ) -> AsyncHttpResponse[Plan]:
365
+ async def list_invoices(
366
+ self,
367
+ *,
368
+ limit: typing.Optional[int] = None,
369
+ offset: typing.Optional[int] = None,
370
+ request_options: typing.Optional[RequestOptions] = None,
371
+ ) -> AsyncHttpResponse[InvoiceListResponse]:
311
372
  """
373
+ Get a list of invoices for the organization
374
+
312
375
  Parameters
313
376
  ----------
314
- plan_id : str
315
- The ID of the plan
377
+ limit : typing.Optional[int]
378
+
379
+ offset : typing.Optional[int]
316
380
 
317
381
  request_options : typing.Optional[RequestOptions]
318
382
  Request-specific configuration.
319
383
 
320
384
  Returns
321
385
  -------
322
- AsyncHttpResponse[Plan]
323
- Success response
386
+ AsyncHttpResponse[InvoiceListResponse]
387
+ 200
324
388
  """
325
389
  _response = await self._client_wrapper.httpx_client.request(
326
- f"plans/{jsonable_encoder(plan_id)}",
390
+ "invoices/",
327
391
  method="GET",
392
+ params={
393
+ "limit": limit,
394
+ "offset": offset,
395
+ },
328
396
  request_options=request_options,
329
397
  )
330
398
  try:
331
399
  if 200 <= _response.status_code < 300:
332
400
  _data = typing.cast(
333
- Plan,
401
+ InvoiceListResponse,
334
402
  parse_obj_as(
335
- type_=Plan, # type: ignore
403
+ type_=InvoiceListResponse, # type: ignore
336
404
  object_=_response.json(),
337
405
  ),
338
406
  )
339
407
  return AsyncHttpResponse(response=_response, data=_data)
408
+ if _response.status_code == 400:
409
+ raise BadRequestError(
410
+ headers=dict(_response.headers),
411
+ body=typing.cast(
412
+ ErrorResponse,
413
+ parse_obj_as(
414
+ type_=ErrorResponse, # type: ignore
415
+ object_=_response.json(),
416
+ ),
417
+ ),
418
+ )
340
419
  if _response.status_code == 403:
341
420
  raise ForbiddenError(
342
421
  headers=dict(_response.headers),
343
422
  body=typing.cast(
344
- Error,
423
+ ErrorResponse,
345
424
  parse_obj_as(
346
- type_=Error, # type: ignore
425
+ type_=ErrorResponse, # type: ignore
347
426
  object_=_response.json(),
348
427
  ),
349
428
  ),
350
429
  )
351
- if _response.status_code == 404:
352
- raise NotFoundError(
430
+ if _response.status_code == 500:
431
+ raise InternalServerError(
353
432
  headers=dict(_response.headers),
354
433
  body=typing.cast(
355
- Error,
434
+ ErrorResponse,
356
435
  parse_obj_as(
357
- type_=Error, # type: ignore
436
+ type_=ErrorResponse, # type: ignore
358
437
  object_=_response.json(),
359
438
  ),
360
439
  ),
@@ -364,97 +443,68 @@ class AsyncRawPlansClient:
364
443
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
365
444
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
366
445
 
367
- async def get_usage(
368
- self,
369
- plan_id: str,
370
- *,
371
- external_id: str,
372
- limit: typing.Optional[int] = None,
373
- offset: typing.Optional[int] = None,
374
- start_time: typing.Optional[dt.datetime] = None,
375
- end_time: typing.Optional[dt.datetime] = None,
376
- request_options: typing.Optional[RequestOptions] = None,
377
- ) -> AsyncHttpResponse[UsageSummariesResponse]:
446
+ async def get_invoice_by_id(
447
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
448
+ ) -> AsyncHttpResponse[Invoice]:
378
449
  """
450
+ Get an invoice by ID
451
+
379
452
  Parameters
380
453
  ----------
381
- plan_id : str
382
- The ID of the plan
383
-
384
- external_id : str
385
- The external ID of the customer
386
-
387
- limit : typing.Optional[int]
388
- Maximum number of usage summaries to return (1-1000)
389
-
390
- offset : typing.Optional[int]
391
- Number of usage summaries to skip for pagination
392
-
393
- start_time : typing.Optional[dt.datetime]
394
- Filter usage summaries starting from this time (ISO 8601 format). Returns summaries that overlap with the time range.
395
-
396
- end_time : typing.Optional[dt.datetime]
397
- Filter usage summaries up to this time (ISO 8601 format). Returns summaries that overlap with the time range.
454
+ id : str
398
455
 
399
456
  request_options : typing.Optional[RequestOptions]
400
457
  Request-specific configuration.
401
458
 
402
459
  Returns
403
460
  -------
404
- AsyncHttpResponse[UsageSummariesResponse]
405
- Success response
461
+ AsyncHttpResponse[Invoice]
462
+ 200
406
463
  """
407
464
  _response = await self._client_wrapper.httpx_client.request(
408
- f"plans/{jsonable_encoder(plan_id)}/usage",
465
+ f"invoices/{jsonable_encoder(id)}",
409
466
  method="GET",
410
- params={
411
- "externalId": external_id,
412
- "limit": limit,
413
- "offset": offset,
414
- "startTime": serialize_datetime(start_time) if start_time is not None else None,
415
- "endTime": serialize_datetime(end_time) if end_time is not None else None,
416
- },
417
467
  request_options=request_options,
418
468
  )
419
469
  try:
420
470
  if 200 <= _response.status_code < 300:
421
471
  _data = typing.cast(
422
- UsageSummariesResponse,
472
+ Invoice,
423
473
  parse_obj_as(
424
- type_=UsageSummariesResponse, # type: ignore
474
+ type_=Invoice, # type: ignore
425
475
  object_=_response.json(),
426
476
  ),
427
477
  )
428
478
  return AsyncHttpResponse(response=_response, data=_data)
429
- if _response.status_code == 400:
430
- raise BadRequestError(
479
+ if _response.status_code == 403:
480
+ raise ForbiddenError(
431
481
  headers=dict(_response.headers),
432
482
  body=typing.cast(
433
- Error,
483
+ ErrorResponse,
434
484
  parse_obj_as(
435
- type_=Error, # type: ignore
485
+ type_=ErrorResponse, # type: ignore
436
486
  object_=_response.json(),
437
487
  ),
438
488
  ),
439
489
  )
440
- if _response.status_code == 403:
441
- raise ForbiddenError(
490
+ if _response.status_code == 404:
491
+ raise NotFoundError(
442
492
  headers=dict(_response.headers),
443
493
  body=typing.cast(
444
- Error,
494
+ ErrorResponse,
445
495
  parse_obj_as(
446
- type_=Error, # type: ignore
496
+ type_=ErrorResponse, # type: ignore
447
497
  object_=_response.json(),
448
498
  ),
449
499
  ),
450
500
  )
451
- if _response.status_code == 404:
452
- raise NotFoundError(
501
+ if _response.status_code == 500:
502
+ raise InternalServerError(
453
503
  headers=dict(_response.headers),
454
504
  body=typing.cast(
455
- Error,
505
+ ErrorResponse,
456
506
  parse_obj_as(
457
- type_=Error, # type: ignore
507
+ type_=ErrorResponse, # type: ignore
458
508
  object_=_response.json(),
459
509
  ),
460
510
  ),
@@ -464,45 +514,70 @@ class AsyncRawPlansClient:
464
514
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
465
515
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
466
516
 
467
- async def get_group_by_id(
468
- self, plan_group_id: str, *, request_options: typing.Optional[RequestOptions] = None
469
- ) -> AsyncHttpResponse[PlanGroup]:
517
+ async def update_invoice_by_id(
518
+ self,
519
+ id: str,
520
+ *,
521
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
522
+ request_options: typing.Optional[RequestOptions] = None,
523
+ ) -> AsyncHttpResponse[Invoice]:
470
524
  """
525
+ Update an invoice by ID
526
+
471
527
  Parameters
472
528
  ----------
473
- plan_group_id : str
474
- The ID of the plan group
529
+ id : str
530
+
531
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
475
532
 
476
533
  request_options : typing.Optional[RequestOptions]
477
534
  Request-specific configuration.
478
535
 
479
536
  Returns
480
537
  -------
481
- AsyncHttpResponse[PlanGroup]
482
- Success response
538
+ AsyncHttpResponse[Invoice]
539
+ 200
483
540
  """
484
541
  _response = await self._client_wrapper.httpx_client.request(
485
- f"plans/planGroup/{jsonable_encoder(plan_group_id)}",
486
- method="GET",
542
+ f"invoices/{jsonable_encoder(id)}",
543
+ method="PUT",
544
+ json={
545
+ "metadata": metadata,
546
+ },
547
+ headers={
548
+ "content-type": "application/json",
549
+ },
487
550
  request_options=request_options,
551
+ omit=OMIT,
488
552
  )
489
553
  try:
490
554
  if 200 <= _response.status_code < 300:
491
555
  _data = typing.cast(
492
- PlanGroup,
556
+ Invoice,
493
557
  parse_obj_as(
494
- type_=PlanGroup, # type: ignore
558
+ type_=Invoice, # type: ignore
495
559
  object_=_response.json(),
496
560
  ),
497
561
  )
498
562
  return AsyncHttpResponse(response=_response, data=_data)
563
+ if _response.status_code == 400:
564
+ raise BadRequestError(
565
+ headers=dict(_response.headers),
566
+ body=typing.cast(
567
+ ErrorResponse,
568
+ parse_obj_as(
569
+ type_=ErrorResponse, # type: ignore
570
+ object_=_response.json(),
571
+ ),
572
+ ),
573
+ )
499
574
  if _response.status_code == 403:
500
575
  raise ForbiddenError(
501
576
  headers=dict(_response.headers),
502
577
  body=typing.cast(
503
- Error,
578
+ ErrorResponse,
504
579
  parse_obj_as(
505
- type_=Error, # type: ignore
580
+ type_=ErrorResponse, # type: ignore
506
581
  object_=_response.json(),
507
582
  ),
508
583
  ),
@@ -511,9 +586,20 @@ class AsyncRawPlansClient:
511
586
  raise NotFoundError(
512
587
  headers=dict(_response.headers),
513
588
  body=typing.cast(
514
- Error,
589
+ ErrorResponse,
590
+ parse_obj_as(
591
+ type_=ErrorResponse, # type: ignore
592
+ object_=_response.json(),
593
+ ),
594
+ ),
595
+ )
596
+ if _response.status_code == 500:
597
+ raise InternalServerError(
598
+ headers=dict(_response.headers),
599
+ body=typing.cast(
600
+ ErrorResponse,
515
601
  parse_obj_as(
516
- type_=Error, # type: ignore
602
+ type_=ErrorResponse, # type: ignore
517
603
  object_=_response.json(),
518
604
  ),
519
605
  ),
@@ -523,34 +609,48 @@ class AsyncRawPlansClient:
523
609
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
524
610
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
525
611
 
526
- async def get_group_plans(
527
- self, plan_group_id: str, *, request_options: typing.Optional[RequestOptions] = None
528
- ) -> AsyncHttpResponse[typing.List[PlanWithFeatures]]:
612
+ async def get_invoice_lines(
613
+ self,
614
+ id: str,
615
+ *,
616
+ limit: typing.Optional[int] = None,
617
+ offset: typing.Optional[int] = None,
618
+ request_options: typing.Optional[RequestOptions] = None,
619
+ ) -> AsyncHttpResponse[InvoiceLinesResponse]:
529
620
  """
621
+ Get the invoice lines for an invoice by ID
622
+
530
623
  Parameters
531
624
  ----------
532
- plan_group_id : str
533
- The ID of the plan group
625
+ id : str
626
+
627
+ limit : typing.Optional[int]
628
+
629
+ offset : typing.Optional[int]
534
630
 
535
631
  request_options : typing.Optional[RequestOptions]
536
632
  Request-specific configuration.
537
633
 
538
634
  Returns
539
635
  -------
540
- AsyncHttpResponse[typing.List[PlanWithFeatures]]
541
- Success response
636
+ AsyncHttpResponse[InvoiceLinesResponse]
637
+ 200
542
638
  """
543
639
  _response = await self._client_wrapper.httpx_client.request(
544
- f"plans/planGroup/{jsonable_encoder(plan_group_id)}/plans",
640
+ f"invoices/{jsonable_encoder(id)}/lines",
545
641
  method="GET",
642
+ params={
643
+ "limit": limit,
644
+ "offset": offset,
645
+ },
546
646
  request_options=request_options,
547
647
  )
548
648
  try:
549
649
  if 200 <= _response.status_code < 300:
550
650
  _data = typing.cast(
551
- typing.List[PlanWithFeatures],
651
+ InvoiceLinesResponse,
552
652
  parse_obj_as(
553
- type_=typing.List[PlanWithFeatures], # type: ignore
653
+ type_=InvoiceLinesResponse, # type: ignore
554
654
  object_=_response.json(),
555
655
  ),
556
656
  )
@@ -559,9 +659,9 @@ class AsyncRawPlansClient:
559
659
  raise ForbiddenError(
560
660
  headers=dict(_response.headers),
561
661
  body=typing.cast(
562
- Error,
662
+ ErrorResponse,
563
663
  parse_obj_as(
564
- type_=Error, # type: ignore
664
+ type_=ErrorResponse, # type: ignore
565
665
  object_=_response.json(),
566
666
  ),
567
667
  ),
@@ -570,9 +670,20 @@ class AsyncRawPlansClient:
570
670
  raise NotFoundError(
571
671
  headers=dict(_response.headers),
572
672
  body=typing.cast(
573
- Error,
673
+ ErrorResponse,
674
+ parse_obj_as(
675
+ type_=ErrorResponse, # type: ignore
676
+ object_=_response.json(),
677
+ ),
678
+ ),
679
+ )
680
+ if _response.status_code == 500:
681
+ raise InternalServerError(
682
+ headers=dict(_response.headers),
683
+ body=typing.cast(
684
+ ErrorResponse,
574
685
  parse_obj_as(
575
- type_=Error, # type: ignore
686
+ type_=ErrorResponse, # type: ignore
576
687
  object_=_response.json(),
577
688
  ),
578
689
  ),