paid-python 1.0.0a0__py3-none-any.whl → 1.0.0a1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. paid/__init__.py +61 -122
  2. paid/client.py +16 -22
  3. paid/contacts/client.py +415 -133
  4. paid/contacts/raw_client.py +1046 -118
  5. paid/core/client_wrapper.py +8 -10
  6. paid/customers/__init__.py +0 -3
  7. paid/customers/client.py +392 -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 +310 -201
  16. paid/orders/__init__.py +0 -3
  17. paid/orders/client.py +279 -471
  18. paid/orders/raw_client.py +551 -538
  19. paid/products/__init__.py +0 -3
  20. paid/products/client.py +129 -265
  21. paid/products/raw_client.py +563 -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.0a1.dist-info}/METADATA +22 -8
  68. paid_python-1.0.0a1.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.0a1.dist-info}/LICENSE +0 -0
  137. {paid_python-1.0.0a0.dist-info → paid_python-1.0.0a1.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_a_new_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,51 @@ 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,
253
- ) -> HttpResponse[Order]:
238
+ def get_order(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[Order]:
254
239
  """
255
- Activates the order and processes the initial payment using the provided Stripe confirmation token.
240
+ Get an order by its ID
256
241
 
257
242
  Parameters
258
243
  ----------
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
244
+ id : str
267
245
 
268
246
  request_options : typing.Optional[RequestOptions]
269
247
  Request-specific configuration.
@@ -271,20 +249,12 @@ class RawOrdersClient:
271
249
  Returns
272
250
  -------
273
251
  HttpResponse[Order]
274
- Order activated and payment processed successfully
252
+ 200
275
253
  """
276
254
  _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
- },
255
+ f"orders/{jsonable_encoder(id)}",
256
+ method="GET",
286
257
  request_options=request_options,
287
- omit=OMIT,
288
258
  )
289
259
  try:
290
260
  if 200 <= _response.status_code < 300:
@@ -296,35 +266,35 @@ class RawOrdersClient:
296
266
  ),
297
267
  )
298
268
  return HttpResponse(response=_response, data=_data)
299
- if _response.status_code == 400:
300
- raise BadRequestError(
269
+ if _response.status_code == 403:
270
+ raise ForbiddenError(
301
271
  headers=dict(_response.headers),
302
272
  body=typing.cast(
303
- Error,
273
+ ErrorResponse,
304
274
  parse_obj_as(
305
- type_=Error, # type: ignore
275
+ type_=ErrorResponse, # type: ignore
306
276
  object_=_response.json(),
307
277
  ),
308
278
  ),
309
279
  )
310
- if _response.status_code == 403:
311
- raise ForbiddenError(
280
+ if _response.status_code == 404:
281
+ raise NotFoundError(
312
282
  headers=dict(_response.headers),
313
283
  body=typing.cast(
314
- Error,
284
+ ErrorResponse,
315
285
  parse_obj_as(
316
- type_=Error, # type: ignore
286
+ type_=ErrorResponse, # type: ignore
317
287
  object_=_response.json(),
318
288
  ),
319
289
  ),
320
290
  )
321
- if _response.status_code == 404:
322
- raise NotFoundError(
291
+ if _response.status_code == 500:
292
+ raise InternalServerError(
323
293
  headers=dict(_response.headers),
324
294
  body=typing.cast(
325
- Error,
295
+ ErrorResponse,
326
296
  parse_obj_as(
327
- type_=Error, # type: ignore
297
+ type_=ErrorResponse, # type: ignore
328
298
  object_=_response.json(),
329
299
  ),
330
300
  ),
@@ -334,42 +304,75 @@ class RawOrdersClient:
334
304
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
335
305
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
336
306
 
337
- def cancel_renewal(
307
+ def update_order(
338
308
  self,
339
- order_id: str,
309
+ id: str,
340
310
  *,
341
- order_version: int,
342
- cancel_from_date: dt.datetime,
311
+ name: typing.Optional[str] = OMIT,
312
+ start_date: typing.Optional[dt.datetime] = OMIT,
313
+ end_date: typing.Optional[dt.datetime] = OMIT,
314
+ subscription_terms: typing.Optional[int] = OMIT,
315
+ creation_state: typing.Optional[OrderCreationState] = OMIT,
316
+ billing_anchor: typing.Optional[float] = OMIT,
317
+ payment_terms: typing.Optional[str] = OMIT,
318
+ external_id: typing.Optional[str] = OMIT,
319
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
320
+ billing_customer_id: typing.Optional[str] = OMIT,
321
+ billing_contact_ids: typing.Optional[typing.Sequence[str]] = OMIT,
343
322
  request_options: typing.Optional[RequestOptions] = None,
344
- ) -> HttpResponse[CancelRenewalResponse]:
323
+ ) -> HttpResponse[Order]:
345
324
  """
346
- Schedules the cancellation of an order's renewal from a specified date. The order will remain active until the cancellation date.
325
+ Update an order by its ID
347
326
 
348
327
  Parameters
349
328
  ----------
350
- order_id : str
351
- The order ID (can be internal ID or display ID)
329
+ id : str
330
+
331
+ name : typing.Optional[str]
332
+
333
+ start_date : typing.Optional[dt.datetime]
334
+
335
+ end_date : typing.Optional[dt.datetime]
336
+
337
+ subscription_terms : typing.Optional[int]
338
+
339
+ creation_state : typing.Optional[OrderCreationState]
340
+
341
+ billing_anchor : typing.Optional[float]
352
342
 
353
- order_version : int
354
- The current version of the order (for optimistic locking)
343
+ payment_terms : typing.Optional[str]
355
344
 
356
- cancel_from_date : dt.datetime
357
- The date from which the renewal should be cancelled (ISO 8601 format)
345
+ external_id : typing.Optional[str]
346
+
347
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
348
+
349
+ billing_customer_id : typing.Optional[str]
350
+
351
+ billing_contact_ids : typing.Optional[typing.Sequence[str]]
358
352
 
359
353
  request_options : typing.Optional[RequestOptions]
360
354
  Request-specific configuration.
361
355
 
362
356
  Returns
363
357
  -------
364
- HttpResponse[CancelRenewalResponse]
365
- Order renewal cancelled successfully
358
+ HttpResponse[Order]
359
+ 200
366
360
  """
367
361
  _response = self._client_wrapper.httpx_client.request(
368
- f"orders/{jsonable_encoder(order_id)}/cancel",
369
- method="POST",
362
+ f"orders/{jsonable_encoder(id)}",
363
+ method="PUT",
370
364
  json={
371
- "orderVersion": order_version,
372
- "cancelFromDate": cancel_from_date,
365
+ "name": name,
366
+ "startDate": start_date,
367
+ "endDate": end_date,
368
+ "subscriptionTerms": subscription_terms,
369
+ "creationState": creation_state,
370
+ "billingAnchor": billing_anchor,
371
+ "paymentTerms": payment_terms,
372
+ "externalId": external_id,
373
+ "metadata": metadata,
374
+ "billingCustomerId": billing_customer_id,
375
+ "billingContactIds": billing_contact_ids,
373
376
  },
374
377
  headers={
375
378
  "content-type": "application/json",
@@ -380,9 +383,9 @@ class RawOrdersClient:
380
383
  try:
381
384
  if 200 <= _response.status_code < 300:
382
385
  _data = typing.cast(
383
- CancelRenewalResponse,
386
+ Order,
384
387
  parse_obj_as(
385
- type_=CancelRenewalResponse, # type: ignore
388
+ type_=Order, # type: ignore
386
389
  object_=_response.json(),
387
390
  ),
388
391
  )
@@ -391,9 +394,9 @@ class RawOrdersClient:
391
394
  raise BadRequestError(
392
395
  headers=dict(_response.headers),
393
396
  body=typing.cast(
394
- Error,
397
+ ErrorResponse,
395
398
  parse_obj_as(
396
- type_=Error, # type: ignore
399
+ type_=ErrorResponse, # type: ignore
397
400
  object_=_response.json(),
398
401
  ),
399
402
  ),
@@ -402,9 +405,9 @@ class RawOrdersClient:
402
405
  raise ForbiddenError(
403
406
  headers=dict(_response.headers),
404
407
  body=typing.cast(
405
- Error,
408
+ ErrorResponse,
406
409
  parse_obj_as(
407
- type_=Error, # type: ignore
410
+ type_=ErrorResponse, # type: ignore
408
411
  object_=_response.json(),
409
412
  ),
410
413
  ),
@@ -413,9 +416,20 @@ class RawOrdersClient:
413
416
  raise NotFoundError(
414
417
  headers=dict(_response.headers),
415
418
  body=typing.cast(
416
- Error,
419
+ ErrorResponse,
417
420
  parse_obj_as(
418
- type_=Error, # type: ignore
421
+ type_=ErrorResponse, # type: ignore
422
+ object_=_response.json(),
423
+ ),
424
+ ),
425
+ )
426
+ if _response.status_code == 500:
427
+ raise InternalServerError(
428
+ headers=dict(_response.headers),
429
+ body=typing.cast(
430
+ ErrorResponse,
431
+ parse_obj_as(
432
+ type_=ErrorResponse, # type: ignore
419
433
  object_=_response.json(),
420
434
  ),
421
435
  ),
@@ -425,97 +439,68 @@ class RawOrdersClient:
425
439
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
426
440
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
427
441
 
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]:
442
+ def delete_order(
443
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
444
+ ) -> HttpResponse[EmptyResponse]:
437
445
  """
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.
446
+ Delete an order by its ID
439
447
 
440
448
  Parameters
441
449
  ----------
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
450
+ id : str
453
451
 
454
452
  request_options : typing.Optional[RequestOptions]
455
453
  Request-specific configuration.
456
454
 
457
455
  Returns
458
456
  -------
459
- HttpResponse[ProrationUpgradeResponse]
460
- Plan change scheduled successfully
457
+ HttpResponse[EmptyResponse]
458
+ 200
461
459
  """
462
460
  _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
- },
461
+ f"orders/{jsonable_encoder(id)}",
462
+ method="DELETE",
477
463
  request_options=request_options,
478
- omit=OMIT,
479
464
  )
480
465
  try:
481
466
  if 200 <= _response.status_code < 300:
482
467
  _data = typing.cast(
483
- ProrationUpgradeResponse,
468
+ EmptyResponse,
484
469
  parse_obj_as(
485
- type_=ProrationUpgradeResponse, # type: ignore
470
+ type_=EmptyResponse, # type: ignore
486
471
  object_=_response.json(),
487
472
  ),
488
473
  )
489
474
  return HttpResponse(response=_response, data=_data)
490
- if _response.status_code == 400:
491
- raise BadRequestError(
475
+ if _response.status_code == 403:
476
+ raise ForbiddenError(
492
477
  headers=dict(_response.headers),
493
478
  body=typing.cast(
494
- Error,
479
+ ErrorResponse,
495
480
  parse_obj_as(
496
- type_=Error, # type: ignore
481
+ type_=ErrorResponse, # type: ignore
497
482
  object_=_response.json(),
498
483
  ),
499
484
  ),
500
485
  )
501
- if _response.status_code == 403:
502
- raise ForbiddenError(
486
+ if _response.status_code == 404:
487
+ raise NotFoundError(
503
488
  headers=dict(_response.headers),
504
489
  body=typing.cast(
505
- Error,
490
+ ErrorResponse,
506
491
  parse_obj_as(
507
- type_=Error, # type: ignore
492
+ type_=ErrorResponse, # type: ignore
508
493
  object_=_response.json(),
509
494
  ),
510
495
  ),
511
496
  )
512
- if _response.status_code == 404:
513
- raise NotFoundError(
497
+ if _response.status_code == 500:
498
+ raise InternalServerError(
514
499
  headers=dict(_response.headers),
515
500
  body=typing.cast(
516
- Error,
501
+ ErrorResponse,
517
502
  parse_obj_as(
518
- type_=Error, # type: ignore
503
+ type_=ErrorResponse, # type: ignore
519
504
  object_=_response.json(),
520
505
  ),
521
506
  ),
@@ -525,36 +510,48 @@ class RawOrdersClient:
525
510
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
526
511
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
527
512
 
528
- def get_invoices(
529
- self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None
530
- ) -> HttpResponse[typing.List[Invoice]]:
513
+ def get_order_lines(
514
+ self,
515
+ id: str,
516
+ *,
517
+ limit: typing.Optional[int] = None,
518
+ offset: typing.Optional[int] = None,
519
+ request_options: typing.Optional[RequestOptions] = None,
520
+ ) -> HttpResponse[OrderLinesResponse]:
531
521
  """
532
- Retrieves all invoices associated with a specific order.
522
+ Get the order lines for an order by its ID
533
523
 
534
524
  Parameters
535
525
  ----------
536
- order_id : str
537
- The order ID (can be internal ID or display ID)
526
+ id : str
527
+
528
+ limit : typing.Optional[int]
529
+
530
+ offset : typing.Optional[int]
538
531
 
539
532
  request_options : typing.Optional[RequestOptions]
540
533
  Request-specific configuration.
541
534
 
542
535
  Returns
543
536
  -------
544
- HttpResponse[typing.List[Invoice]]
545
- Success response
537
+ HttpResponse[OrderLinesResponse]
538
+ 200
546
539
  """
547
540
  _response = self._client_wrapper.httpx_client.request(
548
- f"orders/{jsonable_encoder(order_id)}/invoices",
541
+ f"orders/{jsonable_encoder(id)}/lines",
549
542
  method="GET",
543
+ params={
544
+ "limit": limit,
545
+ "offset": offset,
546
+ },
550
547
  request_options=request_options,
551
548
  )
552
549
  try:
553
550
  if 200 <= _response.status_code < 300:
554
551
  _data = typing.cast(
555
- typing.List[Invoice],
552
+ OrderLinesResponse,
556
553
  parse_obj_as(
557
- type_=typing.List[Invoice], # type: ignore
554
+ type_=OrderLinesResponse, # type: ignore
558
555
  object_=_response.json(),
559
556
  ),
560
557
  )
@@ -563,9 +560,9 @@ class RawOrdersClient:
563
560
  raise ForbiddenError(
564
561
  headers=dict(_response.headers),
565
562
  body=typing.cast(
566
- Error,
563
+ ErrorResponse,
567
564
  parse_obj_as(
568
- type_=Error, # type: ignore
565
+ type_=ErrorResponse, # type: ignore
569
566
  object_=_response.json(),
570
567
  ),
571
568
  ),
@@ -574,9 +571,20 @@ class RawOrdersClient:
574
571
  raise NotFoundError(
575
572
  headers=dict(_response.headers),
576
573
  body=typing.cast(
577
- Error,
574
+ ErrorResponse,
575
+ parse_obj_as(
576
+ type_=ErrorResponse, # type: ignore
577
+ object_=_response.json(),
578
+ ),
579
+ ),
580
+ )
581
+ if _response.status_code == 500:
582
+ raise InternalServerError(
583
+ headers=dict(_response.headers),
584
+ body=typing.cast(
585
+ ErrorResponse,
578
586
  parse_obj_as(
579
- type_=Error, # type: ignore
587
+ type_=ErrorResponse, # type: ignore
580
588
  object_=_response.json(),
581
589
  ),
582
590
  ),
@@ -591,78 +599,132 @@ class AsyncRawOrdersClient:
591
599
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
592
600
  self._client_wrapper = client_wrapper
593
601
 
594
- async def list(
595
- self, *, request_options: typing.Optional[RequestOptions] = None
596
- ) -> AsyncHttpResponse[typing.List[Order]]:
602
+ async def list_orders(
603
+ self,
604
+ *,
605
+ limit: typing.Optional[int] = None,
606
+ offset: typing.Optional[int] = None,
607
+ request_options: typing.Optional[RequestOptions] = None,
608
+ ) -> AsyncHttpResponse[OrderListResponse]:
597
609
  """
610
+ Get a list of orders for the organization
611
+
598
612
  Parameters
599
613
  ----------
614
+ limit : typing.Optional[int]
615
+
616
+ offset : typing.Optional[int]
617
+
600
618
  request_options : typing.Optional[RequestOptions]
601
619
  Request-specific configuration.
602
620
 
603
621
  Returns
604
622
  -------
605
- AsyncHttpResponse[typing.List[Order]]
606
- Success response
623
+ AsyncHttpResponse[OrderListResponse]
624
+ 200
607
625
  """
608
626
  _response = await self._client_wrapper.httpx_client.request(
609
- "orders",
627
+ "orders/",
610
628
  method="GET",
629
+ params={
630
+ "limit": limit,
631
+ "offset": offset,
632
+ },
611
633
  request_options=request_options,
612
634
  )
613
635
  try:
614
636
  if 200 <= _response.status_code < 300:
615
637
  _data = typing.cast(
616
- typing.List[Order],
638
+ OrderListResponse,
617
639
  parse_obj_as(
618
- type_=typing.List[Order], # type: ignore
640
+ type_=OrderListResponse, # type: ignore
619
641
  object_=_response.json(),
620
642
  ),
621
643
  )
622
644
  return AsyncHttpResponse(response=_response, data=_data)
645
+ if _response.status_code == 400:
646
+ raise BadRequestError(
647
+ headers=dict(_response.headers),
648
+ body=typing.cast(
649
+ ErrorResponse,
650
+ parse_obj_as(
651
+ type_=ErrorResponse, # type: ignore
652
+ object_=_response.json(),
653
+ ),
654
+ ),
655
+ )
656
+ if _response.status_code == 403:
657
+ raise ForbiddenError(
658
+ headers=dict(_response.headers),
659
+ body=typing.cast(
660
+ ErrorResponse,
661
+ parse_obj_as(
662
+ type_=ErrorResponse, # type: ignore
663
+ object_=_response.json(),
664
+ ),
665
+ ),
666
+ )
667
+ if _response.status_code == 500:
668
+ raise InternalServerError(
669
+ headers=dict(_response.headers),
670
+ body=typing.cast(
671
+ ErrorResponse,
672
+ parse_obj_as(
673
+ type_=ErrorResponse, # type: ignore
674
+ object_=_response.json(),
675
+ ),
676
+ ),
677
+ )
623
678
  _response_json = _response.json()
624
679
  except JSONDecodeError:
625
680
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
626
681
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
627
682
 
628
- async def create(
683
+ async def create_a_new_order(
629
684
  self,
630
685
  *,
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,
686
+ customer_id: str,
687
+ billing_customer_id: typing.Optional[str] = OMIT,
688
+ billing_contact_ids: typing.Optional[typing.Sequence[str]] = OMIT,
689
+ name: typing.Optional[str] = OMIT,
690
+ start_date: typing.Optional[dt.datetime] = OMIT,
691
+ end_date: typing.Optional[dt.datetime] = OMIT,
692
+ subscription_terms: typing.Optional[int] = OMIT,
693
+ creation_state: typing.Optional[OrderCreationState] = OMIT,
694
+ billing_anchor: typing.Optional[float] = OMIT,
695
+ payment_terms: typing.Optional[str] = OMIT,
696
+ external_id: typing.Optional[str] = OMIT,
697
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
641
698
  request_options: typing.Optional[RequestOptions] = None,
642
699
  ) -> AsyncHttpResponse[Order]:
643
700
  """
701
+ Creates a new order for the organization
702
+
644
703
  Parameters
645
704
  ----------
646
- name : str
705
+ customer_id : str
706
+
707
+ billing_customer_id : typing.Optional[str]
708
+
709
+ billing_contact_ids : typing.Optional[typing.Sequence[str]]
647
710
 
648
- start_date : str
711
+ name : typing.Optional[str]
649
712
 
650
- currency : str
713
+ start_date : typing.Optional[dt.datetime]
651
714
 
652
- customer_id : typing.Optional[str]
715
+ end_date : typing.Optional[dt.datetime]
653
716
 
654
- customer_external_id : typing.Optional[str]
717
+ subscription_terms : typing.Optional[int]
655
718
 
656
- billing_contact_id : typing.Optional[str]
719
+ creation_state : typing.Optional[OrderCreationState]
657
720
 
658
- description : typing.Optional[str]
721
+ billing_anchor : typing.Optional[float]
659
722
 
660
- end_date : typing.Optional[str]
723
+ payment_terms : typing.Optional[str]
661
724
 
662
- plan_id : typing.Optional[str]
663
- Optional plan ID to associate with this order
725
+ external_id : typing.Optional[str]
664
726
 
665
- order_lines : typing.Optional[typing.Sequence[OrderLineCreate]]
727
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
666
728
 
667
729
  request_options : typing.Optional[RequestOptions]
668
730
  Request-specific configuration.
@@ -670,24 +732,24 @@ class AsyncRawOrdersClient:
670
732
  Returns
671
733
  -------
672
734
  AsyncHttpResponse[Order]
673
- Success response
735
+ 201
674
736
  """
675
737
  _response = await self._client_wrapper.httpx_client.request(
676
- "orders",
738
+ "orders/",
677
739
  method="POST",
678
740
  json={
679
741
  "customerId": customer_id,
680
- "customerExternalId": customer_external_id,
681
- "billingContactId": billing_contact_id,
742
+ "billingCustomerId": billing_customer_id,
743
+ "billingContactIds": billing_contact_ids,
682
744
  "name": name,
683
- "description": description,
684
745
  "startDate": start_date,
685
746
  "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
- ),
747
+ "subscriptionTerms": subscription_terms,
748
+ "creationState": creation_state,
749
+ "billingAnchor": billing_anchor,
750
+ "paymentTerms": payment_terms,
751
+ "externalId": external_id,
752
+ "metadata": metadata,
691
753
  },
692
754
  headers={
693
755
  "content-type": "application/json",
@@ -705,132 +767,53 @@ class AsyncRawOrdersClient:
705
767
  ),
706
768
  )
707
769
  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(),
770
+ if _response.status_code == 400:
771
+ raise BadRequestError(
772
+ headers=dict(_response.headers),
773
+ body=typing.cast(
774
+ ErrorResponse,
775
+ parse_obj_as(
776
+ type_=ErrorResponse, # type: ignore
777
+ object_=_response.json(),
778
+ ),
741
779
  ),
742
780
  )
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(),
781
+ if _response.status_code == 403:
782
+ raise ForbiddenError(
783
+ headers=dict(_response.headers),
784
+ body=typing.cast(
785
+ ErrorResponse,
786
+ parse_obj_as(
787
+ type_=ErrorResponse, # type: ignore
788
+ object_=_response.json(),
789
+ ),
790
+ ),
791
+ )
792
+ if _response.status_code == 500:
793
+ raise InternalServerError(
794
+ headers=dict(_response.headers),
795
+ body=typing.cast(
796
+ ErrorResponse,
797
+ parse_obj_as(
798
+ type_=ErrorResponse, # type: ignore
799
+ object_=_response.json(),
800
+ ),
805
801
  ),
806
802
  )
807
- return AsyncHttpResponse(response=_response, data=_data)
808
803
  _response_json = _response.json()
809
804
  except JSONDecodeError:
810
805
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
811
806
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
812
807
 
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,
808
+ async def get_order(
809
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
820
810
  ) -> AsyncHttpResponse[Order]:
821
811
  """
822
- Activates the order and processes the initial payment using the provided Stripe confirmation token.
812
+ Get an order by its ID
823
813
 
824
814
  Parameters
825
815
  ----------
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
816
+ id : str
834
817
 
835
818
  request_options : typing.Optional[RequestOptions]
836
819
  Request-specific configuration.
@@ -838,20 +821,12 @@ class AsyncRawOrdersClient:
838
821
  Returns
839
822
  -------
840
823
  AsyncHttpResponse[Order]
841
- Order activated and payment processed successfully
824
+ 200
842
825
  """
843
826
  _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
- },
827
+ f"orders/{jsonable_encoder(id)}",
828
+ method="GET",
853
829
  request_options=request_options,
854
- omit=OMIT,
855
830
  )
856
831
  try:
857
832
  if 200 <= _response.status_code < 300:
@@ -863,35 +838,35 @@ class AsyncRawOrdersClient:
863
838
  ),
864
839
  )
865
840
  return AsyncHttpResponse(response=_response, data=_data)
866
- if _response.status_code == 400:
867
- raise BadRequestError(
841
+ if _response.status_code == 403:
842
+ raise ForbiddenError(
868
843
  headers=dict(_response.headers),
869
844
  body=typing.cast(
870
- Error,
845
+ ErrorResponse,
871
846
  parse_obj_as(
872
- type_=Error, # type: ignore
847
+ type_=ErrorResponse, # type: ignore
873
848
  object_=_response.json(),
874
849
  ),
875
850
  ),
876
851
  )
877
- if _response.status_code == 403:
878
- raise ForbiddenError(
852
+ if _response.status_code == 404:
853
+ raise NotFoundError(
879
854
  headers=dict(_response.headers),
880
855
  body=typing.cast(
881
- Error,
856
+ ErrorResponse,
882
857
  parse_obj_as(
883
- type_=Error, # type: ignore
858
+ type_=ErrorResponse, # type: ignore
884
859
  object_=_response.json(),
885
860
  ),
886
861
  ),
887
862
  )
888
- if _response.status_code == 404:
889
- raise NotFoundError(
863
+ if _response.status_code == 500:
864
+ raise InternalServerError(
890
865
  headers=dict(_response.headers),
891
866
  body=typing.cast(
892
- Error,
867
+ ErrorResponse,
893
868
  parse_obj_as(
894
- type_=Error, # type: ignore
869
+ type_=ErrorResponse, # type: ignore
895
870
  object_=_response.json(),
896
871
  ),
897
872
  ),
@@ -901,42 +876,75 @@ class AsyncRawOrdersClient:
901
876
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
902
877
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
903
878
 
904
- async def cancel_renewal(
879
+ async def update_order(
905
880
  self,
906
- order_id: str,
881
+ id: str,
907
882
  *,
908
- order_version: int,
909
- cancel_from_date: dt.datetime,
883
+ name: typing.Optional[str] = OMIT,
884
+ start_date: typing.Optional[dt.datetime] = OMIT,
885
+ end_date: typing.Optional[dt.datetime] = OMIT,
886
+ subscription_terms: typing.Optional[int] = OMIT,
887
+ creation_state: typing.Optional[OrderCreationState] = OMIT,
888
+ billing_anchor: typing.Optional[float] = OMIT,
889
+ payment_terms: typing.Optional[str] = OMIT,
890
+ external_id: typing.Optional[str] = OMIT,
891
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
892
+ billing_customer_id: typing.Optional[str] = OMIT,
893
+ billing_contact_ids: typing.Optional[typing.Sequence[str]] = OMIT,
910
894
  request_options: typing.Optional[RequestOptions] = None,
911
- ) -> AsyncHttpResponse[CancelRenewalResponse]:
895
+ ) -> AsyncHttpResponse[Order]:
912
896
  """
913
- Schedules the cancellation of an order's renewal from a specified date. The order will remain active until the cancellation date.
897
+ Update an order by its ID
914
898
 
915
899
  Parameters
916
900
  ----------
917
- order_id : str
918
- The order ID (can be internal ID or display ID)
901
+ id : str
902
+
903
+ name : typing.Optional[str]
904
+
905
+ start_date : typing.Optional[dt.datetime]
906
+
907
+ end_date : typing.Optional[dt.datetime]
908
+
909
+ subscription_terms : typing.Optional[int]
910
+
911
+ creation_state : typing.Optional[OrderCreationState]
912
+
913
+ billing_anchor : typing.Optional[float]
919
914
 
920
- order_version : int
921
- The current version of the order (for optimistic locking)
915
+ payment_terms : typing.Optional[str]
922
916
 
923
- cancel_from_date : dt.datetime
924
- The date from which the renewal should be cancelled (ISO 8601 format)
917
+ external_id : typing.Optional[str]
918
+
919
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
920
+
921
+ billing_customer_id : typing.Optional[str]
922
+
923
+ billing_contact_ids : typing.Optional[typing.Sequence[str]]
925
924
 
926
925
  request_options : typing.Optional[RequestOptions]
927
926
  Request-specific configuration.
928
927
 
929
928
  Returns
930
929
  -------
931
- AsyncHttpResponse[CancelRenewalResponse]
932
- Order renewal cancelled successfully
930
+ AsyncHttpResponse[Order]
931
+ 200
933
932
  """
934
933
  _response = await self._client_wrapper.httpx_client.request(
935
- f"orders/{jsonable_encoder(order_id)}/cancel",
936
- method="POST",
934
+ f"orders/{jsonable_encoder(id)}",
935
+ method="PUT",
937
936
  json={
938
- "orderVersion": order_version,
939
- "cancelFromDate": cancel_from_date,
937
+ "name": name,
938
+ "startDate": start_date,
939
+ "endDate": end_date,
940
+ "subscriptionTerms": subscription_terms,
941
+ "creationState": creation_state,
942
+ "billingAnchor": billing_anchor,
943
+ "paymentTerms": payment_terms,
944
+ "externalId": external_id,
945
+ "metadata": metadata,
946
+ "billingCustomerId": billing_customer_id,
947
+ "billingContactIds": billing_contact_ids,
940
948
  },
941
949
  headers={
942
950
  "content-type": "application/json",
@@ -947,9 +955,9 @@ class AsyncRawOrdersClient:
947
955
  try:
948
956
  if 200 <= _response.status_code < 300:
949
957
  _data = typing.cast(
950
- CancelRenewalResponse,
958
+ Order,
951
959
  parse_obj_as(
952
- type_=CancelRenewalResponse, # type: ignore
960
+ type_=Order, # type: ignore
953
961
  object_=_response.json(),
954
962
  ),
955
963
  )
@@ -958,9 +966,9 @@ class AsyncRawOrdersClient:
958
966
  raise BadRequestError(
959
967
  headers=dict(_response.headers),
960
968
  body=typing.cast(
961
- Error,
969
+ ErrorResponse,
962
970
  parse_obj_as(
963
- type_=Error, # type: ignore
971
+ type_=ErrorResponse, # type: ignore
964
972
  object_=_response.json(),
965
973
  ),
966
974
  ),
@@ -969,9 +977,9 @@ class AsyncRawOrdersClient:
969
977
  raise ForbiddenError(
970
978
  headers=dict(_response.headers),
971
979
  body=typing.cast(
972
- Error,
980
+ ErrorResponse,
973
981
  parse_obj_as(
974
- type_=Error, # type: ignore
982
+ type_=ErrorResponse, # type: ignore
975
983
  object_=_response.json(),
976
984
  ),
977
985
  ),
@@ -980,9 +988,20 @@ class AsyncRawOrdersClient:
980
988
  raise NotFoundError(
981
989
  headers=dict(_response.headers),
982
990
  body=typing.cast(
983
- Error,
991
+ ErrorResponse,
984
992
  parse_obj_as(
985
- type_=Error, # type: ignore
993
+ type_=ErrorResponse, # type: ignore
994
+ object_=_response.json(),
995
+ ),
996
+ ),
997
+ )
998
+ if _response.status_code == 500:
999
+ raise InternalServerError(
1000
+ headers=dict(_response.headers),
1001
+ body=typing.cast(
1002
+ ErrorResponse,
1003
+ parse_obj_as(
1004
+ type_=ErrorResponse, # type: ignore
986
1005
  object_=_response.json(),
987
1006
  ),
988
1007
  ),
@@ -992,97 +1011,68 @@ class AsyncRawOrdersClient:
992
1011
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
993
1012
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
994
1013
 
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]:
1014
+ async def delete_order(
1015
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1016
+ ) -> AsyncHttpResponse[EmptyResponse]:
1004
1017
  """
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.
1018
+ Delete an order by its ID
1006
1019
 
1007
1020
  Parameters
1008
1021
  ----------
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
1022
+ id : str
1020
1023
 
1021
1024
  request_options : typing.Optional[RequestOptions]
1022
1025
  Request-specific configuration.
1023
1026
 
1024
1027
  Returns
1025
1028
  -------
1026
- AsyncHttpResponse[ProrationUpgradeResponse]
1027
- Plan change scheduled successfully
1029
+ AsyncHttpResponse[EmptyResponse]
1030
+ 200
1028
1031
  """
1029
1032
  _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
- },
1033
+ f"orders/{jsonable_encoder(id)}",
1034
+ method="DELETE",
1044
1035
  request_options=request_options,
1045
- omit=OMIT,
1046
1036
  )
1047
1037
  try:
1048
1038
  if 200 <= _response.status_code < 300:
1049
1039
  _data = typing.cast(
1050
- ProrationUpgradeResponse,
1040
+ EmptyResponse,
1051
1041
  parse_obj_as(
1052
- type_=ProrationUpgradeResponse, # type: ignore
1042
+ type_=EmptyResponse, # type: ignore
1053
1043
  object_=_response.json(),
1054
1044
  ),
1055
1045
  )
1056
1046
  return AsyncHttpResponse(response=_response, data=_data)
1057
- if _response.status_code == 400:
1058
- raise BadRequestError(
1047
+ if _response.status_code == 403:
1048
+ raise ForbiddenError(
1059
1049
  headers=dict(_response.headers),
1060
1050
  body=typing.cast(
1061
- Error,
1051
+ ErrorResponse,
1062
1052
  parse_obj_as(
1063
- type_=Error, # type: ignore
1053
+ type_=ErrorResponse, # type: ignore
1064
1054
  object_=_response.json(),
1065
1055
  ),
1066
1056
  ),
1067
1057
  )
1068
- if _response.status_code == 403:
1069
- raise ForbiddenError(
1058
+ if _response.status_code == 404:
1059
+ raise NotFoundError(
1070
1060
  headers=dict(_response.headers),
1071
1061
  body=typing.cast(
1072
- Error,
1062
+ ErrorResponse,
1073
1063
  parse_obj_as(
1074
- type_=Error, # type: ignore
1064
+ type_=ErrorResponse, # type: ignore
1075
1065
  object_=_response.json(),
1076
1066
  ),
1077
1067
  ),
1078
1068
  )
1079
- if _response.status_code == 404:
1080
- raise NotFoundError(
1069
+ if _response.status_code == 500:
1070
+ raise InternalServerError(
1081
1071
  headers=dict(_response.headers),
1082
1072
  body=typing.cast(
1083
- Error,
1073
+ ErrorResponse,
1084
1074
  parse_obj_as(
1085
- type_=Error, # type: ignore
1075
+ type_=ErrorResponse, # type: ignore
1086
1076
  object_=_response.json(),
1087
1077
  ),
1088
1078
  ),
@@ -1092,36 +1082,48 @@ class AsyncRawOrdersClient:
1092
1082
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1093
1083
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1094
1084
 
1095
- async def get_invoices(
1096
- self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None
1097
- ) -> AsyncHttpResponse[typing.List[Invoice]]:
1085
+ async def get_order_lines(
1086
+ self,
1087
+ id: str,
1088
+ *,
1089
+ limit: typing.Optional[int] = None,
1090
+ offset: typing.Optional[int] = None,
1091
+ request_options: typing.Optional[RequestOptions] = None,
1092
+ ) -> AsyncHttpResponse[OrderLinesResponse]:
1098
1093
  """
1099
- Retrieves all invoices associated with a specific order.
1094
+ Get the order lines for an order by its ID
1100
1095
 
1101
1096
  Parameters
1102
1097
  ----------
1103
- order_id : str
1104
- The order ID (can be internal ID or display ID)
1098
+ id : str
1099
+
1100
+ limit : typing.Optional[int]
1101
+
1102
+ offset : typing.Optional[int]
1105
1103
 
1106
1104
  request_options : typing.Optional[RequestOptions]
1107
1105
  Request-specific configuration.
1108
1106
 
1109
1107
  Returns
1110
1108
  -------
1111
- AsyncHttpResponse[typing.List[Invoice]]
1112
- Success response
1109
+ AsyncHttpResponse[OrderLinesResponse]
1110
+ 200
1113
1111
  """
1114
1112
  _response = await self._client_wrapper.httpx_client.request(
1115
- f"orders/{jsonable_encoder(order_id)}/invoices",
1113
+ f"orders/{jsonable_encoder(id)}/lines",
1116
1114
  method="GET",
1115
+ params={
1116
+ "limit": limit,
1117
+ "offset": offset,
1118
+ },
1117
1119
  request_options=request_options,
1118
1120
  )
1119
1121
  try:
1120
1122
  if 200 <= _response.status_code < 300:
1121
1123
  _data = typing.cast(
1122
- typing.List[Invoice],
1124
+ OrderLinesResponse,
1123
1125
  parse_obj_as(
1124
- type_=typing.List[Invoice], # type: ignore
1126
+ type_=OrderLinesResponse, # type: ignore
1125
1127
  object_=_response.json(),
1126
1128
  ),
1127
1129
  )
@@ -1130,9 +1132,9 @@ class AsyncRawOrdersClient:
1130
1132
  raise ForbiddenError(
1131
1133
  headers=dict(_response.headers),
1132
1134
  body=typing.cast(
1133
- Error,
1135
+ ErrorResponse,
1134
1136
  parse_obj_as(
1135
- type_=Error, # type: ignore
1137
+ type_=ErrorResponse, # type: ignore
1136
1138
  object_=_response.json(),
1137
1139
  ),
1138
1140
  ),
@@ -1141,9 +1143,20 @@ class AsyncRawOrdersClient:
1141
1143
  raise NotFoundError(
1142
1144
  headers=dict(_response.headers),
1143
1145
  body=typing.cast(
1144
- Error,
1146
+ ErrorResponse,
1147
+ parse_obj_as(
1148
+ type_=ErrorResponse, # type: ignore
1149
+ object_=_response.json(),
1150
+ ),
1151
+ ),
1152
+ )
1153
+ if _response.status_code == 500:
1154
+ raise InternalServerError(
1155
+ headers=dict(_response.headers),
1156
+ body=typing.cast(
1157
+ ErrorResponse,
1145
1158
  parse_obj_as(
1146
- type_=Error, # type: ignore
1159
+ type_=ErrorResponse, # type: ignore
1147
1160
  object_=_response.json(),
1148
1161
  ),
1149
1162
  ),