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
@@ -6,7 +6,6 @@ from json.decoder import JSONDecodeError
6
6
 
7
7
  from ..core.api_error import ApiError
8
8
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
- from ..core.datetime_utils import serialize_datetime
10
9
  from ..core.http_response import AsyncHttpResponse, HttpResponse
11
10
  from ..core.jsonable_encoder import jsonable_encoder
12
11
  from ..core.pydantic_utilities import parse_obj_as
@@ -14,19 +13,14 @@ from ..core.request_options import RequestOptions
14
13
  from ..core.serialization import convert_and_respect_annotation_metadata
15
14
  from ..errors.bad_request_error import BadRequestError
16
15
  from ..errors.forbidden_error import ForbiddenError
16
+ from ..errors.internal_server_error import InternalServerError
17
17
  from ..errors.not_found_error import NotFoundError
18
- from ..types.address import Address
19
- from ..types.contact_create_for_customer import ContactCreateForCustomer
20
- from ..types.cost_traces_response import CostTracesResponse
21
- from ..types.creation_source import CreationSource
22
18
  from ..types.customer import Customer
23
- from ..types.entitlement_usage import EntitlementUsage
24
- from ..types.error import Error
25
- from ..types.payment_method import PaymentMethod
26
- from ..types.tax_exempt_status import TaxExemptStatus
27
- from ..types.usage_summaries_response import UsageSummariesResponse
28
- from .types.customers_check_entitlement_request_view import CustomersCheckEntitlementRequestView
29
- from .types.customers_check_entitlement_response import CustomersCheckEntitlementResponse
19
+ from ..types.customer_billing_address import CustomerBillingAddress
20
+ from ..types.customer_creation_state import CustomerCreationState
21
+ from ..types.customer_list_response import CustomerListResponse
22
+ from ..types.empty_response import EmptyResponse
23
+ from ..types.error_response import ErrorResponse
30
24
 
31
25
  # this is used as the default value for optional parameters
32
26
  OMIT = typing.cast(typing.Any, ...)
@@ -36,80 +30,126 @@ class RawCustomersClient:
36
30
  def __init__(self, *, client_wrapper: SyncClientWrapper):
37
31
  self._client_wrapper = client_wrapper
38
32
 
39
- def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[typing.List[Customer]]:
33
+ def list_customers(
34
+ self,
35
+ *,
36
+ limit: typing.Optional[int] = None,
37
+ offset: typing.Optional[int] = None,
38
+ request_options: typing.Optional[RequestOptions] = None,
39
+ ) -> HttpResponse[CustomerListResponse]:
40
40
  """
41
+ Get a list of customers for the organization
42
+
41
43
  Parameters
42
44
  ----------
45
+ limit : typing.Optional[int]
46
+
47
+ offset : typing.Optional[int]
48
+
43
49
  request_options : typing.Optional[RequestOptions]
44
50
  Request-specific configuration.
45
51
 
46
52
  Returns
47
53
  -------
48
- HttpResponse[typing.List[Customer]]
49
- Success response
54
+ HttpResponse[CustomerListResponse]
55
+ 200
50
56
  """
51
57
  _response = self._client_wrapper.httpx_client.request(
52
- "customers",
58
+ "customers/",
53
59
  method="GET",
60
+ params={
61
+ "limit": limit,
62
+ "offset": offset,
63
+ },
54
64
  request_options=request_options,
55
65
  )
56
66
  try:
57
67
  if 200 <= _response.status_code < 300:
58
68
  _data = typing.cast(
59
- typing.List[Customer],
69
+ CustomerListResponse,
60
70
  parse_obj_as(
61
- type_=typing.List[Customer], # type: ignore
71
+ type_=CustomerListResponse, # type: ignore
62
72
  object_=_response.json(),
63
73
  ),
64
74
  )
65
75
  return HttpResponse(response=_response, data=_data)
76
+ if _response.status_code == 400:
77
+ raise BadRequestError(
78
+ headers=dict(_response.headers),
79
+ body=typing.cast(
80
+ ErrorResponse,
81
+ parse_obj_as(
82
+ type_=ErrorResponse, # type: ignore
83
+ object_=_response.json(),
84
+ ),
85
+ ),
86
+ )
87
+ if _response.status_code == 403:
88
+ raise ForbiddenError(
89
+ headers=dict(_response.headers),
90
+ body=typing.cast(
91
+ ErrorResponse,
92
+ parse_obj_as(
93
+ type_=ErrorResponse, # type: ignore
94
+ object_=_response.json(),
95
+ ),
96
+ ),
97
+ )
98
+ if _response.status_code == 500:
99
+ raise InternalServerError(
100
+ headers=dict(_response.headers),
101
+ body=typing.cast(
102
+ ErrorResponse,
103
+ parse_obj_as(
104
+ type_=ErrorResponse, # type: ignore
105
+ object_=_response.json(),
106
+ ),
107
+ ),
108
+ )
66
109
  _response_json = _response.json()
67
110
  except JSONDecodeError:
68
111
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
69
112
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
70
113
 
71
- def create(
114
+ def create_customer(
72
115
  self,
73
116
  *,
74
117
  name: str,
75
- external_id: typing.Optional[str] = OMIT,
118
+ legal_name: typing.Optional[str] = OMIT,
119
+ email: typing.Optional[str] = OMIT,
76
120
  phone: typing.Optional[str] = OMIT,
77
- employee_count: typing.Optional[float] = OMIT,
78
- annual_revenue: typing.Optional[float] = OMIT,
79
- tax_exempt_status: typing.Optional[TaxExemptStatus] = OMIT,
80
- creation_source: typing.Optional[CreationSource] = OMIT,
81
121
  website: typing.Optional[str] = OMIT,
82
- billing_address: typing.Optional[Address] = OMIT,
122
+ external_id: typing.Optional[str] = OMIT,
123
+ billing_address: typing.Optional[CustomerBillingAddress] = OMIT,
124
+ creation_state: typing.Optional[CustomerCreationState] = OMIT,
125
+ vat_number: typing.Optional[str] = OMIT,
83
126
  metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
84
- contacts: typing.Optional[typing.Sequence[ContactCreateForCustomer]] = OMIT,
85
127
  request_options: typing.Optional[RequestOptions] = None,
86
128
  ) -> HttpResponse[Customer]:
87
129
  """
130
+ Creates a new customer for the organization
131
+
88
132
  Parameters
89
133
  ----------
90
134
  name : str
91
135
 
92
- external_id : typing.Optional[str]
136
+ legal_name : typing.Optional[str]
93
137
 
94
- phone : typing.Optional[str]
138
+ email : typing.Optional[str]
95
139
 
96
- employee_count : typing.Optional[float]
140
+ phone : typing.Optional[str]
97
141
 
98
- annual_revenue : typing.Optional[float]
142
+ website : typing.Optional[str]
99
143
 
100
- tax_exempt_status : typing.Optional[TaxExemptStatus]
144
+ external_id : typing.Optional[str]
101
145
 
102
- creation_source : typing.Optional[CreationSource]
146
+ billing_address : typing.Optional[CustomerBillingAddress]
103
147
 
104
- website : typing.Optional[str]
148
+ creation_state : typing.Optional[CustomerCreationState]
105
149
 
106
- billing_address : typing.Optional[Address]
150
+ vat_number : typing.Optional[str]
107
151
 
108
152
  metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
109
- Flexible JSON field for storing custom metadata about the customer
110
-
111
- contacts : typing.Optional[typing.Sequence[ContactCreateForCustomer]]
112
- Array of contacts to create for this customer
113
153
 
114
154
  request_options : typing.Optional[RequestOptions]
115
155
  Request-specific configuration.
@@ -117,27 +157,24 @@ class RawCustomersClient:
117
157
  Returns
118
158
  -------
119
159
  HttpResponse[Customer]
120
- Success response - customer already exists with this externalId
160
+ 201
121
161
  """
122
162
  _response = self._client_wrapper.httpx_client.request(
123
- "customers",
163
+ "customers/",
124
164
  method="POST",
125
165
  json={
126
166
  "name": name,
127
- "externalId": external_id,
167
+ "legalName": legal_name,
168
+ "email": email,
128
169
  "phone": phone,
129
- "employeeCount": employee_count,
130
- "annualRevenue": annual_revenue,
131
- "taxExemptStatus": tax_exempt_status,
132
- "creationSource": creation_source,
133
170
  "website": website,
171
+ "externalId": external_id,
134
172
  "billingAddress": convert_and_respect_annotation_metadata(
135
- object_=billing_address, annotation=Address, direction="write"
173
+ object_=billing_address, annotation=typing.Optional[CustomerBillingAddress], direction="write"
136
174
  ),
175
+ "creationState": creation_state,
176
+ "vatNumber": vat_number,
137
177
  "metadata": metadata,
138
- "contacts": convert_and_respect_annotation_metadata(
139
- object_=contacts, annotation=typing.Sequence[ContactCreateForCustomer], direction="write"
140
- ),
141
178
  },
142
179
  headers={
143
180
  "content-type": "application/json",
@@ -155,18 +192,53 @@ class RawCustomersClient:
155
192
  ),
156
193
  )
157
194
  return HttpResponse(response=_response, data=_data)
195
+ if _response.status_code == 400:
196
+ raise BadRequestError(
197
+ headers=dict(_response.headers),
198
+ body=typing.cast(
199
+ ErrorResponse,
200
+ parse_obj_as(
201
+ type_=ErrorResponse, # type: ignore
202
+ object_=_response.json(),
203
+ ),
204
+ ),
205
+ )
206
+ if _response.status_code == 403:
207
+ raise ForbiddenError(
208
+ headers=dict(_response.headers),
209
+ body=typing.cast(
210
+ ErrorResponse,
211
+ parse_obj_as(
212
+ type_=ErrorResponse, # type: ignore
213
+ object_=_response.json(),
214
+ ),
215
+ ),
216
+ )
217
+ if _response.status_code == 500:
218
+ raise InternalServerError(
219
+ headers=dict(_response.headers),
220
+ body=typing.cast(
221
+ ErrorResponse,
222
+ parse_obj_as(
223
+ type_=ErrorResponse, # type: ignore
224
+ object_=_response.json(),
225
+ ),
226
+ ),
227
+ )
158
228
  _response_json = _response.json()
159
229
  except JSONDecodeError:
160
230
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
161
231
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
162
232
 
163
- def get(
164
- self, customer_id: str, *, request_options: typing.Optional[RequestOptions] = None
233
+ def get_customer_by_id(
234
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
165
235
  ) -> HttpResponse[Customer]:
166
236
  """
237
+ Get a customer by ID
238
+
167
239
  Parameters
168
240
  ----------
169
- customer_id : str
241
+ id : str
170
242
 
171
243
  request_options : typing.Optional[RequestOptions]
172
244
  Request-specific configuration.
@@ -174,10 +246,10 @@ class RawCustomersClient:
174
246
  Returns
175
247
  -------
176
248
  HttpResponse[Customer]
177
- Success response
249
+ 200
178
250
  """
179
251
  _response = self._client_wrapper.httpx_client.request(
180
- f"customers/{jsonable_encoder(customer_id)}",
252
+ f"customers/{jsonable_encoder(id)}",
181
253
  method="GET",
182
254
  request_options=request_options,
183
255
  )
@@ -191,52 +263,89 @@ class RawCustomersClient:
191
263
  ),
192
264
  )
193
265
  return HttpResponse(response=_response, data=_data)
266
+ if _response.status_code == 403:
267
+ raise ForbiddenError(
268
+ headers=dict(_response.headers),
269
+ body=typing.cast(
270
+ ErrorResponse,
271
+ parse_obj_as(
272
+ type_=ErrorResponse, # type: ignore
273
+ object_=_response.json(),
274
+ ),
275
+ ),
276
+ )
277
+ if _response.status_code == 404:
278
+ raise NotFoundError(
279
+ headers=dict(_response.headers),
280
+ body=typing.cast(
281
+ ErrorResponse,
282
+ parse_obj_as(
283
+ type_=ErrorResponse, # type: ignore
284
+ object_=_response.json(),
285
+ ),
286
+ ),
287
+ )
288
+ if _response.status_code == 500:
289
+ raise InternalServerError(
290
+ headers=dict(_response.headers),
291
+ body=typing.cast(
292
+ ErrorResponse,
293
+ parse_obj_as(
294
+ type_=ErrorResponse, # type: ignore
295
+ object_=_response.json(),
296
+ ),
297
+ ),
298
+ )
194
299
  _response_json = _response.json()
195
300
  except JSONDecodeError:
196
301
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
197
302
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
198
303
 
199
- def update(
304
+ def update_customer_by_id(
200
305
  self,
201
- customer_id: str,
306
+ id: str,
202
307
  *,
203
308
  name: typing.Optional[str] = OMIT,
204
- external_id: typing.Optional[str] = OMIT,
309
+ legal_name: typing.Optional[str] = OMIT,
310
+ email: typing.Optional[str] = OMIT,
205
311
  phone: typing.Optional[str] = OMIT,
206
- employee_count: typing.Optional[float] = OMIT,
207
- annual_revenue: typing.Optional[float] = OMIT,
208
- tax_exempt_status: typing.Optional[TaxExemptStatus] = OMIT,
209
- creation_source: typing.Optional[CreationSource] = OMIT,
210
312
  website: typing.Optional[str] = OMIT,
211
- billing_address: typing.Optional[Address] = OMIT,
313
+ external_id: typing.Optional[str] = OMIT,
314
+ billing_address: typing.Optional[CustomerBillingAddress] = OMIT,
315
+ creation_state: typing.Optional[CustomerCreationState] = OMIT,
316
+ churn_date: typing.Optional[dt.datetime] = OMIT,
317
+ vat_number: typing.Optional[str] = OMIT,
212
318
  metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
213
319
  request_options: typing.Optional[RequestOptions] = None,
214
320
  ) -> HttpResponse[Customer]:
215
321
  """
322
+ Update a customer by ID
323
+
216
324
  Parameters
217
325
  ----------
218
- customer_id : str
326
+ id : str
219
327
 
220
328
  name : typing.Optional[str]
221
329
 
222
- external_id : typing.Optional[str]
330
+ legal_name : typing.Optional[str]
331
+
332
+ email : typing.Optional[str]
223
333
 
224
334
  phone : typing.Optional[str]
225
335
 
226
- employee_count : typing.Optional[float]
336
+ website : typing.Optional[str]
227
337
 
228
- annual_revenue : typing.Optional[float]
338
+ external_id : typing.Optional[str]
229
339
 
230
- tax_exempt_status : typing.Optional[TaxExemptStatus]
340
+ billing_address : typing.Optional[CustomerBillingAddress]
231
341
 
232
- creation_source : typing.Optional[CreationSource]
342
+ creation_state : typing.Optional[CustomerCreationState]
233
343
 
234
- website : typing.Optional[str]
344
+ churn_date : typing.Optional[dt.datetime]
235
345
 
236
- billing_address : typing.Optional[Address]
346
+ vat_number : typing.Optional[str]
237
347
 
238
348
  metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
239
- Flexible JSON field for storing custom metadata about the customer
240
349
 
241
350
  request_options : typing.Optional[RequestOptions]
242
351
  Request-specific configuration.
@@ -244,23 +353,24 @@ class RawCustomersClient:
244
353
  Returns
245
354
  -------
246
355
  HttpResponse[Customer]
247
- Customer updated successfully
356
+ 200
248
357
  """
249
358
  _response = self._client_wrapper.httpx_client.request(
250
- f"customers/{jsonable_encoder(customer_id)}",
359
+ f"customers/{jsonable_encoder(id)}",
251
360
  method="PUT",
252
361
  json={
253
362
  "name": name,
254
- "externalId": external_id,
363
+ "legalName": legal_name,
364
+ "email": email,
255
365
  "phone": phone,
256
- "employeeCount": employee_count,
257
- "annualRevenue": annual_revenue,
258
- "taxExemptStatus": tax_exempt_status,
259
- "creationSource": creation_source,
260
366
  "website": website,
367
+ "externalId": external_id,
261
368
  "billingAddress": convert_and_respect_annotation_metadata(
262
- object_=billing_address, annotation=Address, direction="write"
369
+ object_=billing_address, annotation=typing.Optional[CustomerBillingAddress], direction="write"
263
370
  ),
371
+ "creationState": creation_state,
372
+ "churnDate": churn_date,
373
+ "vatNumber": vat_number,
264
374
  "metadata": metadata,
265
375
  },
266
376
  headers={
@@ -279,93 +389,24 @@ class RawCustomersClient:
279
389
  ),
280
390
  )
281
391
  return HttpResponse(response=_response, data=_data)
282
- _response_json = _response.json()
283
- except JSONDecodeError:
284
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
285
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
286
-
287
- def delete(
288
- self, customer_id: str, *, request_options: typing.Optional[RequestOptions] = None
289
- ) -> HttpResponse[None]:
290
- """
291
- Parameters
292
- ----------
293
- customer_id : str
294
-
295
- request_options : typing.Optional[RequestOptions]
296
- Request-specific configuration.
297
-
298
- Returns
299
- -------
300
- HttpResponse[None]
301
- """
302
- _response = self._client_wrapper.httpx_client.request(
303
- f"customers/{jsonable_encoder(customer_id)}",
304
- method="DELETE",
305
- request_options=request_options,
306
- )
307
- try:
308
- if 200 <= _response.status_code < 300:
309
- return HttpResponse(response=_response, data=None)
310
- _response_json = _response.json()
311
- except JSONDecodeError:
312
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
313
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
314
-
315
- def check_entitlement(
316
- self,
317
- customer_id: str,
318
- *,
319
- event_name: str,
320
- view: typing.Optional[CustomersCheckEntitlementRequestView] = None,
321
- request_options: typing.Optional[RequestOptions] = None,
322
- ) -> HttpResponse[CustomersCheckEntitlementResponse]:
323
- """
324
- Parameters
325
- ----------
326
- customer_id : str
327
- The customer ID
328
-
329
- event_name : str
330
- The name of the usage event to check entitlement for
331
-
332
- view : typing.Optional[CustomersCheckEntitlementRequestView]
333
- Filter view - 'all' returns all entitlements regardless of status, 'active_only' returns only currently active entitlements with available credits
334
-
335
- request_options : typing.Optional[RequestOptions]
336
- Request-specific configuration.
337
-
338
- Returns
339
- -------
340
- HttpResponse[CustomersCheckEntitlementResponse]
341
- Success response
342
- """
343
- _response = self._client_wrapper.httpx_client.request(
344
- f"customers/{jsonable_encoder(customer_id)}/entitlement",
345
- method="GET",
346
- params={
347
- "event_name": event_name,
348
- "view": view,
349
- },
350
- request_options=request_options,
351
- )
352
- try:
353
- if 200 <= _response.status_code < 300:
354
- _data = typing.cast(
355
- CustomersCheckEntitlementResponse,
356
- parse_obj_as(
357
- type_=CustomersCheckEntitlementResponse, # type: ignore
358
- object_=_response.json(),
359
- ),
360
- )
361
- return HttpResponse(response=_response, data=_data)
362
392
  if _response.status_code == 400:
363
393
  raise BadRequestError(
364
394
  headers=dict(_response.headers),
365
395
  body=typing.cast(
366
- Error,
396
+ ErrorResponse,
397
+ parse_obj_as(
398
+ type_=ErrorResponse, # type: ignore
399
+ object_=_response.json(),
400
+ ),
401
+ ),
402
+ )
403
+ if _response.status_code == 403:
404
+ raise ForbiddenError(
405
+ headers=dict(_response.headers),
406
+ body=typing.cast(
407
+ ErrorResponse,
367
408
  parse_obj_as(
368
- type_=Error, # type: ignore
409
+ type_=ErrorResponse, # type: ignore
369
410
  object_=_response.json(),
370
411
  ),
371
412
  ),
@@ -374,9 +415,20 @@ class RawCustomersClient:
374
415
  raise NotFoundError(
375
416
  headers=dict(_response.headers),
376
417
  body=typing.cast(
377
- Error,
418
+ ErrorResponse,
419
+ parse_obj_as(
420
+ type_=ErrorResponse, # type: ignore
421
+ object_=_response.json(),
422
+ ),
423
+ ),
424
+ )
425
+ if _response.status_code == 500:
426
+ raise InternalServerError(
427
+ headers=dict(_response.headers),
428
+ body=typing.cast(
429
+ ErrorResponse,
378
430
  parse_obj_as(
379
- type_=Error, # type: ignore
431
+ type_=ErrorResponse, # type: ignore
380
432
  object_=_response.json(),
381
433
  ),
382
434
  ),
@@ -386,34 +438,35 @@ class RawCustomersClient:
386
438
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
387
439
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
388
440
 
389
- def get_entitlements(
390
- self, customer_id: str, *, request_options: typing.Optional[RequestOptions] = None
391
- ) -> HttpResponse[typing.List[EntitlementUsage]]:
441
+ def delete_customer_by_id(
442
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
443
+ ) -> HttpResponse[EmptyResponse]:
392
444
  """
445
+ Delete a customer by ID
446
+
393
447
  Parameters
394
448
  ----------
395
- customer_id : str
396
- The customer ID
449
+ id : str
397
450
 
398
451
  request_options : typing.Optional[RequestOptions]
399
452
  Request-specific configuration.
400
453
 
401
454
  Returns
402
455
  -------
403
- HttpResponse[typing.List[EntitlementUsage]]
404
- Success response
456
+ HttpResponse[EmptyResponse]
457
+ 200
405
458
  """
406
459
  _response = self._client_wrapper.httpx_client.request(
407
- f"customers/{jsonable_encoder(customer_id)}/credit-bundles",
408
- method="GET",
460
+ f"customers/{jsonable_encoder(id)}",
461
+ method="DELETE",
409
462
  request_options=request_options,
410
463
  )
411
464
  try:
412
465
  if 200 <= _response.status_code < 300:
413
466
  _data = typing.cast(
414
- typing.List[EntitlementUsage],
467
+ EmptyResponse,
415
468
  parse_obj_as(
416
- type_=typing.List[EntitlementUsage], # type: ignore
469
+ type_=EmptyResponse, # type: ignore
417
470
  object_=_response.json(),
418
471
  ),
419
472
  )
@@ -422,9 +475,31 @@ class RawCustomersClient:
422
475
  raise ForbiddenError(
423
476
  headers=dict(_response.headers),
424
477
  body=typing.cast(
425
- Error,
478
+ ErrorResponse,
479
+ parse_obj_as(
480
+ type_=ErrorResponse, # type: ignore
481
+ object_=_response.json(),
482
+ ),
483
+ ),
484
+ )
485
+ if _response.status_code == 404:
486
+ raise NotFoundError(
487
+ headers=dict(_response.headers),
488
+ body=typing.cast(
489
+ ErrorResponse,
490
+ parse_obj_as(
491
+ type_=ErrorResponse, # type: ignore
492
+ object_=_response.json(),
493
+ ),
494
+ ),
495
+ )
496
+ if _response.status_code == 500:
497
+ raise InternalServerError(
498
+ headers=dict(_response.headers),
499
+ body=typing.cast(
500
+ ErrorResponse,
426
501
  parse_obj_as(
427
- type_=Error, # type: ignore
502
+ type_=ErrorResponse, # type: ignore
428
503
  object_=_response.json(),
429
504
  ),
430
505
  ),
@@ -434,10 +509,12 @@ class RawCustomersClient:
434
509
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
435
510
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
436
511
 
437
- def get_by_external_id(
512
+ def get_customer_by_external_id(
438
513
  self, external_id: str, *, request_options: typing.Optional[RequestOptions] = None
439
514
  ) -> HttpResponse[Customer]:
440
515
  """
516
+ Get a customer by external ID
517
+
441
518
  Parameters
442
519
  ----------
443
520
  external_id : str
@@ -448,7 +525,7 @@ class RawCustomersClient:
448
525
  Returns
449
526
  -------
450
527
  HttpResponse[Customer]
451
- Success response
528
+ 200
452
529
  """
453
530
  _response = self._client_wrapper.httpx_client.request(
454
531
  f"customers/external/{jsonable_encoder(external_id)}",
@@ -465,52 +542,89 @@ class RawCustomersClient:
465
542
  ),
466
543
  )
467
544
  return HttpResponse(response=_response, data=_data)
545
+ if _response.status_code == 403:
546
+ raise ForbiddenError(
547
+ headers=dict(_response.headers),
548
+ body=typing.cast(
549
+ ErrorResponse,
550
+ parse_obj_as(
551
+ type_=ErrorResponse, # type: ignore
552
+ object_=_response.json(),
553
+ ),
554
+ ),
555
+ )
556
+ if _response.status_code == 404:
557
+ raise NotFoundError(
558
+ headers=dict(_response.headers),
559
+ body=typing.cast(
560
+ ErrorResponse,
561
+ parse_obj_as(
562
+ type_=ErrorResponse, # type: ignore
563
+ object_=_response.json(),
564
+ ),
565
+ ),
566
+ )
567
+ if _response.status_code == 500:
568
+ raise InternalServerError(
569
+ headers=dict(_response.headers),
570
+ body=typing.cast(
571
+ ErrorResponse,
572
+ parse_obj_as(
573
+ type_=ErrorResponse, # type: ignore
574
+ object_=_response.json(),
575
+ ),
576
+ ),
577
+ )
468
578
  _response_json = _response.json()
469
579
  except JSONDecodeError:
470
580
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
471
581
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
472
582
 
473
- def update_by_external_id(
583
+ def update_customer_by_external_id(
474
584
  self,
475
585
  external_id_: str,
476
586
  *,
477
587
  name: typing.Optional[str] = OMIT,
478
- external_id: typing.Optional[str] = OMIT,
588
+ legal_name: typing.Optional[str] = OMIT,
589
+ email: typing.Optional[str] = OMIT,
479
590
  phone: typing.Optional[str] = OMIT,
480
- employee_count: typing.Optional[float] = OMIT,
481
- annual_revenue: typing.Optional[float] = OMIT,
482
- tax_exempt_status: typing.Optional[TaxExemptStatus] = OMIT,
483
- creation_source: typing.Optional[CreationSource] = OMIT,
484
591
  website: typing.Optional[str] = OMIT,
485
- billing_address: typing.Optional[Address] = OMIT,
592
+ external_id: typing.Optional[str] = OMIT,
593
+ billing_address: typing.Optional[CustomerBillingAddress] = OMIT,
594
+ creation_state: typing.Optional[CustomerCreationState] = OMIT,
595
+ churn_date: typing.Optional[dt.datetime] = OMIT,
596
+ vat_number: typing.Optional[str] = OMIT,
486
597
  metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
487
598
  request_options: typing.Optional[RequestOptions] = None,
488
599
  ) -> HttpResponse[Customer]:
489
600
  """
601
+ Update a customer by external ID
602
+
490
603
  Parameters
491
604
  ----------
492
605
  external_id_ : str
493
606
 
494
607
  name : typing.Optional[str]
495
608
 
496
- external_id : typing.Optional[str]
609
+ legal_name : typing.Optional[str]
610
+
611
+ email : typing.Optional[str]
497
612
 
498
613
  phone : typing.Optional[str]
499
614
 
500
- employee_count : typing.Optional[float]
615
+ website : typing.Optional[str]
501
616
 
502
- annual_revenue : typing.Optional[float]
617
+ external_id : typing.Optional[str]
503
618
 
504
- tax_exempt_status : typing.Optional[TaxExemptStatus]
619
+ billing_address : typing.Optional[CustomerBillingAddress]
505
620
 
506
- creation_source : typing.Optional[CreationSource]
621
+ creation_state : typing.Optional[CustomerCreationState]
507
622
 
508
- website : typing.Optional[str]
623
+ churn_date : typing.Optional[dt.datetime]
509
624
 
510
- billing_address : typing.Optional[Address]
625
+ vat_number : typing.Optional[str]
511
626
 
512
627
  metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
513
- Flexible JSON field for storing custom metadata about the customer
514
628
 
515
629
  request_options : typing.Optional[RequestOptions]
516
630
  Request-specific configuration.
@@ -518,23 +632,24 @@ class RawCustomersClient:
518
632
  Returns
519
633
  -------
520
634
  HttpResponse[Customer]
521
- Success response
635
+ 200
522
636
  """
523
637
  _response = self._client_wrapper.httpx_client.request(
524
638
  f"customers/external/{jsonable_encoder(external_id_)}",
525
639
  method="PUT",
526
640
  json={
527
641
  "name": name,
528
- "externalId": external_id,
642
+ "legalName": legal_name,
643
+ "email": email,
529
644
  "phone": phone,
530
- "employeeCount": employee_count,
531
- "annualRevenue": annual_revenue,
532
- "taxExemptStatus": tax_exempt_status,
533
- "creationSource": creation_source,
534
645
  "website": website,
646
+ "externalId": external_id,
535
647
  "billingAddress": convert_and_respect_annotation_metadata(
536
- object_=billing_address, annotation=Address, direction="write"
648
+ object_=billing_address, annotation=typing.Optional[CustomerBillingAddress], direction="write"
537
649
  ),
650
+ "creationState": creation_state,
651
+ "churnDate": churn_date,
652
+ "vatNumber": vat_number,
538
653
  "metadata": metadata,
539
654
  },
540
655
  headers={
@@ -553,103 +668,13 @@ class RawCustomersClient:
553
668
  ),
554
669
  )
555
670
  return HttpResponse(response=_response, data=_data)
556
- _response_json = _response.json()
557
- except JSONDecodeError:
558
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
559
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
560
-
561
- def delete_by_external_id(
562
- self, external_id: str, *, request_options: typing.Optional[RequestOptions] = None
563
- ) -> HttpResponse[None]:
564
- """
565
- Parameters
566
- ----------
567
- external_id : str
568
-
569
- request_options : typing.Optional[RequestOptions]
570
- Request-specific configuration.
571
-
572
- Returns
573
- -------
574
- HttpResponse[None]
575
- """
576
- _response = self._client_wrapper.httpx_client.request(
577
- f"customers/external/{jsonable_encoder(external_id)}",
578
- method="DELETE",
579
- request_options=request_options,
580
- )
581
- try:
582
- if 200 <= _response.status_code < 300:
583
- return HttpResponse(response=_response, data=None)
584
- _response_json = _response.json()
585
- except JSONDecodeError:
586
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
587
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
588
-
589
- def get_costs_by_external_id(
590
- self,
591
- external_id: str,
592
- *,
593
- limit: typing.Optional[int] = None,
594
- offset: typing.Optional[int] = None,
595
- start_time: typing.Optional[dt.datetime] = None,
596
- end_time: typing.Optional[dt.datetime] = None,
597
- request_options: typing.Optional[RequestOptions] = None,
598
- ) -> HttpResponse[CostTracesResponse]:
599
- """
600
- Parameters
601
- ----------
602
- external_id : str
603
- The external ID of the customer
604
-
605
- limit : typing.Optional[int]
606
- Maximum number of traces to return (1-1000)
607
-
608
- offset : typing.Optional[int]
609
- Number of traces to skip for pagination
610
-
611
- start_time : typing.Optional[dt.datetime]
612
- Filter traces starting from this time (ISO 8601 format)
613
-
614
- end_time : typing.Optional[dt.datetime]
615
- Filter traces up to this time (ISO 8601 format)
616
-
617
- request_options : typing.Optional[RequestOptions]
618
- Request-specific configuration.
619
-
620
- Returns
621
- -------
622
- HttpResponse[CostTracesResponse]
623
- Success response
624
- """
625
- _response = self._client_wrapper.httpx_client.request(
626
- f"customers/external/{jsonable_encoder(external_id)}/costs",
627
- method="GET",
628
- params={
629
- "limit": limit,
630
- "offset": offset,
631
- "startTime": serialize_datetime(start_time) if start_time is not None else None,
632
- "endTime": serialize_datetime(end_time) if end_time is not None else None,
633
- },
634
- request_options=request_options,
635
- )
636
- try:
637
- if 200 <= _response.status_code < 300:
638
- _data = typing.cast(
639
- CostTracesResponse,
640
- parse_obj_as(
641
- type_=CostTracesResponse, # type: ignore
642
- object_=_response.json(),
643
- ),
644
- )
645
- return HttpResponse(response=_response, data=_data)
646
671
  if _response.status_code == 400:
647
672
  raise BadRequestError(
648
673
  headers=dict(_response.headers),
649
674
  body=typing.cast(
650
- Error,
675
+ ErrorResponse,
651
676
  parse_obj_as(
652
- type_=Error, # type: ignore
677
+ type_=ErrorResponse, # type: ignore
653
678
  object_=_response.json(),
654
679
  ),
655
680
  ),
@@ -658,9 +683,9 @@ class RawCustomersClient:
658
683
  raise ForbiddenError(
659
684
  headers=dict(_response.headers),
660
685
  body=typing.cast(
661
- Error,
686
+ ErrorResponse,
662
687
  parse_obj_as(
663
- type_=Error, # type: ignore
688
+ type_=ErrorResponse, # type: ignore
664
689
  object_=_response.json(),
665
690
  ),
666
691
  ),
@@ -669,104 +694,20 @@ class RawCustomersClient:
669
694
  raise NotFoundError(
670
695
  headers=dict(_response.headers),
671
696
  body=typing.cast(
672
- Error,
673
- parse_obj_as(
674
- type_=Error, # type: ignore
675
- object_=_response.json(),
676
- ),
677
- ),
678
- )
679
- _response_json = _response.json()
680
- except JSONDecodeError:
681
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
682
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
683
-
684
- def get_usage_by_external_id(
685
- self,
686
- external_id: str,
687
- *,
688
- limit: typing.Optional[int] = None,
689
- offset: typing.Optional[int] = None,
690
- start_time: typing.Optional[dt.datetime] = None,
691
- end_time: typing.Optional[dt.datetime] = None,
692
- request_options: typing.Optional[RequestOptions] = None,
693
- ) -> HttpResponse[UsageSummariesResponse]:
694
- """
695
- Parameters
696
- ----------
697
- external_id : str
698
- The external ID of the customer
699
-
700
- limit : typing.Optional[int]
701
- Maximum number of usage summaries to return (1-1000)
702
-
703
- offset : typing.Optional[int]
704
- Number of usage summaries to skip for pagination
705
-
706
- start_time : typing.Optional[dt.datetime]
707
- Filter usage summaries starting from this time (ISO 8601 format). Returns summaries that overlap with the time range.
708
-
709
- end_time : typing.Optional[dt.datetime]
710
- Filter usage summaries up to this time (ISO 8601 format). Returns summaries that overlap with the time range.
711
-
712
- request_options : typing.Optional[RequestOptions]
713
- Request-specific configuration.
714
-
715
- Returns
716
- -------
717
- HttpResponse[UsageSummariesResponse]
718
- Success response
719
- """
720
- _response = self._client_wrapper.httpx_client.request(
721
- f"customers/external/{jsonable_encoder(external_id)}/usage",
722
- method="GET",
723
- params={
724
- "limit": limit,
725
- "offset": offset,
726
- "startTime": serialize_datetime(start_time) if start_time is not None else None,
727
- "endTime": serialize_datetime(end_time) if end_time is not None else None,
728
- },
729
- request_options=request_options,
730
- )
731
- try:
732
- if 200 <= _response.status_code < 300:
733
- _data = typing.cast(
734
- UsageSummariesResponse,
735
- parse_obj_as(
736
- type_=UsageSummariesResponse, # type: ignore
737
- object_=_response.json(),
738
- ),
739
- )
740
- return HttpResponse(response=_response, data=_data)
741
- if _response.status_code == 400:
742
- raise BadRequestError(
743
- headers=dict(_response.headers),
744
- body=typing.cast(
745
- Error,
697
+ ErrorResponse,
746
698
  parse_obj_as(
747
- type_=Error, # type: ignore
699
+ type_=ErrorResponse, # type: ignore
748
700
  object_=_response.json(),
749
701
  ),
750
702
  ),
751
703
  )
752
- if _response.status_code == 403:
753
- raise ForbiddenError(
754
- headers=dict(_response.headers),
755
- body=typing.cast(
756
- Error,
757
- parse_obj_as(
758
- type_=Error, # type: ignore
759
- object_=_response.json(),
760
- ),
761
- ),
762
- )
763
- if _response.status_code == 404:
764
- raise NotFoundError(
704
+ if _response.status_code == 500:
705
+ raise InternalServerError(
765
706
  headers=dict(_response.headers),
766
707
  body=typing.cast(
767
- Error,
708
+ ErrorResponse,
768
709
  parse_obj_as(
769
- type_=Error, # type: ignore
710
+ type_=ErrorResponse, # type: ignore
770
711
  object_=_response.json(),
771
712
  ),
772
713
  ),
@@ -776,36 +717,35 @@ class RawCustomersClient:
776
717
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
777
718
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
778
719
 
779
- def list_payment_methods(
720
+ def delete_customer_by_external_id(
780
721
  self, external_id: str, *, request_options: typing.Optional[RequestOptions] = None
781
- ) -> HttpResponse[typing.List[PaymentMethod]]:
722
+ ) -> HttpResponse[EmptyResponse]:
782
723
  """
783
- Retrieves all payment methods associated with a customer identified by their external ID.
724
+ Delete a customer by external ID
784
725
 
785
726
  Parameters
786
727
  ----------
787
728
  external_id : str
788
- The external ID of the customer
789
729
 
790
730
  request_options : typing.Optional[RequestOptions]
791
731
  Request-specific configuration.
792
732
 
793
733
  Returns
794
734
  -------
795
- HttpResponse[typing.List[PaymentMethod]]
796
- Success response
735
+ HttpResponse[EmptyResponse]
736
+ 200
797
737
  """
798
738
  _response = self._client_wrapper.httpx_client.request(
799
- f"customers/external/{jsonable_encoder(external_id)}/payment-methods",
800
- method="GET",
739
+ f"customers/external/{jsonable_encoder(external_id)}",
740
+ method="DELETE",
801
741
  request_options=request_options,
802
742
  )
803
743
  try:
804
744
  if 200 <= _response.status_code < 300:
805
745
  _data = typing.cast(
806
- typing.List[PaymentMethod],
746
+ EmptyResponse,
807
747
  parse_obj_as(
808
- type_=typing.List[PaymentMethod], # type: ignore
748
+ type_=EmptyResponse, # type: ignore
809
749
  object_=_response.json(),
810
750
  ),
811
751
  )
@@ -814,9 +754,9 @@ class RawCustomersClient:
814
754
  raise ForbiddenError(
815
755
  headers=dict(_response.headers),
816
756
  body=typing.cast(
817
- Error,
757
+ ErrorResponse,
818
758
  parse_obj_as(
819
- type_=Error, # type: ignore
759
+ type_=ErrorResponse, # type: ignore
820
760
  object_=_response.json(),
821
761
  ),
822
762
  ),
@@ -825,9 +765,20 @@ class RawCustomersClient:
825
765
  raise NotFoundError(
826
766
  headers=dict(_response.headers),
827
767
  body=typing.cast(
828
- Error,
768
+ ErrorResponse,
769
+ parse_obj_as(
770
+ type_=ErrorResponse, # type: ignore
771
+ object_=_response.json(),
772
+ ),
773
+ ),
774
+ )
775
+ if _response.status_code == 500:
776
+ raise InternalServerError(
777
+ headers=dict(_response.headers),
778
+ body=typing.cast(
779
+ ErrorResponse,
829
780
  parse_obj_as(
830
- type_=Error, # type: ignore
781
+ type_=ErrorResponse, # type: ignore
831
782
  object_=_response.json(),
832
783
  ),
833
784
  ),
@@ -837,71 +788,61 @@ class RawCustomersClient:
837
788
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
838
789
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
839
790
 
840
- def create_payment_method(
791
+
792
+ class AsyncRawCustomersClient:
793
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
794
+ self._client_wrapper = client_wrapper
795
+
796
+ async def list_customers(
841
797
  self,
842
- external_id: str,
843
798
  *,
844
- confirmation_token: str,
845
- return_url: str,
846
- metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
799
+ limit: typing.Optional[int] = None,
800
+ offset: typing.Optional[int] = None,
847
801
  request_options: typing.Optional[RequestOptions] = None,
848
- ) -> HttpResponse[PaymentMethod]:
802
+ ) -> AsyncHttpResponse[CustomerListResponse]:
849
803
  """
850
- Creates a new payment method for a customer using a Stripe confirmation token.
804
+ Get a list of customers for the organization
851
805
 
852
806
  Parameters
853
807
  ----------
854
- external_id : str
855
- The external ID of the customer
856
-
857
- confirmation_token : str
858
- Stripe confirmation token for the payment method
859
-
860
- return_url : str
861
- URL to redirect to after payment method setup
808
+ limit : typing.Optional[int]
862
809
 
863
- metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
864
- Optional metadata to attach to the payment method
810
+ offset : typing.Optional[int]
865
811
 
866
812
  request_options : typing.Optional[RequestOptions]
867
813
  Request-specific configuration.
868
814
 
869
815
  Returns
870
816
  -------
871
- HttpResponse[PaymentMethod]
872
- Payment method created successfully
817
+ AsyncHttpResponse[CustomerListResponse]
818
+ 200
873
819
  """
874
- _response = self._client_wrapper.httpx_client.request(
875
- f"customers/external/{jsonable_encoder(external_id)}/payment-methods",
876
- method="POST",
877
- json={
878
- "confirmationToken": confirmation_token,
879
- "returnUrl": return_url,
880
- "metadata": metadata,
881
- },
882
- headers={
883
- "content-type": "application/json",
820
+ _response = await self._client_wrapper.httpx_client.request(
821
+ "customers/",
822
+ method="GET",
823
+ params={
824
+ "limit": limit,
825
+ "offset": offset,
884
826
  },
885
827
  request_options=request_options,
886
- omit=OMIT,
887
828
  )
888
829
  try:
889
830
  if 200 <= _response.status_code < 300:
890
831
  _data = typing.cast(
891
- PaymentMethod,
832
+ CustomerListResponse,
892
833
  parse_obj_as(
893
- type_=PaymentMethod, # type: ignore
834
+ type_=CustomerListResponse, # type: ignore
894
835
  object_=_response.json(),
895
836
  ),
896
837
  )
897
- return HttpResponse(response=_response, data=_data)
838
+ return AsyncHttpResponse(response=_response, data=_data)
898
839
  if _response.status_code == 400:
899
840
  raise BadRequestError(
900
841
  headers=dict(_response.headers),
901
842
  body=typing.cast(
902
- Error,
843
+ ErrorResponse,
903
844
  parse_obj_as(
904
- type_=Error, # type: ignore
845
+ type_=ErrorResponse, # type: ignore
905
846
  object_=_response.json(),
906
847
  ),
907
848
  ),
@@ -910,76 +851,20 @@ class RawCustomersClient:
910
851
  raise ForbiddenError(
911
852
  headers=dict(_response.headers),
912
853
  body=typing.cast(
913
- Error,
914
- parse_obj_as(
915
- type_=Error, # type: ignore
916
- object_=_response.json(),
917
- ),
918
- ),
919
- )
920
- if _response.status_code == 404:
921
- raise NotFoundError(
922
- headers=dict(_response.headers),
923
- body=typing.cast(
924
- Error,
925
- parse_obj_as(
926
- type_=Error, # type: ignore
927
- object_=_response.json(),
928
- ),
929
- ),
930
- )
931
- _response_json = _response.json()
932
- except JSONDecodeError:
933
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
934
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
935
-
936
- def delete_payment_method(
937
- self, external_id: str, payment_method_id: str, *, request_options: typing.Optional[RequestOptions] = None
938
- ) -> HttpResponse[None]:
939
- """
940
- Deletes a specific payment method from a customer's account.
941
-
942
- Parameters
943
- ----------
944
- external_id : str
945
- The external ID of the customer
946
-
947
- payment_method_id : str
948
- The ID of the payment method to delete
949
-
950
- request_options : typing.Optional[RequestOptions]
951
- Request-specific configuration.
952
-
953
- Returns
954
- -------
955
- HttpResponse[None]
956
- """
957
- _response = self._client_wrapper.httpx_client.request(
958
- f"customers/external/{jsonable_encoder(external_id)}/payment-methods/{jsonable_encoder(payment_method_id)}",
959
- method="DELETE",
960
- request_options=request_options,
961
- )
962
- try:
963
- if 200 <= _response.status_code < 300:
964
- return HttpResponse(response=_response, data=None)
965
- if _response.status_code == 403:
966
- raise ForbiddenError(
967
- headers=dict(_response.headers),
968
- body=typing.cast(
969
- Error,
854
+ ErrorResponse,
970
855
  parse_obj_as(
971
- type_=Error, # type: ignore
856
+ type_=ErrorResponse, # type: ignore
972
857
  object_=_response.json(),
973
858
  ),
974
859
  ),
975
860
  )
976
- if _response.status_code == 404:
977
- raise NotFoundError(
861
+ if _response.status_code == 500:
862
+ raise InternalServerError(
978
863
  headers=dict(_response.headers),
979
864
  body=typing.cast(
980
- Error,
865
+ ErrorResponse,
981
866
  parse_obj_as(
982
- type_=Error, # type: ignore
867
+ type_=ErrorResponse, # type: ignore
983
868
  object_=_response.json(),
984
869
  ),
985
870
  ),
@@ -989,214 +874,45 @@ class RawCustomersClient:
989
874
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
990
875
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
991
876
 
992
-
993
- class AsyncRawCustomersClient:
994
- def __init__(self, *, client_wrapper: AsyncClientWrapper):
995
- self._client_wrapper = client_wrapper
996
-
997
- async def list(
998
- self, *, request_options: typing.Optional[RequestOptions] = None
999
- ) -> AsyncHttpResponse[typing.List[Customer]]:
1000
- """
1001
- Parameters
1002
- ----------
1003
- request_options : typing.Optional[RequestOptions]
1004
- Request-specific configuration.
1005
-
1006
- Returns
1007
- -------
1008
- AsyncHttpResponse[typing.List[Customer]]
1009
- Success response
1010
- """
1011
- _response = await self._client_wrapper.httpx_client.request(
1012
- "customers",
1013
- method="GET",
1014
- request_options=request_options,
1015
- )
1016
- try:
1017
- if 200 <= _response.status_code < 300:
1018
- _data = typing.cast(
1019
- typing.List[Customer],
1020
- parse_obj_as(
1021
- type_=typing.List[Customer], # type: ignore
1022
- object_=_response.json(),
1023
- ),
1024
- )
1025
- return AsyncHttpResponse(response=_response, data=_data)
1026
- _response_json = _response.json()
1027
- except JSONDecodeError:
1028
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1029
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1030
-
1031
- async def create(
877
+ async def create_customer(
1032
878
  self,
1033
879
  *,
1034
880
  name: str,
1035
- external_id: typing.Optional[str] = OMIT,
881
+ legal_name: typing.Optional[str] = OMIT,
882
+ email: typing.Optional[str] = OMIT,
1036
883
  phone: typing.Optional[str] = OMIT,
1037
- employee_count: typing.Optional[float] = OMIT,
1038
- annual_revenue: typing.Optional[float] = OMIT,
1039
- tax_exempt_status: typing.Optional[TaxExemptStatus] = OMIT,
1040
- creation_source: typing.Optional[CreationSource] = OMIT,
1041
884
  website: typing.Optional[str] = OMIT,
1042
- billing_address: typing.Optional[Address] = OMIT,
885
+ external_id: typing.Optional[str] = OMIT,
886
+ billing_address: typing.Optional[CustomerBillingAddress] = OMIT,
887
+ creation_state: typing.Optional[CustomerCreationState] = OMIT,
888
+ vat_number: typing.Optional[str] = OMIT,
1043
889
  metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
1044
- contacts: typing.Optional[typing.Sequence[ContactCreateForCustomer]] = OMIT,
1045
890
  request_options: typing.Optional[RequestOptions] = None,
1046
891
  ) -> AsyncHttpResponse[Customer]:
1047
892
  """
893
+ Creates a new customer for the organization
894
+
1048
895
  Parameters
1049
896
  ----------
1050
897
  name : str
1051
898
 
1052
- external_id : typing.Optional[str]
899
+ legal_name : typing.Optional[str]
1053
900
 
1054
- phone : typing.Optional[str]
901
+ email : typing.Optional[str]
1055
902
 
1056
- employee_count : typing.Optional[float]
1057
-
1058
- annual_revenue : typing.Optional[float]
1059
-
1060
- tax_exempt_status : typing.Optional[TaxExemptStatus]
1061
-
1062
- creation_source : typing.Optional[CreationSource]
903
+ phone : typing.Optional[str]
1063
904
 
1064
905
  website : typing.Optional[str]
1065
906
 
1066
- billing_address : typing.Optional[Address]
1067
-
1068
- metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
1069
- Flexible JSON field for storing custom metadata about the customer
1070
-
1071
- contacts : typing.Optional[typing.Sequence[ContactCreateForCustomer]]
1072
- Array of contacts to create for this customer
1073
-
1074
- request_options : typing.Optional[RequestOptions]
1075
- Request-specific configuration.
1076
-
1077
- Returns
1078
- -------
1079
- AsyncHttpResponse[Customer]
1080
- Success response - customer already exists with this externalId
1081
- """
1082
- _response = await self._client_wrapper.httpx_client.request(
1083
- "customers",
1084
- method="POST",
1085
- json={
1086
- "name": name,
1087
- "externalId": external_id,
1088
- "phone": phone,
1089
- "employeeCount": employee_count,
1090
- "annualRevenue": annual_revenue,
1091
- "taxExemptStatus": tax_exempt_status,
1092
- "creationSource": creation_source,
1093
- "website": website,
1094
- "billingAddress": convert_and_respect_annotation_metadata(
1095
- object_=billing_address, annotation=Address, direction="write"
1096
- ),
1097
- "metadata": metadata,
1098
- "contacts": convert_and_respect_annotation_metadata(
1099
- object_=contacts, annotation=typing.Sequence[ContactCreateForCustomer], direction="write"
1100
- ),
1101
- },
1102
- headers={
1103
- "content-type": "application/json",
1104
- },
1105
- request_options=request_options,
1106
- omit=OMIT,
1107
- )
1108
- try:
1109
- if 200 <= _response.status_code < 300:
1110
- _data = typing.cast(
1111
- Customer,
1112
- parse_obj_as(
1113
- type_=Customer, # type: ignore
1114
- object_=_response.json(),
1115
- ),
1116
- )
1117
- return AsyncHttpResponse(response=_response, data=_data)
1118
- _response_json = _response.json()
1119
- except JSONDecodeError:
1120
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1121
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1122
-
1123
- async def get(
1124
- self, customer_id: str, *, request_options: typing.Optional[RequestOptions] = None
1125
- ) -> AsyncHttpResponse[Customer]:
1126
- """
1127
- Parameters
1128
- ----------
1129
- customer_id : str
1130
-
1131
- request_options : typing.Optional[RequestOptions]
1132
- Request-specific configuration.
1133
-
1134
- Returns
1135
- -------
1136
- AsyncHttpResponse[Customer]
1137
- Success response
1138
- """
1139
- _response = await self._client_wrapper.httpx_client.request(
1140
- f"customers/{jsonable_encoder(customer_id)}",
1141
- method="GET",
1142
- request_options=request_options,
1143
- )
1144
- try:
1145
- if 200 <= _response.status_code < 300:
1146
- _data = typing.cast(
1147
- Customer,
1148
- parse_obj_as(
1149
- type_=Customer, # type: ignore
1150
- object_=_response.json(),
1151
- ),
1152
- )
1153
- return AsyncHttpResponse(response=_response, data=_data)
1154
- _response_json = _response.json()
1155
- except JSONDecodeError:
1156
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1157
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1158
-
1159
- async def update(
1160
- self,
1161
- customer_id: str,
1162
- *,
1163
- name: typing.Optional[str] = OMIT,
1164
- external_id: typing.Optional[str] = OMIT,
1165
- phone: typing.Optional[str] = OMIT,
1166
- employee_count: typing.Optional[float] = OMIT,
1167
- annual_revenue: typing.Optional[float] = OMIT,
1168
- tax_exempt_status: typing.Optional[TaxExemptStatus] = OMIT,
1169
- creation_source: typing.Optional[CreationSource] = OMIT,
1170
- website: typing.Optional[str] = OMIT,
1171
- billing_address: typing.Optional[Address] = OMIT,
1172
- metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
1173
- request_options: typing.Optional[RequestOptions] = None,
1174
- ) -> AsyncHttpResponse[Customer]:
1175
- """
1176
- Parameters
1177
- ----------
1178
- customer_id : str
1179
-
1180
- name : typing.Optional[str]
1181
-
1182
907
  external_id : typing.Optional[str]
1183
908
 
1184
- phone : typing.Optional[str]
1185
-
1186
- employee_count : typing.Optional[float]
1187
-
1188
- annual_revenue : typing.Optional[float]
909
+ billing_address : typing.Optional[CustomerBillingAddress]
1189
910
 
1190
- tax_exempt_status : typing.Optional[TaxExemptStatus]
1191
-
1192
- creation_source : typing.Optional[CreationSource]
1193
-
1194
- website : typing.Optional[str]
911
+ creation_state : typing.Optional[CustomerCreationState]
1195
912
 
1196
- billing_address : typing.Optional[Address]
913
+ vat_number : typing.Optional[str]
1197
914
 
1198
915
  metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
1199
- Flexible JSON field for storing custom metadata about the customer
1200
916
 
1201
917
  request_options : typing.Optional[RequestOptions]
1202
918
  Request-specific configuration.
@@ -1204,117 +920,37 @@ class AsyncRawCustomersClient:
1204
920
  Returns
1205
921
  -------
1206
922
  AsyncHttpResponse[Customer]
1207
- Customer updated successfully
923
+ 201
1208
924
  """
1209
925
  _response = await self._client_wrapper.httpx_client.request(
1210
- f"customers/{jsonable_encoder(customer_id)}",
1211
- method="PUT",
926
+ "customers/",
927
+ method="POST",
1212
928
  json={
1213
929
  "name": name,
1214
- "externalId": external_id,
930
+ "legalName": legal_name,
931
+ "email": email,
1215
932
  "phone": phone,
1216
- "employeeCount": employee_count,
1217
- "annualRevenue": annual_revenue,
1218
- "taxExemptStatus": tax_exempt_status,
1219
- "creationSource": creation_source,
1220
- "website": website,
1221
- "billingAddress": convert_and_respect_annotation_metadata(
1222
- object_=billing_address, annotation=Address, direction="write"
1223
- ),
1224
- "metadata": metadata,
1225
- },
1226
- headers={
1227
- "content-type": "application/json",
1228
- },
1229
- request_options=request_options,
1230
- omit=OMIT,
1231
- )
1232
- try:
1233
- if 200 <= _response.status_code < 300:
1234
- _data = typing.cast(
1235
- Customer,
1236
- parse_obj_as(
1237
- type_=Customer, # type: ignore
1238
- object_=_response.json(),
1239
- ),
1240
- )
1241
- return AsyncHttpResponse(response=_response, data=_data)
1242
- _response_json = _response.json()
1243
- except JSONDecodeError:
1244
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1245
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1246
-
1247
- async def delete(
1248
- self, customer_id: str, *, request_options: typing.Optional[RequestOptions] = None
1249
- ) -> AsyncHttpResponse[None]:
1250
- """
1251
- Parameters
1252
- ----------
1253
- customer_id : str
1254
-
1255
- request_options : typing.Optional[RequestOptions]
1256
- Request-specific configuration.
1257
-
1258
- Returns
1259
- -------
1260
- AsyncHttpResponse[None]
1261
- """
1262
- _response = await self._client_wrapper.httpx_client.request(
1263
- f"customers/{jsonable_encoder(customer_id)}",
1264
- method="DELETE",
1265
- request_options=request_options,
1266
- )
1267
- try:
1268
- if 200 <= _response.status_code < 300:
1269
- return AsyncHttpResponse(response=_response, data=None)
1270
- _response_json = _response.json()
1271
- except JSONDecodeError:
1272
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1273
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1274
-
1275
- async def check_entitlement(
1276
- self,
1277
- customer_id: str,
1278
- *,
1279
- event_name: str,
1280
- view: typing.Optional[CustomersCheckEntitlementRequestView] = None,
1281
- request_options: typing.Optional[RequestOptions] = None,
1282
- ) -> AsyncHttpResponse[CustomersCheckEntitlementResponse]:
1283
- """
1284
- Parameters
1285
- ----------
1286
- customer_id : str
1287
- The customer ID
1288
-
1289
- event_name : str
1290
- The name of the usage event to check entitlement for
1291
-
1292
- view : typing.Optional[CustomersCheckEntitlementRequestView]
1293
- Filter view - 'all' returns all entitlements regardless of status, 'active_only' returns only currently active entitlements with available credits
1294
-
1295
- request_options : typing.Optional[RequestOptions]
1296
- Request-specific configuration.
1297
-
1298
- Returns
1299
- -------
1300
- AsyncHttpResponse[CustomersCheckEntitlementResponse]
1301
- Success response
1302
- """
1303
- _response = await self._client_wrapper.httpx_client.request(
1304
- f"customers/{jsonable_encoder(customer_id)}/entitlement",
1305
- method="GET",
1306
- params={
1307
- "event_name": event_name,
1308
- "view": view,
933
+ "website": website,
934
+ "externalId": external_id,
935
+ "billingAddress": convert_and_respect_annotation_metadata(
936
+ object_=billing_address, annotation=typing.Optional[CustomerBillingAddress], direction="write"
937
+ ),
938
+ "creationState": creation_state,
939
+ "vatNumber": vat_number,
940
+ "metadata": metadata,
941
+ },
942
+ headers={
943
+ "content-type": "application/json",
1309
944
  },
1310
945
  request_options=request_options,
946
+ omit=OMIT,
1311
947
  )
1312
948
  try:
1313
949
  if 200 <= _response.status_code < 300:
1314
950
  _data = typing.cast(
1315
- CustomersCheckEntitlementResponse,
951
+ Customer,
1316
952
  parse_obj_as(
1317
- type_=CustomersCheckEntitlementResponse, # type: ignore
953
+ type_=Customer, # type: ignore
1318
954
  object_=_response.json(),
1319
955
  ),
1320
956
  )
@@ -1323,68 +959,31 @@ class AsyncRawCustomersClient:
1323
959
  raise BadRequestError(
1324
960
  headers=dict(_response.headers),
1325
961
  body=typing.cast(
1326
- Error,
962
+ ErrorResponse,
1327
963
  parse_obj_as(
1328
- type_=Error, # type: ignore
964
+ type_=ErrorResponse, # type: ignore
1329
965
  object_=_response.json(),
1330
966
  ),
1331
967
  ),
1332
968
  )
1333
- if _response.status_code == 404:
1334
- raise NotFoundError(
969
+ if _response.status_code == 403:
970
+ raise ForbiddenError(
1335
971
  headers=dict(_response.headers),
1336
972
  body=typing.cast(
1337
- Error,
973
+ ErrorResponse,
1338
974
  parse_obj_as(
1339
- type_=Error, # type: ignore
975
+ type_=ErrorResponse, # type: ignore
1340
976
  object_=_response.json(),
1341
977
  ),
1342
978
  ),
1343
979
  )
1344
- _response_json = _response.json()
1345
- except JSONDecodeError:
1346
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1347
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1348
-
1349
- async def get_entitlements(
1350
- self, customer_id: str, *, request_options: typing.Optional[RequestOptions] = None
1351
- ) -> AsyncHttpResponse[typing.List[EntitlementUsage]]:
1352
- """
1353
- Parameters
1354
- ----------
1355
- customer_id : str
1356
- The customer ID
1357
-
1358
- request_options : typing.Optional[RequestOptions]
1359
- Request-specific configuration.
1360
-
1361
- Returns
1362
- -------
1363
- AsyncHttpResponse[typing.List[EntitlementUsage]]
1364
- Success response
1365
- """
1366
- _response = await self._client_wrapper.httpx_client.request(
1367
- f"customers/{jsonable_encoder(customer_id)}/credit-bundles",
1368
- method="GET",
1369
- request_options=request_options,
1370
- )
1371
- try:
1372
- if 200 <= _response.status_code < 300:
1373
- _data = typing.cast(
1374
- typing.List[EntitlementUsage],
1375
- parse_obj_as(
1376
- type_=typing.List[EntitlementUsage], # type: ignore
1377
- object_=_response.json(),
1378
- ),
1379
- )
1380
- return AsyncHttpResponse(response=_response, data=_data)
1381
- if _response.status_code == 403:
1382
- raise ForbiddenError(
980
+ if _response.status_code == 500:
981
+ raise InternalServerError(
1383
982
  headers=dict(_response.headers),
1384
983
  body=typing.cast(
1385
- Error,
984
+ ErrorResponse,
1386
985
  parse_obj_as(
1387
- type_=Error, # type: ignore
986
+ type_=ErrorResponse, # type: ignore
1388
987
  object_=_response.json(),
1389
988
  ),
1390
989
  ),
@@ -1394,13 +993,15 @@ class AsyncRawCustomersClient:
1394
993
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1395
994
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1396
995
 
1397
- async def get_by_external_id(
1398
- self, external_id: str, *, request_options: typing.Optional[RequestOptions] = None
996
+ async def get_customer_by_id(
997
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1399
998
  ) -> AsyncHttpResponse[Customer]:
1400
999
  """
1000
+ Get a customer by ID
1001
+
1401
1002
  Parameters
1402
1003
  ----------
1403
- external_id : str
1004
+ id : str
1404
1005
 
1405
1006
  request_options : typing.Optional[RequestOptions]
1406
1007
  Request-specific configuration.
@@ -1408,10 +1009,10 @@ class AsyncRawCustomersClient:
1408
1009
  Returns
1409
1010
  -------
1410
1011
  AsyncHttpResponse[Customer]
1411
- Success response
1012
+ 200
1412
1013
  """
1413
1014
  _response = await self._client_wrapper.httpx_client.request(
1414
- f"customers/external/{jsonable_encoder(external_id)}",
1015
+ f"customers/{jsonable_encoder(id)}",
1415
1016
  method="GET",
1416
1017
  request_options=request_options,
1417
1018
  )
@@ -1425,52 +1026,89 @@ class AsyncRawCustomersClient:
1425
1026
  ),
1426
1027
  )
1427
1028
  return AsyncHttpResponse(response=_response, data=_data)
1029
+ if _response.status_code == 403:
1030
+ raise ForbiddenError(
1031
+ headers=dict(_response.headers),
1032
+ body=typing.cast(
1033
+ ErrorResponse,
1034
+ parse_obj_as(
1035
+ type_=ErrorResponse, # type: ignore
1036
+ object_=_response.json(),
1037
+ ),
1038
+ ),
1039
+ )
1040
+ if _response.status_code == 404:
1041
+ raise NotFoundError(
1042
+ headers=dict(_response.headers),
1043
+ body=typing.cast(
1044
+ ErrorResponse,
1045
+ parse_obj_as(
1046
+ type_=ErrorResponse, # type: ignore
1047
+ object_=_response.json(),
1048
+ ),
1049
+ ),
1050
+ )
1051
+ if _response.status_code == 500:
1052
+ raise InternalServerError(
1053
+ headers=dict(_response.headers),
1054
+ body=typing.cast(
1055
+ ErrorResponse,
1056
+ parse_obj_as(
1057
+ type_=ErrorResponse, # type: ignore
1058
+ object_=_response.json(),
1059
+ ),
1060
+ ),
1061
+ )
1428
1062
  _response_json = _response.json()
1429
1063
  except JSONDecodeError:
1430
1064
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1431
1065
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1432
1066
 
1433
- async def update_by_external_id(
1067
+ async def update_customer_by_id(
1434
1068
  self,
1435
- external_id_: str,
1069
+ id: str,
1436
1070
  *,
1437
1071
  name: typing.Optional[str] = OMIT,
1438
- external_id: typing.Optional[str] = OMIT,
1072
+ legal_name: typing.Optional[str] = OMIT,
1073
+ email: typing.Optional[str] = OMIT,
1439
1074
  phone: typing.Optional[str] = OMIT,
1440
- employee_count: typing.Optional[float] = OMIT,
1441
- annual_revenue: typing.Optional[float] = OMIT,
1442
- tax_exempt_status: typing.Optional[TaxExemptStatus] = OMIT,
1443
- creation_source: typing.Optional[CreationSource] = OMIT,
1444
1075
  website: typing.Optional[str] = OMIT,
1445
- billing_address: typing.Optional[Address] = OMIT,
1076
+ external_id: typing.Optional[str] = OMIT,
1077
+ billing_address: typing.Optional[CustomerBillingAddress] = OMIT,
1078
+ creation_state: typing.Optional[CustomerCreationState] = OMIT,
1079
+ churn_date: typing.Optional[dt.datetime] = OMIT,
1080
+ vat_number: typing.Optional[str] = OMIT,
1446
1081
  metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
1447
1082
  request_options: typing.Optional[RequestOptions] = None,
1448
1083
  ) -> AsyncHttpResponse[Customer]:
1449
1084
  """
1085
+ Update a customer by ID
1086
+
1450
1087
  Parameters
1451
1088
  ----------
1452
- external_id_ : str
1089
+ id : str
1453
1090
 
1454
1091
  name : typing.Optional[str]
1455
1092
 
1456
- external_id : typing.Optional[str]
1093
+ legal_name : typing.Optional[str]
1094
+
1095
+ email : typing.Optional[str]
1457
1096
 
1458
1097
  phone : typing.Optional[str]
1459
1098
 
1460
- employee_count : typing.Optional[float]
1099
+ website : typing.Optional[str]
1461
1100
 
1462
- annual_revenue : typing.Optional[float]
1101
+ external_id : typing.Optional[str]
1463
1102
 
1464
- tax_exempt_status : typing.Optional[TaxExemptStatus]
1103
+ billing_address : typing.Optional[CustomerBillingAddress]
1465
1104
 
1466
- creation_source : typing.Optional[CreationSource]
1105
+ creation_state : typing.Optional[CustomerCreationState]
1467
1106
 
1468
- website : typing.Optional[str]
1107
+ churn_date : typing.Optional[dt.datetime]
1469
1108
 
1470
- billing_address : typing.Optional[Address]
1109
+ vat_number : typing.Optional[str]
1471
1110
 
1472
1111
  metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
1473
- Flexible JSON field for storing custom metadata about the customer
1474
1112
 
1475
1113
  request_options : typing.Optional[RequestOptions]
1476
1114
  Request-specific configuration.
@@ -1478,23 +1116,24 @@ class AsyncRawCustomersClient:
1478
1116
  Returns
1479
1117
  -------
1480
1118
  AsyncHttpResponse[Customer]
1481
- Success response
1119
+ 200
1482
1120
  """
1483
1121
  _response = await self._client_wrapper.httpx_client.request(
1484
- f"customers/external/{jsonable_encoder(external_id_)}",
1122
+ f"customers/{jsonable_encoder(id)}",
1485
1123
  method="PUT",
1486
1124
  json={
1487
1125
  "name": name,
1488
- "externalId": external_id,
1126
+ "legalName": legal_name,
1127
+ "email": email,
1489
1128
  "phone": phone,
1490
- "employeeCount": employee_count,
1491
- "annualRevenue": annual_revenue,
1492
- "taxExemptStatus": tax_exempt_status,
1493
- "creationSource": creation_source,
1494
1129
  "website": website,
1130
+ "externalId": external_id,
1495
1131
  "billingAddress": convert_and_respect_annotation_metadata(
1496
- object_=billing_address, annotation=Address, direction="write"
1132
+ object_=billing_address, annotation=typing.Optional[CustomerBillingAddress], direction="write"
1497
1133
  ),
1134
+ "creationState": creation_state,
1135
+ "churnDate": churn_date,
1136
+ "vatNumber": vat_number,
1498
1137
  "metadata": metadata,
1499
1138
  },
1500
1139
  headers={
@@ -1513,103 +1152,13 @@ class AsyncRawCustomersClient:
1513
1152
  ),
1514
1153
  )
1515
1154
  return AsyncHttpResponse(response=_response, data=_data)
1516
- _response_json = _response.json()
1517
- except JSONDecodeError:
1518
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1519
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1520
-
1521
- async def delete_by_external_id(
1522
- self, external_id: str, *, request_options: typing.Optional[RequestOptions] = None
1523
- ) -> AsyncHttpResponse[None]:
1524
- """
1525
- Parameters
1526
- ----------
1527
- external_id : str
1528
-
1529
- request_options : typing.Optional[RequestOptions]
1530
- Request-specific configuration.
1531
-
1532
- Returns
1533
- -------
1534
- AsyncHttpResponse[None]
1535
- """
1536
- _response = await self._client_wrapper.httpx_client.request(
1537
- f"customers/external/{jsonable_encoder(external_id)}",
1538
- method="DELETE",
1539
- request_options=request_options,
1540
- )
1541
- try:
1542
- if 200 <= _response.status_code < 300:
1543
- return AsyncHttpResponse(response=_response, data=None)
1544
- _response_json = _response.json()
1545
- except JSONDecodeError:
1546
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1547
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1548
-
1549
- async def get_costs_by_external_id(
1550
- self,
1551
- external_id: str,
1552
- *,
1553
- limit: typing.Optional[int] = None,
1554
- offset: typing.Optional[int] = None,
1555
- start_time: typing.Optional[dt.datetime] = None,
1556
- end_time: typing.Optional[dt.datetime] = None,
1557
- request_options: typing.Optional[RequestOptions] = None,
1558
- ) -> AsyncHttpResponse[CostTracesResponse]:
1559
- """
1560
- Parameters
1561
- ----------
1562
- external_id : str
1563
- The external ID of the customer
1564
-
1565
- limit : typing.Optional[int]
1566
- Maximum number of traces to return (1-1000)
1567
-
1568
- offset : typing.Optional[int]
1569
- Number of traces to skip for pagination
1570
-
1571
- start_time : typing.Optional[dt.datetime]
1572
- Filter traces starting from this time (ISO 8601 format)
1573
-
1574
- end_time : typing.Optional[dt.datetime]
1575
- Filter traces up to this time (ISO 8601 format)
1576
-
1577
- request_options : typing.Optional[RequestOptions]
1578
- Request-specific configuration.
1579
-
1580
- Returns
1581
- -------
1582
- AsyncHttpResponse[CostTracesResponse]
1583
- Success response
1584
- """
1585
- _response = await self._client_wrapper.httpx_client.request(
1586
- f"customers/external/{jsonable_encoder(external_id)}/costs",
1587
- method="GET",
1588
- params={
1589
- "limit": limit,
1590
- "offset": offset,
1591
- "startTime": serialize_datetime(start_time) if start_time is not None else None,
1592
- "endTime": serialize_datetime(end_time) if end_time is not None else None,
1593
- },
1594
- request_options=request_options,
1595
- )
1596
- try:
1597
- if 200 <= _response.status_code < 300:
1598
- _data = typing.cast(
1599
- CostTracesResponse,
1600
- parse_obj_as(
1601
- type_=CostTracesResponse, # type: ignore
1602
- object_=_response.json(),
1603
- ),
1604
- )
1605
- return AsyncHttpResponse(response=_response, data=_data)
1606
1155
  if _response.status_code == 400:
1607
1156
  raise BadRequestError(
1608
1157
  headers=dict(_response.headers),
1609
1158
  body=typing.cast(
1610
- Error,
1159
+ ErrorResponse,
1611
1160
  parse_obj_as(
1612
- type_=Error, # type: ignore
1161
+ type_=ErrorResponse, # type: ignore
1613
1162
  object_=_response.json(),
1614
1163
  ),
1615
1164
  ),
@@ -1618,9 +1167,9 @@ class AsyncRawCustomersClient:
1618
1167
  raise ForbiddenError(
1619
1168
  headers=dict(_response.headers),
1620
1169
  body=typing.cast(
1621
- Error,
1170
+ ErrorResponse,
1622
1171
  parse_obj_as(
1623
- type_=Error, # type: ignore
1172
+ type_=ErrorResponse, # type: ignore
1624
1173
  object_=_response.json(),
1625
1174
  ),
1626
1175
  ),
@@ -1629,9 +1178,20 @@ class AsyncRawCustomersClient:
1629
1178
  raise NotFoundError(
1630
1179
  headers=dict(_response.headers),
1631
1180
  body=typing.cast(
1632
- Error,
1181
+ ErrorResponse,
1182
+ parse_obj_as(
1183
+ type_=ErrorResponse, # type: ignore
1184
+ object_=_response.json(),
1185
+ ),
1186
+ ),
1187
+ )
1188
+ if _response.status_code == 500:
1189
+ raise InternalServerError(
1190
+ headers=dict(_response.headers),
1191
+ body=typing.cast(
1192
+ ErrorResponse,
1633
1193
  parse_obj_as(
1634
- type_=Error, # type: ignore
1194
+ type_=ErrorResponse, # type: ignore
1635
1195
  object_=_response.json(),
1636
1196
  ),
1637
1197
  ),
@@ -1641,92 +1201,68 @@ class AsyncRawCustomersClient:
1641
1201
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1642
1202
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1643
1203
 
1644
- async def get_usage_by_external_id(
1645
- self,
1646
- external_id: str,
1647
- *,
1648
- limit: typing.Optional[int] = None,
1649
- offset: typing.Optional[int] = None,
1650
- start_time: typing.Optional[dt.datetime] = None,
1651
- end_time: typing.Optional[dt.datetime] = None,
1652
- request_options: typing.Optional[RequestOptions] = None,
1653
- ) -> AsyncHttpResponse[UsageSummariesResponse]:
1204
+ async def delete_customer_by_id(
1205
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1206
+ ) -> AsyncHttpResponse[EmptyResponse]:
1654
1207
  """
1208
+ Delete a customer by ID
1209
+
1655
1210
  Parameters
1656
1211
  ----------
1657
- external_id : str
1658
- The external ID of the customer
1659
-
1660
- limit : typing.Optional[int]
1661
- Maximum number of usage summaries to return (1-1000)
1662
-
1663
- offset : typing.Optional[int]
1664
- Number of usage summaries to skip for pagination
1665
-
1666
- start_time : typing.Optional[dt.datetime]
1667
- Filter usage summaries starting from this time (ISO 8601 format). Returns summaries that overlap with the time range.
1668
-
1669
- end_time : typing.Optional[dt.datetime]
1670
- Filter usage summaries up to this time (ISO 8601 format). Returns summaries that overlap with the time range.
1212
+ id : str
1671
1213
 
1672
1214
  request_options : typing.Optional[RequestOptions]
1673
1215
  Request-specific configuration.
1674
1216
 
1675
1217
  Returns
1676
1218
  -------
1677
- AsyncHttpResponse[UsageSummariesResponse]
1678
- Success response
1219
+ AsyncHttpResponse[EmptyResponse]
1220
+ 200
1679
1221
  """
1680
1222
  _response = await self._client_wrapper.httpx_client.request(
1681
- f"customers/external/{jsonable_encoder(external_id)}/usage",
1682
- method="GET",
1683
- params={
1684
- "limit": limit,
1685
- "offset": offset,
1686
- "startTime": serialize_datetime(start_time) if start_time is not None else None,
1687
- "endTime": serialize_datetime(end_time) if end_time is not None else None,
1688
- },
1223
+ f"customers/{jsonable_encoder(id)}",
1224
+ method="DELETE",
1689
1225
  request_options=request_options,
1690
1226
  )
1691
1227
  try:
1692
1228
  if 200 <= _response.status_code < 300:
1693
1229
  _data = typing.cast(
1694
- UsageSummariesResponse,
1230
+ EmptyResponse,
1695
1231
  parse_obj_as(
1696
- type_=UsageSummariesResponse, # type: ignore
1232
+ type_=EmptyResponse, # type: ignore
1697
1233
  object_=_response.json(),
1698
1234
  ),
1699
1235
  )
1700
1236
  return AsyncHttpResponse(response=_response, data=_data)
1701
- if _response.status_code == 400:
1702
- raise BadRequestError(
1237
+ if _response.status_code == 403:
1238
+ raise ForbiddenError(
1703
1239
  headers=dict(_response.headers),
1704
1240
  body=typing.cast(
1705
- Error,
1241
+ ErrorResponse,
1706
1242
  parse_obj_as(
1707
- type_=Error, # type: ignore
1243
+ type_=ErrorResponse, # type: ignore
1708
1244
  object_=_response.json(),
1709
1245
  ),
1710
1246
  ),
1711
1247
  )
1712
- if _response.status_code == 403:
1713
- raise ForbiddenError(
1248
+ if _response.status_code == 404:
1249
+ raise NotFoundError(
1714
1250
  headers=dict(_response.headers),
1715
1251
  body=typing.cast(
1716
- Error,
1252
+ ErrorResponse,
1717
1253
  parse_obj_as(
1718
- type_=Error, # type: ignore
1254
+ type_=ErrorResponse, # type: ignore
1719
1255
  object_=_response.json(),
1720
1256
  ),
1721
1257
  ),
1722
1258
  )
1723
- if _response.status_code == 404:
1724
- raise NotFoundError(
1259
+ if _response.status_code == 500:
1260
+ raise InternalServerError(
1725
1261
  headers=dict(_response.headers),
1726
1262
  body=typing.cast(
1727
- Error,
1263
+ ErrorResponse,
1728
1264
  parse_obj_as(
1729
- type_=Error, # type: ignore
1265
+ type_=ErrorResponse, # type: ignore
1730
1266
  object_=_response.json(),
1731
1267
  ),
1732
1268
  ),
@@ -1736,36 +1272,35 @@ class AsyncRawCustomersClient:
1736
1272
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1737
1273
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1738
1274
 
1739
- async def list_payment_methods(
1275
+ async def get_customer_by_external_id(
1740
1276
  self, external_id: str, *, request_options: typing.Optional[RequestOptions] = None
1741
- ) -> AsyncHttpResponse[typing.List[PaymentMethod]]:
1277
+ ) -> AsyncHttpResponse[Customer]:
1742
1278
  """
1743
- Retrieves all payment methods associated with a customer identified by their external ID.
1279
+ Get a customer by external ID
1744
1280
 
1745
1281
  Parameters
1746
1282
  ----------
1747
1283
  external_id : str
1748
- The external ID of the customer
1749
1284
 
1750
1285
  request_options : typing.Optional[RequestOptions]
1751
1286
  Request-specific configuration.
1752
1287
 
1753
1288
  Returns
1754
1289
  -------
1755
- AsyncHttpResponse[typing.List[PaymentMethod]]
1756
- Success response
1290
+ AsyncHttpResponse[Customer]
1291
+ 200
1757
1292
  """
1758
1293
  _response = await self._client_wrapper.httpx_client.request(
1759
- f"customers/external/{jsonable_encoder(external_id)}/payment-methods",
1294
+ f"customers/external/{jsonable_encoder(external_id)}",
1760
1295
  method="GET",
1761
1296
  request_options=request_options,
1762
1297
  )
1763
1298
  try:
1764
1299
  if 200 <= _response.status_code < 300:
1765
1300
  _data = typing.cast(
1766
- typing.List[PaymentMethod],
1301
+ Customer,
1767
1302
  parse_obj_as(
1768
- type_=typing.List[PaymentMethod], # type: ignore
1303
+ type_=Customer, # type: ignore
1769
1304
  object_=_response.json(),
1770
1305
  ),
1771
1306
  )
@@ -1774,9 +1309,9 @@ class AsyncRawCustomersClient:
1774
1309
  raise ForbiddenError(
1775
1310
  headers=dict(_response.headers),
1776
1311
  body=typing.cast(
1777
- Error,
1312
+ ErrorResponse,
1778
1313
  parse_obj_as(
1779
- type_=Error, # type: ignore
1314
+ type_=ErrorResponse, # type: ignore
1780
1315
  object_=_response.json(),
1781
1316
  ),
1782
1317
  ),
@@ -1785,9 +1320,20 @@ class AsyncRawCustomersClient:
1785
1320
  raise NotFoundError(
1786
1321
  headers=dict(_response.headers),
1787
1322
  body=typing.cast(
1788
- Error,
1323
+ ErrorResponse,
1324
+ parse_obj_as(
1325
+ type_=ErrorResponse, # type: ignore
1326
+ object_=_response.json(),
1327
+ ),
1328
+ ),
1329
+ )
1330
+ if _response.status_code == 500:
1331
+ raise InternalServerError(
1332
+ headers=dict(_response.headers),
1333
+ body=typing.cast(
1334
+ ErrorResponse,
1789
1335
  parse_obj_as(
1790
- type_=Error, # type: ignore
1336
+ type_=ErrorResponse, # type: ignore
1791
1337
  object_=_response.json(),
1792
1338
  ),
1793
1339
  ),
@@ -1797,46 +1343,76 @@ class AsyncRawCustomersClient:
1797
1343
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1798
1344
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1799
1345
 
1800
- async def create_payment_method(
1346
+ async def update_customer_by_external_id(
1801
1347
  self,
1802
- external_id: str,
1348
+ external_id_: str,
1803
1349
  *,
1804
- confirmation_token: str,
1805
- return_url: str,
1350
+ name: typing.Optional[str] = OMIT,
1351
+ legal_name: typing.Optional[str] = OMIT,
1352
+ email: typing.Optional[str] = OMIT,
1353
+ phone: typing.Optional[str] = OMIT,
1354
+ website: typing.Optional[str] = OMIT,
1355
+ external_id: typing.Optional[str] = OMIT,
1356
+ billing_address: typing.Optional[CustomerBillingAddress] = OMIT,
1357
+ creation_state: typing.Optional[CustomerCreationState] = OMIT,
1358
+ churn_date: typing.Optional[dt.datetime] = OMIT,
1359
+ vat_number: typing.Optional[str] = OMIT,
1806
1360
  metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
1807
1361
  request_options: typing.Optional[RequestOptions] = None,
1808
- ) -> AsyncHttpResponse[PaymentMethod]:
1362
+ ) -> AsyncHttpResponse[Customer]:
1809
1363
  """
1810
- Creates a new payment method for a customer using a Stripe confirmation token.
1364
+ Update a customer by external ID
1811
1365
 
1812
1366
  Parameters
1813
1367
  ----------
1814
- external_id : str
1815
- The external ID of the customer
1368
+ external_id_ : str
1369
+
1370
+ name : typing.Optional[str]
1371
+
1372
+ legal_name : typing.Optional[str]
1373
+
1374
+ email : typing.Optional[str]
1375
+
1376
+ phone : typing.Optional[str]
1377
+
1378
+ website : typing.Optional[str]
1379
+
1380
+ external_id : typing.Optional[str]
1381
+
1382
+ billing_address : typing.Optional[CustomerBillingAddress]
1816
1383
 
1817
- confirmation_token : str
1818
- Stripe confirmation token for the payment method
1384
+ creation_state : typing.Optional[CustomerCreationState]
1819
1385
 
1820
- return_url : str
1821
- URL to redirect to after payment method setup
1386
+ churn_date : typing.Optional[dt.datetime]
1387
+
1388
+ vat_number : typing.Optional[str]
1822
1389
 
1823
1390
  metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
1824
- Optional metadata to attach to the payment method
1825
1391
 
1826
1392
  request_options : typing.Optional[RequestOptions]
1827
1393
  Request-specific configuration.
1828
1394
 
1829
1395
  Returns
1830
1396
  -------
1831
- AsyncHttpResponse[PaymentMethod]
1832
- Payment method created successfully
1397
+ AsyncHttpResponse[Customer]
1398
+ 200
1833
1399
  """
1834
1400
  _response = await self._client_wrapper.httpx_client.request(
1835
- f"customers/external/{jsonable_encoder(external_id)}/payment-methods",
1836
- method="POST",
1401
+ f"customers/external/{jsonable_encoder(external_id_)}",
1402
+ method="PUT",
1837
1403
  json={
1838
- "confirmationToken": confirmation_token,
1839
- "returnUrl": return_url,
1404
+ "name": name,
1405
+ "legalName": legal_name,
1406
+ "email": email,
1407
+ "phone": phone,
1408
+ "website": website,
1409
+ "externalId": external_id,
1410
+ "billingAddress": convert_and_respect_annotation_metadata(
1411
+ object_=billing_address, annotation=typing.Optional[CustomerBillingAddress], direction="write"
1412
+ ),
1413
+ "creationState": creation_state,
1414
+ "churnDate": churn_date,
1415
+ "vatNumber": vat_number,
1840
1416
  "metadata": metadata,
1841
1417
  },
1842
1418
  headers={
@@ -1848,9 +1424,9 @@ class AsyncRawCustomersClient:
1848
1424
  try:
1849
1425
  if 200 <= _response.status_code < 300:
1850
1426
  _data = typing.cast(
1851
- PaymentMethod,
1427
+ Customer,
1852
1428
  parse_obj_as(
1853
- type_=PaymentMethod, # type: ignore
1429
+ type_=Customer, # type: ignore
1854
1430
  object_=_response.json(),
1855
1431
  ),
1856
1432
  )
@@ -1859,9 +1435,9 @@ class AsyncRawCustomersClient:
1859
1435
  raise BadRequestError(
1860
1436
  headers=dict(_response.headers),
1861
1437
  body=typing.cast(
1862
- Error,
1438
+ ErrorResponse,
1863
1439
  parse_obj_as(
1864
- type_=Error, # type: ignore
1440
+ type_=ErrorResponse, # type: ignore
1865
1441
  object_=_response.json(),
1866
1442
  ),
1867
1443
  ),
@@ -1870,9 +1446,9 @@ class AsyncRawCustomersClient:
1870
1446
  raise ForbiddenError(
1871
1447
  headers=dict(_response.headers),
1872
1448
  body=typing.cast(
1873
- Error,
1449
+ ErrorResponse,
1874
1450
  parse_obj_as(
1875
- type_=Error, # type: ignore
1451
+ type_=ErrorResponse, # type: ignore
1876
1452
  object_=_response.json(),
1877
1453
  ),
1878
1454
  ),
@@ -1881,9 +1457,20 @@ class AsyncRawCustomersClient:
1881
1457
  raise NotFoundError(
1882
1458
  headers=dict(_response.headers),
1883
1459
  body=typing.cast(
1884
- Error,
1460
+ ErrorResponse,
1461
+ parse_obj_as(
1462
+ type_=ErrorResponse, # type: ignore
1463
+ object_=_response.json(),
1464
+ ),
1465
+ ),
1466
+ )
1467
+ if _response.status_code == 500:
1468
+ raise InternalServerError(
1469
+ headers=dict(_response.headers),
1470
+ body=typing.cast(
1471
+ ErrorResponse,
1885
1472
  parse_obj_as(
1886
- type_=Error, # type: ignore
1473
+ type_=ErrorResponse, # type: ignore
1887
1474
  object_=_response.json(),
1888
1475
  ),
1889
1476
  ),
@@ -1893,42 +1480,46 @@ class AsyncRawCustomersClient:
1893
1480
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1894
1481
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1895
1482
 
1896
- async def delete_payment_method(
1897
- self, external_id: str, payment_method_id: str, *, request_options: typing.Optional[RequestOptions] = None
1898
- ) -> AsyncHttpResponse[None]:
1483
+ async def delete_customer_by_external_id(
1484
+ self, external_id: str, *, request_options: typing.Optional[RequestOptions] = None
1485
+ ) -> AsyncHttpResponse[EmptyResponse]:
1899
1486
  """
1900
- Deletes a specific payment method from a customer's account.
1487
+ Delete a customer by external ID
1901
1488
 
1902
1489
  Parameters
1903
1490
  ----------
1904
1491
  external_id : str
1905
- The external ID of the customer
1906
-
1907
- payment_method_id : str
1908
- The ID of the payment method to delete
1909
1492
 
1910
1493
  request_options : typing.Optional[RequestOptions]
1911
1494
  Request-specific configuration.
1912
1495
 
1913
1496
  Returns
1914
1497
  -------
1915
- AsyncHttpResponse[None]
1498
+ AsyncHttpResponse[EmptyResponse]
1499
+ 200
1916
1500
  """
1917
1501
  _response = await self._client_wrapper.httpx_client.request(
1918
- f"customers/external/{jsonable_encoder(external_id)}/payment-methods/{jsonable_encoder(payment_method_id)}",
1502
+ f"customers/external/{jsonable_encoder(external_id)}",
1919
1503
  method="DELETE",
1920
1504
  request_options=request_options,
1921
1505
  )
1922
1506
  try:
1923
1507
  if 200 <= _response.status_code < 300:
1924
- return AsyncHttpResponse(response=_response, data=None)
1508
+ _data = typing.cast(
1509
+ EmptyResponse,
1510
+ parse_obj_as(
1511
+ type_=EmptyResponse, # type: ignore
1512
+ object_=_response.json(),
1513
+ ),
1514
+ )
1515
+ return AsyncHttpResponse(response=_response, data=_data)
1925
1516
  if _response.status_code == 403:
1926
1517
  raise ForbiddenError(
1927
1518
  headers=dict(_response.headers),
1928
1519
  body=typing.cast(
1929
- Error,
1520
+ ErrorResponse,
1930
1521
  parse_obj_as(
1931
- type_=Error, # type: ignore
1522
+ type_=ErrorResponse, # type: ignore
1932
1523
  object_=_response.json(),
1933
1524
  ),
1934
1525
  ),
@@ -1937,9 +1528,20 @@ class AsyncRawCustomersClient:
1937
1528
  raise NotFoundError(
1938
1529
  headers=dict(_response.headers),
1939
1530
  body=typing.cast(
1940
- Error,
1531
+ ErrorResponse,
1532
+ parse_obj_as(
1533
+ type_=ErrorResponse, # type: ignore
1534
+ object_=_response.json(),
1535
+ ),
1536
+ ),
1537
+ )
1538
+ if _response.status_code == 500:
1539
+ raise InternalServerError(
1540
+ headers=dict(_response.headers),
1541
+ body=typing.cast(
1542
+ ErrorResponse,
1941
1543
  parse_obj_as(
1942
- type_=Error, # type: ignore
1544
+ type_=ErrorResponse, # type: ignore
1943
1545
  object_=_response.json(),
1944
1546
  ),
1945
1547
  ),