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
paid/orders/raw_client.py CHANGED
@@ -10,17 +10,16 @@ from ..core.http_response import AsyncHttpResponse, HttpResponse
10
10
  from ..core.jsonable_encoder import jsonable_encoder
11
11
  from ..core.pydantic_utilities import parse_obj_as
12
12
  from ..core.request_options import RequestOptions
13
- from ..core.serialization import convert_and_respect_annotation_metadata
14
13
  from ..errors.bad_request_error import BadRequestError
15
14
  from ..errors.forbidden_error import ForbiddenError
15
+ from ..errors.internal_server_error import InternalServerError
16
16
  from ..errors.not_found_error import NotFoundError
17
- from ..types.cancel_renewal_response import CancelRenewalResponse
18
- from ..types.error import Error
19
- from ..types.invoice import Invoice
17
+ from ..types.empty_response import EmptyResponse
18
+ from ..types.error_response import ErrorResponse
20
19
  from ..types.order import Order
21
- from ..types.order_line_create import OrderLineCreate
22
- from ..types.proration_attribute_update import ProrationAttributeUpdate
23
- from ..types.proration_upgrade_response import ProrationUpgradeResponse
20
+ from ..types.order_creation_state import OrderCreationState
21
+ from ..types.order_lines_response import OrderLinesResponse
22
+ from ..types.order_list_response import OrderListResponse
24
23
 
25
24
  # this is used as the default value for optional parameters
26
25
  OMIT = typing.cast(typing.Any, ...)
@@ -30,76 +29,132 @@ class RawOrdersClient:
30
29
  def __init__(self, *, client_wrapper: SyncClientWrapper):
31
30
  self._client_wrapper = client_wrapper
32
31
 
33
- def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[typing.List[Order]]:
32
+ def list_orders(
33
+ self,
34
+ *,
35
+ limit: typing.Optional[int] = None,
36
+ offset: typing.Optional[int] = None,
37
+ request_options: typing.Optional[RequestOptions] = None,
38
+ ) -> HttpResponse[OrderListResponse]:
34
39
  """
40
+ Get a list of orders for the organization
41
+
35
42
  Parameters
36
43
  ----------
44
+ limit : typing.Optional[int]
45
+
46
+ offset : typing.Optional[int]
47
+
37
48
  request_options : typing.Optional[RequestOptions]
38
49
  Request-specific configuration.
39
50
 
40
51
  Returns
41
52
  -------
42
- HttpResponse[typing.List[Order]]
43
- Success response
53
+ HttpResponse[OrderListResponse]
54
+ 200
44
55
  """
45
56
  _response = self._client_wrapper.httpx_client.request(
46
- "orders",
57
+ "orders/",
47
58
  method="GET",
59
+ params={
60
+ "limit": limit,
61
+ "offset": offset,
62
+ },
48
63
  request_options=request_options,
49
64
  )
50
65
  try:
51
66
  if 200 <= _response.status_code < 300:
52
67
  _data = typing.cast(
53
- typing.List[Order],
68
+ OrderListResponse,
54
69
  parse_obj_as(
55
- type_=typing.List[Order], # type: ignore
70
+ type_=OrderListResponse, # type: ignore
56
71
  object_=_response.json(),
57
72
  ),
58
73
  )
59
74
  return HttpResponse(response=_response, data=_data)
75
+ if _response.status_code == 400:
76
+ raise BadRequestError(
77
+ headers=dict(_response.headers),
78
+ body=typing.cast(
79
+ ErrorResponse,
80
+ parse_obj_as(
81
+ type_=ErrorResponse, # type: ignore
82
+ object_=_response.json(),
83
+ ),
84
+ ),
85
+ )
86
+ if _response.status_code == 403:
87
+ raise ForbiddenError(
88
+ headers=dict(_response.headers),
89
+ body=typing.cast(
90
+ ErrorResponse,
91
+ parse_obj_as(
92
+ type_=ErrorResponse, # type: ignore
93
+ object_=_response.json(),
94
+ ),
95
+ ),
96
+ )
97
+ if _response.status_code == 500:
98
+ raise InternalServerError(
99
+ headers=dict(_response.headers),
100
+ body=typing.cast(
101
+ ErrorResponse,
102
+ parse_obj_as(
103
+ type_=ErrorResponse, # type: ignore
104
+ object_=_response.json(),
105
+ ),
106
+ ),
107
+ )
60
108
  _response_json = _response.json()
61
109
  except JSONDecodeError:
62
110
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
63
111
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
64
112
 
65
- def create(
113
+ def create_order(
66
114
  self,
67
115
  *,
68
- name: str,
69
- start_date: str,
70
- currency: str,
71
- customer_id: typing.Optional[str] = OMIT,
72
- customer_external_id: typing.Optional[str] = OMIT,
73
- billing_contact_id: typing.Optional[str] = OMIT,
74
- description: typing.Optional[str] = OMIT,
75
- end_date: typing.Optional[str] = OMIT,
76
- plan_id: typing.Optional[str] = OMIT,
77
- order_lines: typing.Optional[typing.Sequence[OrderLineCreate]] = OMIT,
116
+ customer_id: str,
117
+ billing_customer_id: typing.Optional[str] = OMIT,
118
+ billing_contact_ids: typing.Optional[typing.Sequence[str]] = OMIT,
119
+ name: typing.Optional[str] = OMIT,
120
+ start_date: typing.Optional[dt.datetime] = OMIT,
121
+ end_date: typing.Optional[dt.datetime] = OMIT,
122
+ subscription_terms: typing.Optional[int] = OMIT,
123
+ creation_state: typing.Optional[OrderCreationState] = OMIT,
124
+ billing_anchor: typing.Optional[float] = OMIT,
125
+ payment_terms: typing.Optional[str] = OMIT,
126
+ external_id: typing.Optional[str] = OMIT,
127
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
78
128
  request_options: typing.Optional[RequestOptions] = None,
79
129
  ) -> HttpResponse[Order]:
80
130
  """
131
+ Creates a new order for the organization
132
+
81
133
  Parameters
82
134
  ----------
83
- name : str
135
+ customer_id : str
136
+
137
+ billing_customer_id : typing.Optional[str]
138
+
139
+ billing_contact_ids : typing.Optional[typing.Sequence[str]]
84
140
 
85
- start_date : str
141
+ name : typing.Optional[str]
86
142
 
87
- currency : str
143
+ start_date : typing.Optional[dt.datetime]
88
144
 
89
- customer_id : typing.Optional[str]
145
+ end_date : typing.Optional[dt.datetime]
90
146
 
91
- customer_external_id : typing.Optional[str]
147
+ subscription_terms : typing.Optional[int]
92
148
 
93
- billing_contact_id : typing.Optional[str]
149
+ creation_state : typing.Optional[OrderCreationState]
94
150
 
95
- description : typing.Optional[str]
151
+ billing_anchor : typing.Optional[float]
96
152
 
97
- end_date : typing.Optional[str]
153
+ payment_terms : typing.Optional[str]
98
154
 
99
- plan_id : typing.Optional[str]
100
- Optional plan ID to associate with this order
155
+ external_id : typing.Optional[str]
101
156
 
102
- order_lines : typing.Optional[typing.Sequence[OrderLineCreate]]
157
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
103
158
 
104
159
  request_options : typing.Optional[RequestOptions]
105
160
  Request-specific configuration.
@@ -107,24 +162,24 @@ class RawOrdersClient:
107
162
  Returns
108
163
  -------
109
164
  HttpResponse[Order]
110
- Success response
165
+ 201
111
166
  """
112
167
  _response = self._client_wrapper.httpx_client.request(
113
- "orders",
168
+ "orders/",
114
169
  method="POST",
115
170
  json={
116
171
  "customerId": customer_id,
117
- "customerExternalId": customer_external_id,
118
- "billingContactId": billing_contact_id,
172
+ "billingCustomerId": billing_customer_id,
173
+ "billingContactIds": billing_contact_ids,
119
174
  "name": name,
120
- "description": description,
121
175
  "startDate": start_date,
122
176
  "endDate": end_date,
123
- "currency": currency,
124
- "planId": plan_id,
125
- "orderLines": convert_and_respect_annotation_metadata(
126
- object_=order_lines, annotation=typing.Sequence[OrderLineCreate], direction="write"
127
- ),
177
+ "subscriptionTerms": subscription_terms,
178
+ "creationState": creation_state,
179
+ "billingAnchor": billing_anchor,
180
+ "paymentTerms": payment_terms,
181
+ "externalId": external_id,
182
+ "metadata": metadata,
128
183
  },
129
184
  headers={
130
185
  "content-type": "application/json",
@@ -142,128 +197,53 @@ class RawOrdersClient:
142
197
  ),
143
198
  )
144
199
  return HttpResponse(response=_response, data=_data)
145
- _response_json = _response.json()
146
- except JSONDecodeError:
147
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
148
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
149
-
150
- def get(self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[Order]:
151
- """
152
- Parameters
153
- ----------
154
- order_id : str
155
-
156
- request_options : typing.Optional[RequestOptions]
157
- Request-specific configuration.
158
-
159
- Returns
160
- -------
161
- HttpResponse[Order]
162
- Success response
163
- """
164
- _response = self._client_wrapper.httpx_client.request(
165
- f"orders/{jsonable_encoder(order_id)}",
166
- method="GET",
167
- request_options=request_options,
168
- )
169
- try:
170
- if 200 <= _response.status_code < 300:
171
- _data = typing.cast(
172
- Order,
173
- parse_obj_as(
174
- type_=Order, # type: ignore
175
- object_=_response.json(),
200
+ if _response.status_code == 400:
201
+ raise BadRequestError(
202
+ headers=dict(_response.headers),
203
+ body=typing.cast(
204
+ ErrorResponse,
205
+ parse_obj_as(
206
+ type_=ErrorResponse, # type: ignore
207
+ object_=_response.json(),
208
+ ),
176
209
  ),
177
210
  )
178
- return HttpResponse(response=_response, data=_data)
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 delete(self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]:
185
- """
186
- Parameters
187
- ----------
188
- order_id : str
189
-
190
- request_options : typing.Optional[RequestOptions]
191
- Request-specific configuration.
192
-
193
- Returns
194
- -------
195
- HttpResponse[None]
196
- """
197
- _response = self._client_wrapper.httpx_client.request(
198
- f"orders/{jsonable_encoder(order_id)}",
199
- method="DELETE",
200
- request_options=request_options,
201
- )
202
- try:
203
- if 200 <= _response.status_code < 300:
204
- return HttpResponse(response=_response, data=None)
205
- _response_json = _response.json()
206
- except JSONDecodeError:
207
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
208
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
209
-
210
- def activate(
211
- self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None
212
- ) -> HttpResponse[Order]:
213
- """
214
- Parameters
215
- ----------
216
- order_id : str
217
-
218
- request_options : typing.Optional[RequestOptions]
219
- Request-specific configuration.
220
-
221
- Returns
222
- -------
223
- HttpResponse[Order]
224
- Success response
225
- """
226
- _response = self._client_wrapper.httpx_client.request(
227
- f"orders/{jsonable_encoder(order_id)}/activate",
228
- method="POST",
229
- request_options=request_options,
230
- )
231
- try:
232
- if 200 <= _response.status_code < 300:
233
- _data = typing.cast(
234
- Order,
235
- parse_obj_as(
236
- type_=Order, # type: ignore
237
- object_=_response.json(),
211
+ if _response.status_code == 403:
212
+ raise ForbiddenError(
213
+ headers=dict(_response.headers),
214
+ body=typing.cast(
215
+ ErrorResponse,
216
+ parse_obj_as(
217
+ type_=ErrorResponse, # type: ignore
218
+ object_=_response.json(),
219
+ ),
220
+ ),
221
+ )
222
+ if _response.status_code == 500:
223
+ raise InternalServerError(
224
+ headers=dict(_response.headers),
225
+ body=typing.cast(
226
+ ErrorResponse,
227
+ parse_obj_as(
228
+ type_=ErrorResponse, # type: ignore
229
+ object_=_response.json(),
230
+ ),
238
231
  ),
239
232
  )
240
- return HttpResponse(response=_response, data=_data)
241
233
  _response_json = _response.json()
242
234
  except JSONDecodeError:
243
235
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
244
236
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
245
237
 
246
- def activate_and_pay(
247
- self,
248
- order_id: str,
249
- *,
250
- confirmation_token: str,
251
- return_url: str,
252
- request_options: typing.Optional[RequestOptions] = None,
238
+ def get_order_by_id(
239
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
253
240
  ) -> HttpResponse[Order]:
254
241
  """
255
- Activates the order and processes the initial payment using the provided Stripe confirmation token.
242
+ Get an order by ID
256
243
 
257
244
  Parameters
258
245
  ----------
259
- order_id : str
260
- The order ID (can be internal ID or display ID)
261
-
262
- confirmation_token : str
263
- Stripe confirmation token for the payment method
264
-
265
- return_url : str
266
- URL to redirect to after payment processing
246
+ id : str
267
247
 
268
248
  request_options : typing.Optional[RequestOptions]
269
249
  Request-specific configuration.
@@ -271,20 +251,12 @@ class RawOrdersClient:
271
251
  Returns
272
252
  -------
273
253
  HttpResponse[Order]
274
- Order activated and payment processed successfully
254
+ 200
275
255
  """
276
256
  _response = self._client_wrapper.httpx_client.request(
277
- f"orders/{jsonable_encoder(order_id)}/activate-and-pay",
278
- method="POST",
279
- json={
280
- "confirmationToken": confirmation_token,
281
- "returnUrl": return_url,
282
- },
283
- headers={
284
- "content-type": "application/json",
285
- },
257
+ f"orders/{jsonable_encoder(id)}",
258
+ method="GET",
286
259
  request_options=request_options,
287
- omit=OMIT,
288
260
  )
289
261
  try:
290
262
  if 200 <= _response.status_code < 300:
@@ -296,35 +268,35 @@ class RawOrdersClient:
296
268
  ),
297
269
  )
298
270
  return HttpResponse(response=_response, data=_data)
299
- if _response.status_code == 400:
300
- raise BadRequestError(
271
+ if _response.status_code == 403:
272
+ raise ForbiddenError(
301
273
  headers=dict(_response.headers),
302
274
  body=typing.cast(
303
- Error,
275
+ ErrorResponse,
304
276
  parse_obj_as(
305
- type_=Error, # type: ignore
277
+ type_=ErrorResponse, # type: ignore
306
278
  object_=_response.json(),
307
279
  ),
308
280
  ),
309
281
  )
310
- if _response.status_code == 403:
311
- raise ForbiddenError(
282
+ if _response.status_code == 404:
283
+ raise NotFoundError(
312
284
  headers=dict(_response.headers),
313
285
  body=typing.cast(
314
- Error,
286
+ ErrorResponse,
315
287
  parse_obj_as(
316
- type_=Error, # type: ignore
288
+ type_=ErrorResponse, # type: ignore
317
289
  object_=_response.json(),
318
290
  ),
319
291
  ),
320
292
  )
321
- if _response.status_code == 404:
322
- raise NotFoundError(
293
+ if _response.status_code == 500:
294
+ raise InternalServerError(
323
295
  headers=dict(_response.headers),
324
296
  body=typing.cast(
325
- Error,
297
+ ErrorResponse,
326
298
  parse_obj_as(
327
- type_=Error, # type: ignore
299
+ type_=ErrorResponse, # type: ignore
328
300
  object_=_response.json(),
329
301
  ),
330
302
  ),
@@ -334,42 +306,75 @@ class RawOrdersClient:
334
306
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
335
307
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
336
308
 
337
- def cancel_renewal(
309
+ def update_order_by_id(
338
310
  self,
339
- order_id: str,
311
+ id: str,
340
312
  *,
341
- order_version: int,
342
- cancel_from_date: dt.datetime,
313
+ name: typing.Optional[str] = OMIT,
314
+ start_date: typing.Optional[dt.datetime] = OMIT,
315
+ end_date: typing.Optional[dt.datetime] = OMIT,
316
+ subscription_terms: typing.Optional[int] = OMIT,
317
+ creation_state: typing.Optional[OrderCreationState] = OMIT,
318
+ billing_anchor: typing.Optional[float] = OMIT,
319
+ payment_terms: typing.Optional[str] = OMIT,
320
+ external_id: typing.Optional[str] = OMIT,
321
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
322
+ billing_customer_id: typing.Optional[str] = OMIT,
323
+ billing_contact_ids: typing.Optional[typing.Sequence[str]] = OMIT,
343
324
  request_options: typing.Optional[RequestOptions] = None,
344
- ) -> HttpResponse[CancelRenewalResponse]:
325
+ ) -> HttpResponse[Order]:
345
326
  """
346
- Schedules the cancellation of an order's renewal from a specified date. The order will remain active until the cancellation date.
327
+ Update an order by ID
347
328
 
348
329
  Parameters
349
330
  ----------
350
- order_id : str
351
- The order ID (can be internal ID or display ID)
331
+ id : str
332
+
333
+ name : typing.Optional[str]
334
+
335
+ start_date : typing.Optional[dt.datetime]
336
+
337
+ end_date : typing.Optional[dt.datetime]
338
+
339
+ subscription_terms : typing.Optional[int]
340
+
341
+ creation_state : typing.Optional[OrderCreationState]
342
+
343
+ billing_anchor : typing.Optional[float]
344
+
345
+ payment_terms : typing.Optional[str]
352
346
 
353
- order_version : int
354
- The current version of the order (for optimistic locking)
347
+ external_id : typing.Optional[str]
355
348
 
356
- cancel_from_date : dt.datetime
357
- The date from which the renewal should be cancelled (ISO 8601 format)
349
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
350
+
351
+ billing_customer_id : typing.Optional[str]
352
+
353
+ billing_contact_ids : typing.Optional[typing.Sequence[str]]
358
354
 
359
355
  request_options : typing.Optional[RequestOptions]
360
356
  Request-specific configuration.
361
357
 
362
358
  Returns
363
359
  -------
364
- HttpResponse[CancelRenewalResponse]
365
- Order renewal cancelled successfully
360
+ HttpResponse[Order]
361
+ 200
366
362
  """
367
363
  _response = self._client_wrapper.httpx_client.request(
368
- f"orders/{jsonable_encoder(order_id)}/cancel",
369
- method="POST",
364
+ f"orders/{jsonable_encoder(id)}",
365
+ method="PUT",
370
366
  json={
371
- "orderVersion": order_version,
372
- "cancelFromDate": cancel_from_date,
367
+ "name": name,
368
+ "startDate": start_date,
369
+ "endDate": end_date,
370
+ "subscriptionTerms": subscription_terms,
371
+ "creationState": creation_state,
372
+ "billingAnchor": billing_anchor,
373
+ "paymentTerms": payment_terms,
374
+ "externalId": external_id,
375
+ "metadata": metadata,
376
+ "billingCustomerId": billing_customer_id,
377
+ "billingContactIds": billing_contact_ids,
373
378
  },
374
379
  headers={
375
380
  "content-type": "application/json",
@@ -380,9 +385,9 @@ class RawOrdersClient:
380
385
  try:
381
386
  if 200 <= _response.status_code < 300:
382
387
  _data = typing.cast(
383
- CancelRenewalResponse,
388
+ Order,
384
389
  parse_obj_as(
385
- type_=CancelRenewalResponse, # type: ignore
390
+ type_=Order, # type: ignore
386
391
  object_=_response.json(),
387
392
  ),
388
393
  )
@@ -391,9 +396,9 @@ class RawOrdersClient:
391
396
  raise BadRequestError(
392
397
  headers=dict(_response.headers),
393
398
  body=typing.cast(
394
- Error,
399
+ ErrorResponse,
395
400
  parse_obj_as(
396
- type_=Error, # type: ignore
401
+ type_=ErrorResponse, # type: ignore
397
402
  object_=_response.json(),
398
403
  ),
399
404
  ),
@@ -402,9 +407,9 @@ class RawOrdersClient:
402
407
  raise ForbiddenError(
403
408
  headers=dict(_response.headers),
404
409
  body=typing.cast(
405
- Error,
410
+ ErrorResponse,
406
411
  parse_obj_as(
407
- type_=Error, # type: ignore
412
+ type_=ErrorResponse, # type: ignore
408
413
  object_=_response.json(),
409
414
  ),
410
415
  ),
@@ -413,9 +418,20 @@ class RawOrdersClient:
413
418
  raise NotFoundError(
414
419
  headers=dict(_response.headers),
415
420
  body=typing.cast(
416
- Error,
421
+ ErrorResponse,
417
422
  parse_obj_as(
418
- type_=Error, # type: ignore
423
+ type_=ErrorResponse, # type: ignore
424
+ object_=_response.json(),
425
+ ),
426
+ ),
427
+ )
428
+ if _response.status_code == 500:
429
+ raise InternalServerError(
430
+ headers=dict(_response.headers),
431
+ body=typing.cast(
432
+ ErrorResponse,
433
+ parse_obj_as(
434
+ type_=ErrorResponse, # type: ignore
419
435
  object_=_response.json(),
420
436
  ),
421
437
  ),
@@ -425,97 +441,68 @@ class RawOrdersClient:
425
441
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
426
442
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
427
443
 
428
- def schedule_plan_change(
429
- self,
430
- order_id: str,
431
- *,
432
- order_version: int,
433
- effective_date: dt.datetime,
434
- updated_order_line_attributes: typing.Sequence[ProrationAttributeUpdate],
435
- request_options: typing.Optional[RequestOptions] = None,
436
- ) -> HttpResponse[ProrationUpgradeResponse]:
444
+ def delete_order_by_id(
445
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
446
+ ) -> HttpResponse[EmptyResponse]:
437
447
  """
438
- Schedules a plan upgrade or downgrade for an order with automatic proration calculation. Credits are applied for the unused portion of the current billing period.
448
+ Delete an order by ID
439
449
 
440
450
  Parameters
441
451
  ----------
442
- order_id : str
443
- The order ID (can be internal ID or display ID)
444
-
445
- order_version : int
446
- The current version of the order (for optimistic locking)
447
-
448
- effective_date : dt.datetime
449
- The date when the plan change should take effect (ISO 8601 format)
450
-
451
- updated_order_line_attributes : typing.Sequence[ProrationAttributeUpdate]
452
- The list of order line attributes to update
452
+ id : str
453
453
 
454
454
  request_options : typing.Optional[RequestOptions]
455
455
  Request-specific configuration.
456
456
 
457
457
  Returns
458
458
  -------
459
- HttpResponse[ProrationUpgradeResponse]
460
- Plan change scheduled successfully
459
+ HttpResponse[EmptyResponse]
460
+ 200
461
461
  """
462
462
  _response = self._client_wrapper.httpx_client.request(
463
- f"orders/{jsonable_encoder(order_id)}/schedule-plan-change",
464
- method="POST",
465
- json={
466
- "orderVersion": order_version,
467
- "effectiveDate": effective_date,
468
- "updatedOrderLineAttributes": convert_and_respect_annotation_metadata(
469
- object_=updated_order_line_attributes,
470
- annotation=typing.Sequence[ProrationAttributeUpdate],
471
- direction="write",
472
- ),
473
- },
474
- headers={
475
- "content-type": "application/json",
476
- },
463
+ f"orders/{jsonable_encoder(id)}",
464
+ method="DELETE",
477
465
  request_options=request_options,
478
- omit=OMIT,
479
466
  )
480
467
  try:
481
468
  if 200 <= _response.status_code < 300:
482
469
  _data = typing.cast(
483
- ProrationUpgradeResponse,
470
+ EmptyResponse,
484
471
  parse_obj_as(
485
- type_=ProrationUpgradeResponse, # type: ignore
472
+ type_=EmptyResponse, # type: ignore
486
473
  object_=_response.json(),
487
474
  ),
488
475
  )
489
476
  return HttpResponse(response=_response, data=_data)
490
- if _response.status_code == 400:
491
- raise BadRequestError(
477
+ if _response.status_code == 403:
478
+ raise ForbiddenError(
492
479
  headers=dict(_response.headers),
493
480
  body=typing.cast(
494
- Error,
481
+ ErrorResponse,
495
482
  parse_obj_as(
496
- type_=Error, # type: ignore
483
+ type_=ErrorResponse, # type: ignore
497
484
  object_=_response.json(),
498
485
  ),
499
486
  ),
500
487
  )
501
- if _response.status_code == 403:
502
- raise ForbiddenError(
488
+ if _response.status_code == 404:
489
+ raise NotFoundError(
503
490
  headers=dict(_response.headers),
504
491
  body=typing.cast(
505
- Error,
492
+ ErrorResponse,
506
493
  parse_obj_as(
507
- type_=Error, # type: ignore
494
+ type_=ErrorResponse, # type: ignore
508
495
  object_=_response.json(),
509
496
  ),
510
497
  ),
511
498
  )
512
- if _response.status_code == 404:
513
- raise NotFoundError(
499
+ if _response.status_code == 500:
500
+ raise InternalServerError(
514
501
  headers=dict(_response.headers),
515
502
  body=typing.cast(
516
- Error,
503
+ ErrorResponse,
517
504
  parse_obj_as(
518
- type_=Error, # type: ignore
505
+ type_=ErrorResponse, # type: ignore
519
506
  object_=_response.json(),
520
507
  ),
521
508
  ),
@@ -525,36 +512,48 @@ class RawOrdersClient:
525
512
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
526
513
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
527
514
 
528
- def get_invoices(
529
- self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None
530
- ) -> HttpResponse[typing.List[Invoice]]:
515
+ def get_order_lines(
516
+ self,
517
+ id: str,
518
+ *,
519
+ limit: typing.Optional[int] = None,
520
+ offset: typing.Optional[int] = None,
521
+ request_options: typing.Optional[RequestOptions] = None,
522
+ ) -> HttpResponse[OrderLinesResponse]:
531
523
  """
532
- Retrieves all invoices associated with a specific order.
524
+ Get the order lines for an order by ID
533
525
 
534
526
  Parameters
535
527
  ----------
536
- order_id : str
537
- The order ID (can be internal ID or display ID)
528
+ id : str
529
+
530
+ limit : typing.Optional[int]
531
+
532
+ offset : typing.Optional[int]
538
533
 
539
534
  request_options : typing.Optional[RequestOptions]
540
535
  Request-specific configuration.
541
536
 
542
537
  Returns
543
538
  -------
544
- HttpResponse[typing.List[Invoice]]
545
- Success response
539
+ HttpResponse[OrderLinesResponse]
540
+ 200
546
541
  """
547
542
  _response = self._client_wrapper.httpx_client.request(
548
- f"orders/{jsonable_encoder(order_id)}/invoices",
543
+ f"orders/{jsonable_encoder(id)}/lines",
549
544
  method="GET",
545
+ params={
546
+ "limit": limit,
547
+ "offset": offset,
548
+ },
550
549
  request_options=request_options,
551
550
  )
552
551
  try:
553
552
  if 200 <= _response.status_code < 300:
554
553
  _data = typing.cast(
555
- typing.List[Invoice],
554
+ OrderLinesResponse,
556
555
  parse_obj_as(
557
- type_=typing.List[Invoice], # type: ignore
556
+ type_=OrderLinesResponse, # type: ignore
558
557
  object_=_response.json(),
559
558
  ),
560
559
  )
@@ -563,9 +562,9 @@ class RawOrdersClient:
563
562
  raise ForbiddenError(
564
563
  headers=dict(_response.headers),
565
564
  body=typing.cast(
566
- Error,
565
+ ErrorResponse,
567
566
  parse_obj_as(
568
- type_=Error, # type: ignore
567
+ type_=ErrorResponse, # type: ignore
569
568
  object_=_response.json(),
570
569
  ),
571
570
  ),
@@ -574,9 +573,20 @@ class RawOrdersClient:
574
573
  raise NotFoundError(
575
574
  headers=dict(_response.headers),
576
575
  body=typing.cast(
577
- Error,
576
+ ErrorResponse,
578
577
  parse_obj_as(
579
- type_=Error, # type: ignore
578
+ type_=ErrorResponse, # type: ignore
579
+ object_=_response.json(),
580
+ ),
581
+ ),
582
+ )
583
+ if _response.status_code == 500:
584
+ raise InternalServerError(
585
+ headers=dict(_response.headers),
586
+ body=typing.cast(
587
+ ErrorResponse,
588
+ parse_obj_as(
589
+ type_=ErrorResponse, # type: ignore
580
590
  object_=_response.json(),
581
591
  ),
582
592
  ),
@@ -591,78 +601,132 @@ class AsyncRawOrdersClient:
591
601
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
592
602
  self._client_wrapper = client_wrapper
593
603
 
594
- async def list(
595
- self, *, request_options: typing.Optional[RequestOptions] = None
596
- ) -> AsyncHttpResponse[typing.List[Order]]:
604
+ async def list_orders(
605
+ self,
606
+ *,
607
+ limit: typing.Optional[int] = None,
608
+ offset: typing.Optional[int] = None,
609
+ request_options: typing.Optional[RequestOptions] = None,
610
+ ) -> AsyncHttpResponse[OrderListResponse]:
597
611
  """
612
+ Get a list of orders for the organization
613
+
598
614
  Parameters
599
615
  ----------
616
+ limit : typing.Optional[int]
617
+
618
+ offset : typing.Optional[int]
619
+
600
620
  request_options : typing.Optional[RequestOptions]
601
621
  Request-specific configuration.
602
622
 
603
623
  Returns
604
624
  -------
605
- AsyncHttpResponse[typing.List[Order]]
606
- Success response
625
+ AsyncHttpResponse[OrderListResponse]
626
+ 200
607
627
  """
608
628
  _response = await self._client_wrapper.httpx_client.request(
609
- "orders",
629
+ "orders/",
610
630
  method="GET",
631
+ params={
632
+ "limit": limit,
633
+ "offset": offset,
634
+ },
611
635
  request_options=request_options,
612
636
  )
613
637
  try:
614
638
  if 200 <= _response.status_code < 300:
615
639
  _data = typing.cast(
616
- typing.List[Order],
640
+ OrderListResponse,
617
641
  parse_obj_as(
618
- type_=typing.List[Order], # type: ignore
642
+ type_=OrderListResponse, # type: ignore
619
643
  object_=_response.json(),
620
644
  ),
621
645
  )
622
646
  return AsyncHttpResponse(response=_response, data=_data)
647
+ if _response.status_code == 400:
648
+ raise BadRequestError(
649
+ headers=dict(_response.headers),
650
+ body=typing.cast(
651
+ ErrorResponse,
652
+ parse_obj_as(
653
+ type_=ErrorResponse, # type: ignore
654
+ object_=_response.json(),
655
+ ),
656
+ ),
657
+ )
658
+ if _response.status_code == 403:
659
+ raise ForbiddenError(
660
+ headers=dict(_response.headers),
661
+ body=typing.cast(
662
+ ErrorResponse,
663
+ parse_obj_as(
664
+ type_=ErrorResponse, # type: ignore
665
+ object_=_response.json(),
666
+ ),
667
+ ),
668
+ )
669
+ if _response.status_code == 500:
670
+ raise InternalServerError(
671
+ headers=dict(_response.headers),
672
+ body=typing.cast(
673
+ ErrorResponse,
674
+ parse_obj_as(
675
+ type_=ErrorResponse, # type: ignore
676
+ object_=_response.json(),
677
+ ),
678
+ ),
679
+ )
623
680
  _response_json = _response.json()
624
681
  except JSONDecodeError:
625
682
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
626
683
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
627
684
 
628
- async def create(
685
+ async def create_order(
629
686
  self,
630
687
  *,
631
- name: str,
632
- start_date: str,
633
- currency: str,
634
- customer_id: typing.Optional[str] = OMIT,
635
- customer_external_id: typing.Optional[str] = OMIT,
636
- billing_contact_id: typing.Optional[str] = OMIT,
637
- description: typing.Optional[str] = OMIT,
638
- end_date: typing.Optional[str] = OMIT,
639
- plan_id: typing.Optional[str] = OMIT,
640
- order_lines: typing.Optional[typing.Sequence[OrderLineCreate]] = OMIT,
688
+ customer_id: str,
689
+ billing_customer_id: typing.Optional[str] = OMIT,
690
+ billing_contact_ids: typing.Optional[typing.Sequence[str]] = OMIT,
691
+ name: typing.Optional[str] = OMIT,
692
+ start_date: typing.Optional[dt.datetime] = OMIT,
693
+ end_date: typing.Optional[dt.datetime] = OMIT,
694
+ subscription_terms: typing.Optional[int] = OMIT,
695
+ creation_state: typing.Optional[OrderCreationState] = OMIT,
696
+ billing_anchor: typing.Optional[float] = OMIT,
697
+ payment_terms: typing.Optional[str] = OMIT,
698
+ external_id: typing.Optional[str] = OMIT,
699
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
641
700
  request_options: typing.Optional[RequestOptions] = None,
642
701
  ) -> AsyncHttpResponse[Order]:
643
702
  """
703
+ Creates a new order for the organization
704
+
644
705
  Parameters
645
706
  ----------
646
- name : str
707
+ customer_id : str
647
708
 
648
- start_date : str
709
+ billing_customer_id : typing.Optional[str]
649
710
 
650
- currency : str
711
+ billing_contact_ids : typing.Optional[typing.Sequence[str]]
651
712
 
652
- customer_id : typing.Optional[str]
713
+ name : typing.Optional[str]
653
714
 
654
- customer_external_id : typing.Optional[str]
715
+ start_date : typing.Optional[dt.datetime]
655
716
 
656
- billing_contact_id : typing.Optional[str]
717
+ end_date : typing.Optional[dt.datetime]
657
718
 
658
- description : typing.Optional[str]
719
+ subscription_terms : typing.Optional[int]
659
720
 
660
- end_date : typing.Optional[str]
721
+ creation_state : typing.Optional[OrderCreationState]
661
722
 
662
- plan_id : typing.Optional[str]
663
- Optional plan ID to associate with this order
723
+ billing_anchor : typing.Optional[float]
664
724
 
665
- order_lines : typing.Optional[typing.Sequence[OrderLineCreate]]
725
+ payment_terms : typing.Optional[str]
726
+
727
+ external_id : typing.Optional[str]
728
+
729
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
666
730
 
667
731
  request_options : typing.Optional[RequestOptions]
668
732
  Request-specific configuration.
@@ -670,24 +734,24 @@ class AsyncRawOrdersClient:
670
734
  Returns
671
735
  -------
672
736
  AsyncHttpResponse[Order]
673
- Success response
737
+ 201
674
738
  """
675
739
  _response = await self._client_wrapper.httpx_client.request(
676
- "orders",
740
+ "orders/",
677
741
  method="POST",
678
742
  json={
679
743
  "customerId": customer_id,
680
- "customerExternalId": customer_external_id,
681
- "billingContactId": billing_contact_id,
744
+ "billingCustomerId": billing_customer_id,
745
+ "billingContactIds": billing_contact_ids,
682
746
  "name": name,
683
- "description": description,
684
747
  "startDate": start_date,
685
748
  "endDate": end_date,
686
- "currency": currency,
687
- "planId": plan_id,
688
- "orderLines": convert_and_respect_annotation_metadata(
689
- object_=order_lines, annotation=typing.Sequence[OrderLineCreate], direction="write"
690
- ),
749
+ "subscriptionTerms": subscription_terms,
750
+ "creationState": creation_state,
751
+ "billingAnchor": billing_anchor,
752
+ "paymentTerms": payment_terms,
753
+ "externalId": external_id,
754
+ "metadata": metadata,
691
755
  },
692
756
  headers={
693
757
  "content-type": "application/json",
@@ -705,132 +769,53 @@ class AsyncRawOrdersClient:
705
769
  ),
706
770
  )
707
771
  return AsyncHttpResponse(response=_response, data=_data)
708
- _response_json = _response.json()
709
- except JSONDecodeError:
710
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
711
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
712
-
713
- async def get(
714
- self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None
715
- ) -> AsyncHttpResponse[Order]:
716
- """
717
- Parameters
718
- ----------
719
- order_id : str
720
-
721
- request_options : typing.Optional[RequestOptions]
722
- Request-specific configuration.
723
-
724
- Returns
725
- -------
726
- AsyncHttpResponse[Order]
727
- Success response
728
- """
729
- _response = await self._client_wrapper.httpx_client.request(
730
- f"orders/{jsonable_encoder(order_id)}",
731
- method="GET",
732
- request_options=request_options,
733
- )
734
- try:
735
- if 200 <= _response.status_code < 300:
736
- _data = typing.cast(
737
- Order,
738
- parse_obj_as(
739
- type_=Order, # type: ignore
740
- object_=_response.json(),
772
+ if _response.status_code == 400:
773
+ raise BadRequestError(
774
+ headers=dict(_response.headers),
775
+ body=typing.cast(
776
+ ErrorResponse,
777
+ parse_obj_as(
778
+ type_=ErrorResponse, # type: ignore
779
+ object_=_response.json(),
780
+ ),
741
781
  ),
742
782
  )
743
- return AsyncHttpResponse(response=_response, data=_data)
744
- _response_json = _response.json()
745
- except JSONDecodeError:
746
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
747
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
748
-
749
- async def delete(
750
- self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None
751
- ) -> AsyncHttpResponse[None]:
752
- """
753
- Parameters
754
- ----------
755
- order_id : str
756
-
757
- request_options : typing.Optional[RequestOptions]
758
- Request-specific configuration.
759
-
760
- Returns
761
- -------
762
- AsyncHttpResponse[None]
763
- """
764
- _response = await self._client_wrapper.httpx_client.request(
765
- f"orders/{jsonable_encoder(order_id)}",
766
- method="DELETE",
767
- request_options=request_options,
768
- )
769
- try:
770
- if 200 <= _response.status_code < 300:
771
- return AsyncHttpResponse(response=_response, data=None)
772
- _response_json = _response.json()
773
- except JSONDecodeError:
774
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
775
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
776
-
777
- async def activate(
778
- self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None
779
- ) -> AsyncHttpResponse[Order]:
780
- """
781
- Parameters
782
- ----------
783
- order_id : str
784
-
785
- request_options : typing.Optional[RequestOptions]
786
- Request-specific configuration.
787
-
788
- Returns
789
- -------
790
- AsyncHttpResponse[Order]
791
- Success response
792
- """
793
- _response = await self._client_wrapper.httpx_client.request(
794
- f"orders/{jsonable_encoder(order_id)}/activate",
795
- method="POST",
796
- request_options=request_options,
797
- )
798
- try:
799
- if 200 <= _response.status_code < 300:
800
- _data = typing.cast(
801
- Order,
802
- parse_obj_as(
803
- type_=Order, # type: ignore
804
- object_=_response.json(),
783
+ if _response.status_code == 403:
784
+ raise ForbiddenError(
785
+ headers=dict(_response.headers),
786
+ body=typing.cast(
787
+ ErrorResponse,
788
+ parse_obj_as(
789
+ type_=ErrorResponse, # type: ignore
790
+ object_=_response.json(),
791
+ ),
792
+ ),
793
+ )
794
+ if _response.status_code == 500:
795
+ raise InternalServerError(
796
+ headers=dict(_response.headers),
797
+ body=typing.cast(
798
+ ErrorResponse,
799
+ parse_obj_as(
800
+ type_=ErrorResponse, # type: ignore
801
+ object_=_response.json(),
802
+ ),
805
803
  ),
806
804
  )
807
- return AsyncHttpResponse(response=_response, data=_data)
808
805
  _response_json = _response.json()
809
806
  except JSONDecodeError:
810
807
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
811
808
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
812
809
 
813
- async def activate_and_pay(
814
- self,
815
- order_id: str,
816
- *,
817
- confirmation_token: str,
818
- return_url: str,
819
- request_options: typing.Optional[RequestOptions] = None,
810
+ async def get_order_by_id(
811
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
820
812
  ) -> AsyncHttpResponse[Order]:
821
813
  """
822
- Activates the order and processes the initial payment using the provided Stripe confirmation token.
814
+ Get an order by ID
823
815
 
824
816
  Parameters
825
817
  ----------
826
- order_id : str
827
- The order ID (can be internal ID or display ID)
828
-
829
- confirmation_token : str
830
- Stripe confirmation token for the payment method
831
-
832
- return_url : str
833
- URL to redirect to after payment processing
818
+ id : str
834
819
 
835
820
  request_options : typing.Optional[RequestOptions]
836
821
  Request-specific configuration.
@@ -838,20 +823,12 @@ class AsyncRawOrdersClient:
838
823
  Returns
839
824
  -------
840
825
  AsyncHttpResponse[Order]
841
- Order activated and payment processed successfully
826
+ 200
842
827
  """
843
828
  _response = await self._client_wrapper.httpx_client.request(
844
- f"orders/{jsonable_encoder(order_id)}/activate-and-pay",
845
- method="POST",
846
- json={
847
- "confirmationToken": confirmation_token,
848
- "returnUrl": return_url,
849
- },
850
- headers={
851
- "content-type": "application/json",
852
- },
829
+ f"orders/{jsonable_encoder(id)}",
830
+ method="GET",
853
831
  request_options=request_options,
854
- omit=OMIT,
855
832
  )
856
833
  try:
857
834
  if 200 <= _response.status_code < 300:
@@ -863,35 +840,35 @@ class AsyncRawOrdersClient:
863
840
  ),
864
841
  )
865
842
  return AsyncHttpResponse(response=_response, data=_data)
866
- if _response.status_code == 400:
867
- raise BadRequestError(
843
+ if _response.status_code == 403:
844
+ raise ForbiddenError(
868
845
  headers=dict(_response.headers),
869
846
  body=typing.cast(
870
- Error,
847
+ ErrorResponse,
871
848
  parse_obj_as(
872
- type_=Error, # type: ignore
849
+ type_=ErrorResponse, # type: ignore
873
850
  object_=_response.json(),
874
851
  ),
875
852
  ),
876
853
  )
877
- if _response.status_code == 403:
878
- raise ForbiddenError(
854
+ if _response.status_code == 404:
855
+ raise NotFoundError(
879
856
  headers=dict(_response.headers),
880
857
  body=typing.cast(
881
- Error,
858
+ ErrorResponse,
882
859
  parse_obj_as(
883
- type_=Error, # type: ignore
860
+ type_=ErrorResponse, # type: ignore
884
861
  object_=_response.json(),
885
862
  ),
886
863
  ),
887
864
  )
888
- if _response.status_code == 404:
889
- raise NotFoundError(
865
+ if _response.status_code == 500:
866
+ raise InternalServerError(
890
867
  headers=dict(_response.headers),
891
868
  body=typing.cast(
892
- Error,
869
+ ErrorResponse,
893
870
  parse_obj_as(
894
- type_=Error, # type: ignore
871
+ type_=ErrorResponse, # type: ignore
895
872
  object_=_response.json(),
896
873
  ),
897
874
  ),
@@ -901,42 +878,75 @@ class AsyncRawOrdersClient:
901
878
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
902
879
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
903
880
 
904
- async def cancel_renewal(
881
+ async def update_order_by_id(
905
882
  self,
906
- order_id: str,
883
+ id: str,
907
884
  *,
908
- order_version: int,
909
- cancel_from_date: dt.datetime,
885
+ name: typing.Optional[str] = OMIT,
886
+ start_date: typing.Optional[dt.datetime] = OMIT,
887
+ end_date: typing.Optional[dt.datetime] = OMIT,
888
+ subscription_terms: typing.Optional[int] = OMIT,
889
+ creation_state: typing.Optional[OrderCreationState] = OMIT,
890
+ billing_anchor: typing.Optional[float] = OMIT,
891
+ payment_terms: typing.Optional[str] = OMIT,
892
+ external_id: typing.Optional[str] = OMIT,
893
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
894
+ billing_customer_id: typing.Optional[str] = OMIT,
895
+ billing_contact_ids: typing.Optional[typing.Sequence[str]] = OMIT,
910
896
  request_options: typing.Optional[RequestOptions] = None,
911
- ) -> AsyncHttpResponse[CancelRenewalResponse]:
897
+ ) -> AsyncHttpResponse[Order]:
912
898
  """
913
- Schedules the cancellation of an order's renewal from a specified date. The order will remain active until the cancellation date.
899
+ Update an order by ID
914
900
 
915
901
  Parameters
916
902
  ----------
917
- order_id : str
918
- The order ID (can be internal ID or display ID)
903
+ id : str
904
+
905
+ name : typing.Optional[str]
906
+
907
+ start_date : typing.Optional[dt.datetime]
908
+
909
+ end_date : typing.Optional[dt.datetime]
910
+
911
+ subscription_terms : typing.Optional[int]
912
+
913
+ creation_state : typing.Optional[OrderCreationState]
914
+
915
+ billing_anchor : typing.Optional[float]
919
916
 
920
- order_version : int
921
- The current version of the order (for optimistic locking)
917
+ payment_terms : typing.Optional[str]
922
918
 
923
- cancel_from_date : dt.datetime
924
- The date from which the renewal should be cancelled (ISO 8601 format)
919
+ external_id : typing.Optional[str]
920
+
921
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
922
+
923
+ billing_customer_id : typing.Optional[str]
924
+
925
+ billing_contact_ids : typing.Optional[typing.Sequence[str]]
925
926
 
926
927
  request_options : typing.Optional[RequestOptions]
927
928
  Request-specific configuration.
928
929
 
929
930
  Returns
930
931
  -------
931
- AsyncHttpResponse[CancelRenewalResponse]
932
- Order renewal cancelled successfully
932
+ AsyncHttpResponse[Order]
933
+ 200
933
934
  """
934
935
  _response = await self._client_wrapper.httpx_client.request(
935
- f"orders/{jsonable_encoder(order_id)}/cancel",
936
- method="POST",
936
+ f"orders/{jsonable_encoder(id)}",
937
+ method="PUT",
937
938
  json={
938
- "orderVersion": order_version,
939
- "cancelFromDate": cancel_from_date,
939
+ "name": name,
940
+ "startDate": start_date,
941
+ "endDate": end_date,
942
+ "subscriptionTerms": subscription_terms,
943
+ "creationState": creation_state,
944
+ "billingAnchor": billing_anchor,
945
+ "paymentTerms": payment_terms,
946
+ "externalId": external_id,
947
+ "metadata": metadata,
948
+ "billingCustomerId": billing_customer_id,
949
+ "billingContactIds": billing_contact_ids,
940
950
  },
941
951
  headers={
942
952
  "content-type": "application/json",
@@ -947,9 +957,9 @@ class AsyncRawOrdersClient:
947
957
  try:
948
958
  if 200 <= _response.status_code < 300:
949
959
  _data = typing.cast(
950
- CancelRenewalResponse,
960
+ Order,
951
961
  parse_obj_as(
952
- type_=CancelRenewalResponse, # type: ignore
962
+ type_=Order, # type: ignore
953
963
  object_=_response.json(),
954
964
  ),
955
965
  )
@@ -958,9 +968,9 @@ class AsyncRawOrdersClient:
958
968
  raise BadRequestError(
959
969
  headers=dict(_response.headers),
960
970
  body=typing.cast(
961
- Error,
971
+ ErrorResponse,
962
972
  parse_obj_as(
963
- type_=Error, # type: ignore
973
+ type_=ErrorResponse, # type: ignore
964
974
  object_=_response.json(),
965
975
  ),
966
976
  ),
@@ -969,9 +979,9 @@ class AsyncRawOrdersClient:
969
979
  raise ForbiddenError(
970
980
  headers=dict(_response.headers),
971
981
  body=typing.cast(
972
- Error,
982
+ ErrorResponse,
973
983
  parse_obj_as(
974
- type_=Error, # type: ignore
984
+ type_=ErrorResponse, # type: ignore
975
985
  object_=_response.json(),
976
986
  ),
977
987
  ),
@@ -980,9 +990,20 @@ class AsyncRawOrdersClient:
980
990
  raise NotFoundError(
981
991
  headers=dict(_response.headers),
982
992
  body=typing.cast(
983
- Error,
993
+ ErrorResponse,
984
994
  parse_obj_as(
985
- type_=Error, # type: ignore
995
+ type_=ErrorResponse, # type: ignore
996
+ object_=_response.json(),
997
+ ),
998
+ ),
999
+ )
1000
+ if _response.status_code == 500:
1001
+ raise InternalServerError(
1002
+ headers=dict(_response.headers),
1003
+ body=typing.cast(
1004
+ ErrorResponse,
1005
+ parse_obj_as(
1006
+ type_=ErrorResponse, # type: ignore
986
1007
  object_=_response.json(),
987
1008
  ),
988
1009
  ),
@@ -992,97 +1013,68 @@ class AsyncRawOrdersClient:
992
1013
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
993
1014
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
994
1015
 
995
- async def schedule_plan_change(
996
- self,
997
- order_id: str,
998
- *,
999
- order_version: int,
1000
- effective_date: dt.datetime,
1001
- updated_order_line_attributes: typing.Sequence[ProrationAttributeUpdate],
1002
- request_options: typing.Optional[RequestOptions] = None,
1003
- ) -> AsyncHttpResponse[ProrationUpgradeResponse]:
1016
+ async def delete_order_by_id(
1017
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1018
+ ) -> AsyncHttpResponse[EmptyResponse]:
1004
1019
  """
1005
- Schedules a plan upgrade or downgrade for an order with automatic proration calculation. Credits are applied for the unused portion of the current billing period.
1020
+ Delete an order by ID
1006
1021
 
1007
1022
  Parameters
1008
1023
  ----------
1009
- order_id : str
1010
- The order ID (can be internal ID or display ID)
1011
-
1012
- order_version : int
1013
- The current version of the order (for optimistic locking)
1014
-
1015
- effective_date : dt.datetime
1016
- The date when the plan change should take effect (ISO 8601 format)
1017
-
1018
- updated_order_line_attributes : typing.Sequence[ProrationAttributeUpdate]
1019
- The list of order line attributes to update
1024
+ id : str
1020
1025
 
1021
1026
  request_options : typing.Optional[RequestOptions]
1022
1027
  Request-specific configuration.
1023
1028
 
1024
1029
  Returns
1025
1030
  -------
1026
- AsyncHttpResponse[ProrationUpgradeResponse]
1027
- Plan change scheduled successfully
1031
+ AsyncHttpResponse[EmptyResponse]
1032
+ 200
1028
1033
  """
1029
1034
  _response = await self._client_wrapper.httpx_client.request(
1030
- f"orders/{jsonable_encoder(order_id)}/schedule-plan-change",
1031
- method="POST",
1032
- json={
1033
- "orderVersion": order_version,
1034
- "effectiveDate": effective_date,
1035
- "updatedOrderLineAttributes": convert_and_respect_annotation_metadata(
1036
- object_=updated_order_line_attributes,
1037
- annotation=typing.Sequence[ProrationAttributeUpdate],
1038
- direction="write",
1039
- ),
1040
- },
1041
- headers={
1042
- "content-type": "application/json",
1043
- },
1035
+ f"orders/{jsonable_encoder(id)}",
1036
+ method="DELETE",
1044
1037
  request_options=request_options,
1045
- omit=OMIT,
1046
1038
  )
1047
1039
  try:
1048
1040
  if 200 <= _response.status_code < 300:
1049
1041
  _data = typing.cast(
1050
- ProrationUpgradeResponse,
1042
+ EmptyResponse,
1051
1043
  parse_obj_as(
1052
- type_=ProrationUpgradeResponse, # type: ignore
1044
+ type_=EmptyResponse, # type: ignore
1053
1045
  object_=_response.json(),
1054
1046
  ),
1055
1047
  )
1056
1048
  return AsyncHttpResponse(response=_response, data=_data)
1057
- if _response.status_code == 400:
1058
- raise BadRequestError(
1049
+ if _response.status_code == 403:
1050
+ raise ForbiddenError(
1059
1051
  headers=dict(_response.headers),
1060
1052
  body=typing.cast(
1061
- Error,
1053
+ ErrorResponse,
1062
1054
  parse_obj_as(
1063
- type_=Error, # type: ignore
1055
+ type_=ErrorResponse, # type: ignore
1064
1056
  object_=_response.json(),
1065
1057
  ),
1066
1058
  ),
1067
1059
  )
1068
- if _response.status_code == 403:
1069
- raise ForbiddenError(
1060
+ if _response.status_code == 404:
1061
+ raise NotFoundError(
1070
1062
  headers=dict(_response.headers),
1071
1063
  body=typing.cast(
1072
- Error,
1064
+ ErrorResponse,
1073
1065
  parse_obj_as(
1074
- type_=Error, # type: ignore
1066
+ type_=ErrorResponse, # type: ignore
1075
1067
  object_=_response.json(),
1076
1068
  ),
1077
1069
  ),
1078
1070
  )
1079
- if _response.status_code == 404:
1080
- raise NotFoundError(
1071
+ if _response.status_code == 500:
1072
+ raise InternalServerError(
1081
1073
  headers=dict(_response.headers),
1082
1074
  body=typing.cast(
1083
- Error,
1075
+ ErrorResponse,
1084
1076
  parse_obj_as(
1085
- type_=Error, # type: ignore
1077
+ type_=ErrorResponse, # type: ignore
1086
1078
  object_=_response.json(),
1087
1079
  ),
1088
1080
  ),
@@ -1092,36 +1084,48 @@ class AsyncRawOrdersClient:
1092
1084
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1093
1085
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1094
1086
 
1095
- async def get_invoices(
1096
- self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None
1097
- ) -> AsyncHttpResponse[typing.List[Invoice]]:
1087
+ async def get_order_lines(
1088
+ self,
1089
+ id: str,
1090
+ *,
1091
+ limit: typing.Optional[int] = None,
1092
+ offset: typing.Optional[int] = None,
1093
+ request_options: typing.Optional[RequestOptions] = None,
1094
+ ) -> AsyncHttpResponse[OrderLinesResponse]:
1098
1095
  """
1099
- Retrieves all invoices associated with a specific order.
1096
+ Get the order lines for an order by ID
1100
1097
 
1101
1098
  Parameters
1102
1099
  ----------
1103
- order_id : str
1104
- The order ID (can be internal ID or display ID)
1100
+ id : str
1101
+
1102
+ limit : typing.Optional[int]
1103
+
1104
+ offset : typing.Optional[int]
1105
1105
 
1106
1106
  request_options : typing.Optional[RequestOptions]
1107
1107
  Request-specific configuration.
1108
1108
 
1109
1109
  Returns
1110
1110
  -------
1111
- AsyncHttpResponse[typing.List[Invoice]]
1112
- Success response
1111
+ AsyncHttpResponse[OrderLinesResponse]
1112
+ 200
1113
1113
  """
1114
1114
  _response = await self._client_wrapper.httpx_client.request(
1115
- f"orders/{jsonable_encoder(order_id)}/invoices",
1115
+ f"orders/{jsonable_encoder(id)}/lines",
1116
1116
  method="GET",
1117
+ params={
1118
+ "limit": limit,
1119
+ "offset": offset,
1120
+ },
1117
1121
  request_options=request_options,
1118
1122
  )
1119
1123
  try:
1120
1124
  if 200 <= _response.status_code < 300:
1121
1125
  _data = typing.cast(
1122
- typing.List[Invoice],
1126
+ OrderLinesResponse,
1123
1127
  parse_obj_as(
1124
- type_=typing.List[Invoice], # type: ignore
1128
+ type_=OrderLinesResponse, # type: ignore
1125
1129
  object_=_response.json(),
1126
1130
  ),
1127
1131
  )
@@ -1130,9 +1134,9 @@ class AsyncRawOrdersClient:
1130
1134
  raise ForbiddenError(
1131
1135
  headers=dict(_response.headers),
1132
1136
  body=typing.cast(
1133
- Error,
1137
+ ErrorResponse,
1134
1138
  parse_obj_as(
1135
- type_=Error, # type: ignore
1139
+ type_=ErrorResponse, # type: ignore
1136
1140
  object_=_response.json(),
1137
1141
  ),
1138
1142
  ),
@@ -1141,9 +1145,20 @@ class AsyncRawOrdersClient:
1141
1145
  raise NotFoundError(
1142
1146
  headers=dict(_response.headers),
1143
1147
  body=typing.cast(
1144
- Error,
1148
+ ErrorResponse,
1149
+ parse_obj_as(
1150
+ type_=ErrorResponse, # type: ignore
1151
+ object_=_response.json(),
1152
+ ),
1153
+ ),
1154
+ )
1155
+ if _response.status_code == 500:
1156
+ raise InternalServerError(
1157
+ headers=dict(_response.headers),
1158
+ body=typing.cast(
1159
+ ErrorResponse,
1145
1160
  parse_obj_as(
1146
- type_=Error, # type: ignore
1161
+ type_=ErrorResponse, # type: ignore
1147
1162
  object_=_response.json(),
1148
1163
  ),
1149
1164
  ),