paid-python 0.5.0__py3-none-any.whl → 1.0.0a0__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.
- paid/__init__.py +33 -0
- paid/client.py +1 -472
- paid/core/client_wrapper.py +3 -2
- paid/customers/__init__.py +3 -0
- paid/customers/client.py +428 -4
- paid/customers/raw_client.py +594 -2
- paid/customers/types/__init__.py +8 -0
- paid/customers/types/customers_check_entitlement_request_view.py +5 -0
- paid/customers/types/customers_check_entitlement_response.py +22 -0
- paid/orders/client.py +445 -0
- paid/orders/raw_client.py +705 -0
- paid/plans/client.py +142 -0
- paid/plans/raw_client.py +238 -0
- paid/types/__init__.py +30 -0
- paid/types/cancel_renewal_response.py +49 -0
- paid/types/contact_create_for_customer.py +37 -0
- paid/types/invoice.py +75 -0
- paid/types/invoice_status.py +5 -0
- paid/types/payment_method.py +58 -0
- paid/types/payment_method_card.py +49 -0
- paid/types/payment_method_type.py +5 -0
- paid/types/payment_method_us_bank_account.py +36 -0
- paid/types/payment_method_us_bank_account_account_type.py +5 -0
- paid/types/plan_group.py +60 -0
- paid/types/plan_plan_products_item.py +6 -0
- paid/types/plan_with_features.py +69 -0
- paid/types/plan_with_features_features_item.py +34 -0
- paid/types/proration_attribute_update.py +44 -0
- paid/types/proration_detail.py +49 -0
- paid/types/proration_upgrade_response.py +73 -0
- paid/types/signal_v_2.py +5 -5
- paid/usage/client.py +6 -6
- {paid_python-0.5.0.dist-info → paid_python-1.0.0a0.dist-info}/METADATA +6 -4
- {paid_python-0.5.0.dist-info → paid_python-1.0.0a0.dist-info}/RECORD +36 -36
- opentelemetry/instrumentation/openai/__init__.py +0 -54
- opentelemetry/instrumentation/openai/shared/__init__.py +0 -399
- opentelemetry/instrumentation/openai/shared/audio_wrappers.py +0 -247
- opentelemetry/instrumentation/openai/shared/chat_wrappers.py +0 -1192
- opentelemetry/instrumentation/openai/shared/completion_wrappers.py +0 -292
- opentelemetry/instrumentation/openai/shared/config.py +0 -15
- opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py +0 -311
- opentelemetry/instrumentation/openai/shared/event_emitter.py +0 -108
- opentelemetry/instrumentation/openai/shared/event_models.py +0 -41
- opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py +0 -68
- opentelemetry/instrumentation/openai/shared/span_utils.py +0 -0
- opentelemetry/instrumentation/openai/utils.py +0 -213
- opentelemetry/instrumentation/openai/v0/__init__.py +0 -176
- opentelemetry/instrumentation/openai/v1/__init__.py +0 -394
- opentelemetry/instrumentation/openai/v1/assistant_wrappers.py +0 -329
- opentelemetry/instrumentation/openai/v1/event_handler_wrapper.py +0 -134
- opentelemetry/instrumentation/openai/v1/responses_wrappers.py +0 -1113
- opentelemetry/instrumentation/openai/version.py +0 -1
- {paid_python-0.5.0.dist-info → paid_python-1.0.0a0.dist-info}/LICENSE +0 -0
- {paid_python-0.5.0.dist-info → paid_python-1.0.0a0.dist-info}/WHEEL +0 -0
paid/orders/raw_client.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
+
import datetime as dt
|
|
3
4
|
import typing
|
|
4
5
|
from json.decoder import JSONDecodeError
|
|
5
6
|
|
|
@@ -10,8 +11,16 @@ from ..core.jsonable_encoder import jsonable_encoder
|
|
|
10
11
|
from ..core.pydantic_utilities import parse_obj_as
|
|
11
12
|
from ..core.request_options import RequestOptions
|
|
12
13
|
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
14
|
+
from ..errors.bad_request_error import BadRequestError
|
|
15
|
+
from ..errors.forbidden_error import ForbiddenError
|
|
16
|
+
from ..errors.not_found_error import NotFoundError
|
|
17
|
+
from ..types.cancel_renewal_response import CancelRenewalResponse
|
|
18
|
+
from ..types.error import Error
|
|
19
|
+
from ..types.invoice import Invoice
|
|
13
20
|
from ..types.order import Order
|
|
14
21
|
from ..types.order_line_create import OrderLineCreate
|
|
22
|
+
from ..types.proration_attribute_update import ProrationAttributeUpdate
|
|
23
|
+
from ..types.proration_upgrade_response import ProrationUpgradeResponse
|
|
15
24
|
|
|
16
25
|
# this is used as the default value for optional parameters
|
|
17
26
|
OMIT = typing.cast(typing.Any, ...)
|
|
@@ -64,6 +73,7 @@ class RawOrdersClient:
|
|
|
64
73
|
billing_contact_id: typing.Optional[str] = OMIT,
|
|
65
74
|
description: typing.Optional[str] = OMIT,
|
|
66
75
|
end_date: typing.Optional[str] = OMIT,
|
|
76
|
+
plan_id: typing.Optional[str] = OMIT,
|
|
67
77
|
order_lines: typing.Optional[typing.Sequence[OrderLineCreate]] = OMIT,
|
|
68
78
|
request_options: typing.Optional[RequestOptions] = None,
|
|
69
79
|
) -> HttpResponse[Order]:
|
|
@@ -86,6 +96,9 @@ class RawOrdersClient:
|
|
|
86
96
|
|
|
87
97
|
end_date : typing.Optional[str]
|
|
88
98
|
|
|
99
|
+
plan_id : typing.Optional[str]
|
|
100
|
+
Optional plan ID to associate with this order
|
|
101
|
+
|
|
89
102
|
order_lines : typing.Optional[typing.Sequence[OrderLineCreate]]
|
|
90
103
|
|
|
91
104
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -108,6 +121,7 @@ class RawOrdersClient:
|
|
|
108
121
|
"startDate": start_date,
|
|
109
122
|
"endDate": end_date,
|
|
110
123
|
"currency": currency,
|
|
124
|
+
"planId": plan_id,
|
|
111
125
|
"orderLines": convert_and_respect_annotation_metadata(
|
|
112
126
|
object_=order_lines, annotation=typing.Sequence[OrderLineCreate], direction="write"
|
|
113
127
|
),
|
|
@@ -229,6 +243,349 @@ class RawOrdersClient:
|
|
|
229
243
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
230
244
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
231
245
|
|
|
246
|
+
def activate_and_pay(
|
|
247
|
+
self,
|
|
248
|
+
order_id: str,
|
|
249
|
+
*,
|
|
250
|
+
confirmation_token: str,
|
|
251
|
+
return_url: str,
|
|
252
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
253
|
+
) -> HttpResponse[Order]:
|
|
254
|
+
"""
|
|
255
|
+
Activates the order and processes the initial payment using the provided Stripe confirmation token.
|
|
256
|
+
|
|
257
|
+
Parameters
|
|
258
|
+
----------
|
|
259
|
+
order_id : str
|
|
260
|
+
The order ID (can be internal ID or display ID)
|
|
261
|
+
|
|
262
|
+
confirmation_token : str
|
|
263
|
+
Stripe confirmation token for the payment method
|
|
264
|
+
|
|
265
|
+
return_url : str
|
|
266
|
+
URL to redirect to after payment processing
|
|
267
|
+
|
|
268
|
+
request_options : typing.Optional[RequestOptions]
|
|
269
|
+
Request-specific configuration.
|
|
270
|
+
|
|
271
|
+
Returns
|
|
272
|
+
-------
|
|
273
|
+
HttpResponse[Order]
|
|
274
|
+
Order activated and payment processed successfully
|
|
275
|
+
"""
|
|
276
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
277
|
+
f"orders/{jsonable_encoder(order_id)}/activate-and-pay",
|
|
278
|
+
method="POST",
|
|
279
|
+
json={
|
|
280
|
+
"confirmationToken": confirmation_token,
|
|
281
|
+
"returnUrl": return_url,
|
|
282
|
+
},
|
|
283
|
+
headers={
|
|
284
|
+
"content-type": "application/json",
|
|
285
|
+
},
|
|
286
|
+
request_options=request_options,
|
|
287
|
+
omit=OMIT,
|
|
288
|
+
)
|
|
289
|
+
try:
|
|
290
|
+
if 200 <= _response.status_code < 300:
|
|
291
|
+
_data = typing.cast(
|
|
292
|
+
Order,
|
|
293
|
+
parse_obj_as(
|
|
294
|
+
type_=Order, # type: ignore
|
|
295
|
+
object_=_response.json(),
|
|
296
|
+
),
|
|
297
|
+
)
|
|
298
|
+
return HttpResponse(response=_response, data=_data)
|
|
299
|
+
if _response.status_code == 400:
|
|
300
|
+
raise BadRequestError(
|
|
301
|
+
headers=dict(_response.headers),
|
|
302
|
+
body=typing.cast(
|
|
303
|
+
Error,
|
|
304
|
+
parse_obj_as(
|
|
305
|
+
type_=Error, # type: ignore
|
|
306
|
+
object_=_response.json(),
|
|
307
|
+
),
|
|
308
|
+
),
|
|
309
|
+
)
|
|
310
|
+
if _response.status_code == 403:
|
|
311
|
+
raise ForbiddenError(
|
|
312
|
+
headers=dict(_response.headers),
|
|
313
|
+
body=typing.cast(
|
|
314
|
+
Error,
|
|
315
|
+
parse_obj_as(
|
|
316
|
+
type_=Error, # type: ignore
|
|
317
|
+
object_=_response.json(),
|
|
318
|
+
),
|
|
319
|
+
),
|
|
320
|
+
)
|
|
321
|
+
if _response.status_code == 404:
|
|
322
|
+
raise NotFoundError(
|
|
323
|
+
headers=dict(_response.headers),
|
|
324
|
+
body=typing.cast(
|
|
325
|
+
Error,
|
|
326
|
+
parse_obj_as(
|
|
327
|
+
type_=Error, # type: ignore
|
|
328
|
+
object_=_response.json(),
|
|
329
|
+
),
|
|
330
|
+
),
|
|
331
|
+
)
|
|
332
|
+
_response_json = _response.json()
|
|
333
|
+
except JSONDecodeError:
|
|
334
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
335
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
336
|
+
|
|
337
|
+
def cancel_renewal(
|
|
338
|
+
self,
|
|
339
|
+
order_id: str,
|
|
340
|
+
*,
|
|
341
|
+
order_version: int,
|
|
342
|
+
cancel_from_date: dt.datetime,
|
|
343
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
344
|
+
) -> HttpResponse[CancelRenewalResponse]:
|
|
345
|
+
"""
|
|
346
|
+
Schedules the cancellation of an order's renewal from a specified date. The order will remain active until the cancellation date.
|
|
347
|
+
|
|
348
|
+
Parameters
|
|
349
|
+
----------
|
|
350
|
+
order_id : str
|
|
351
|
+
The order ID (can be internal ID or display ID)
|
|
352
|
+
|
|
353
|
+
order_version : int
|
|
354
|
+
The current version of the order (for optimistic locking)
|
|
355
|
+
|
|
356
|
+
cancel_from_date : dt.datetime
|
|
357
|
+
The date from which the renewal should be cancelled (ISO 8601 format)
|
|
358
|
+
|
|
359
|
+
request_options : typing.Optional[RequestOptions]
|
|
360
|
+
Request-specific configuration.
|
|
361
|
+
|
|
362
|
+
Returns
|
|
363
|
+
-------
|
|
364
|
+
HttpResponse[CancelRenewalResponse]
|
|
365
|
+
Order renewal cancelled successfully
|
|
366
|
+
"""
|
|
367
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
368
|
+
f"orders/{jsonable_encoder(order_id)}/cancel",
|
|
369
|
+
method="POST",
|
|
370
|
+
json={
|
|
371
|
+
"orderVersion": order_version,
|
|
372
|
+
"cancelFromDate": cancel_from_date,
|
|
373
|
+
},
|
|
374
|
+
headers={
|
|
375
|
+
"content-type": "application/json",
|
|
376
|
+
},
|
|
377
|
+
request_options=request_options,
|
|
378
|
+
omit=OMIT,
|
|
379
|
+
)
|
|
380
|
+
try:
|
|
381
|
+
if 200 <= _response.status_code < 300:
|
|
382
|
+
_data = typing.cast(
|
|
383
|
+
CancelRenewalResponse,
|
|
384
|
+
parse_obj_as(
|
|
385
|
+
type_=CancelRenewalResponse, # type: ignore
|
|
386
|
+
object_=_response.json(),
|
|
387
|
+
),
|
|
388
|
+
)
|
|
389
|
+
return HttpResponse(response=_response, data=_data)
|
|
390
|
+
if _response.status_code == 400:
|
|
391
|
+
raise BadRequestError(
|
|
392
|
+
headers=dict(_response.headers),
|
|
393
|
+
body=typing.cast(
|
|
394
|
+
Error,
|
|
395
|
+
parse_obj_as(
|
|
396
|
+
type_=Error, # type: ignore
|
|
397
|
+
object_=_response.json(),
|
|
398
|
+
),
|
|
399
|
+
),
|
|
400
|
+
)
|
|
401
|
+
if _response.status_code == 403:
|
|
402
|
+
raise ForbiddenError(
|
|
403
|
+
headers=dict(_response.headers),
|
|
404
|
+
body=typing.cast(
|
|
405
|
+
Error,
|
|
406
|
+
parse_obj_as(
|
|
407
|
+
type_=Error, # type: ignore
|
|
408
|
+
object_=_response.json(),
|
|
409
|
+
),
|
|
410
|
+
),
|
|
411
|
+
)
|
|
412
|
+
if _response.status_code == 404:
|
|
413
|
+
raise NotFoundError(
|
|
414
|
+
headers=dict(_response.headers),
|
|
415
|
+
body=typing.cast(
|
|
416
|
+
Error,
|
|
417
|
+
parse_obj_as(
|
|
418
|
+
type_=Error, # type: ignore
|
|
419
|
+
object_=_response.json(),
|
|
420
|
+
),
|
|
421
|
+
),
|
|
422
|
+
)
|
|
423
|
+
_response_json = _response.json()
|
|
424
|
+
except JSONDecodeError:
|
|
425
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
426
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
427
|
+
|
|
428
|
+
def schedule_plan_change(
|
|
429
|
+
self,
|
|
430
|
+
order_id: str,
|
|
431
|
+
*,
|
|
432
|
+
order_version: int,
|
|
433
|
+
effective_date: dt.datetime,
|
|
434
|
+
updated_order_line_attributes: typing.Sequence[ProrationAttributeUpdate],
|
|
435
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
436
|
+
) -> HttpResponse[ProrationUpgradeResponse]:
|
|
437
|
+
"""
|
|
438
|
+
Schedules a plan upgrade or downgrade for an order with automatic proration calculation. Credits are applied for the unused portion of the current billing period.
|
|
439
|
+
|
|
440
|
+
Parameters
|
|
441
|
+
----------
|
|
442
|
+
order_id : str
|
|
443
|
+
The order ID (can be internal ID or display ID)
|
|
444
|
+
|
|
445
|
+
order_version : int
|
|
446
|
+
The current version of the order (for optimistic locking)
|
|
447
|
+
|
|
448
|
+
effective_date : dt.datetime
|
|
449
|
+
The date when the plan change should take effect (ISO 8601 format)
|
|
450
|
+
|
|
451
|
+
updated_order_line_attributes : typing.Sequence[ProrationAttributeUpdate]
|
|
452
|
+
The list of order line attributes to update
|
|
453
|
+
|
|
454
|
+
request_options : typing.Optional[RequestOptions]
|
|
455
|
+
Request-specific configuration.
|
|
456
|
+
|
|
457
|
+
Returns
|
|
458
|
+
-------
|
|
459
|
+
HttpResponse[ProrationUpgradeResponse]
|
|
460
|
+
Plan change scheduled successfully
|
|
461
|
+
"""
|
|
462
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
463
|
+
f"orders/{jsonable_encoder(order_id)}/schedule-plan-change",
|
|
464
|
+
method="POST",
|
|
465
|
+
json={
|
|
466
|
+
"orderVersion": order_version,
|
|
467
|
+
"effectiveDate": effective_date,
|
|
468
|
+
"updatedOrderLineAttributes": convert_and_respect_annotation_metadata(
|
|
469
|
+
object_=updated_order_line_attributes,
|
|
470
|
+
annotation=typing.Sequence[ProrationAttributeUpdate],
|
|
471
|
+
direction="write",
|
|
472
|
+
),
|
|
473
|
+
},
|
|
474
|
+
headers={
|
|
475
|
+
"content-type": "application/json",
|
|
476
|
+
},
|
|
477
|
+
request_options=request_options,
|
|
478
|
+
omit=OMIT,
|
|
479
|
+
)
|
|
480
|
+
try:
|
|
481
|
+
if 200 <= _response.status_code < 300:
|
|
482
|
+
_data = typing.cast(
|
|
483
|
+
ProrationUpgradeResponse,
|
|
484
|
+
parse_obj_as(
|
|
485
|
+
type_=ProrationUpgradeResponse, # type: ignore
|
|
486
|
+
object_=_response.json(),
|
|
487
|
+
),
|
|
488
|
+
)
|
|
489
|
+
return HttpResponse(response=_response, data=_data)
|
|
490
|
+
if _response.status_code == 400:
|
|
491
|
+
raise BadRequestError(
|
|
492
|
+
headers=dict(_response.headers),
|
|
493
|
+
body=typing.cast(
|
|
494
|
+
Error,
|
|
495
|
+
parse_obj_as(
|
|
496
|
+
type_=Error, # type: ignore
|
|
497
|
+
object_=_response.json(),
|
|
498
|
+
),
|
|
499
|
+
),
|
|
500
|
+
)
|
|
501
|
+
if _response.status_code == 403:
|
|
502
|
+
raise ForbiddenError(
|
|
503
|
+
headers=dict(_response.headers),
|
|
504
|
+
body=typing.cast(
|
|
505
|
+
Error,
|
|
506
|
+
parse_obj_as(
|
|
507
|
+
type_=Error, # type: ignore
|
|
508
|
+
object_=_response.json(),
|
|
509
|
+
),
|
|
510
|
+
),
|
|
511
|
+
)
|
|
512
|
+
if _response.status_code == 404:
|
|
513
|
+
raise NotFoundError(
|
|
514
|
+
headers=dict(_response.headers),
|
|
515
|
+
body=typing.cast(
|
|
516
|
+
Error,
|
|
517
|
+
parse_obj_as(
|
|
518
|
+
type_=Error, # type: ignore
|
|
519
|
+
object_=_response.json(),
|
|
520
|
+
),
|
|
521
|
+
),
|
|
522
|
+
)
|
|
523
|
+
_response_json = _response.json()
|
|
524
|
+
except JSONDecodeError:
|
|
525
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
526
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
527
|
+
|
|
528
|
+
def get_invoices(
|
|
529
|
+
self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
530
|
+
) -> HttpResponse[typing.List[Invoice]]:
|
|
531
|
+
"""
|
|
532
|
+
Retrieves all invoices associated with a specific order.
|
|
533
|
+
|
|
534
|
+
Parameters
|
|
535
|
+
----------
|
|
536
|
+
order_id : str
|
|
537
|
+
The order ID (can be internal ID or display ID)
|
|
538
|
+
|
|
539
|
+
request_options : typing.Optional[RequestOptions]
|
|
540
|
+
Request-specific configuration.
|
|
541
|
+
|
|
542
|
+
Returns
|
|
543
|
+
-------
|
|
544
|
+
HttpResponse[typing.List[Invoice]]
|
|
545
|
+
Success response
|
|
546
|
+
"""
|
|
547
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
548
|
+
f"orders/{jsonable_encoder(order_id)}/invoices",
|
|
549
|
+
method="GET",
|
|
550
|
+
request_options=request_options,
|
|
551
|
+
)
|
|
552
|
+
try:
|
|
553
|
+
if 200 <= _response.status_code < 300:
|
|
554
|
+
_data = typing.cast(
|
|
555
|
+
typing.List[Invoice],
|
|
556
|
+
parse_obj_as(
|
|
557
|
+
type_=typing.List[Invoice], # type: ignore
|
|
558
|
+
object_=_response.json(),
|
|
559
|
+
),
|
|
560
|
+
)
|
|
561
|
+
return HttpResponse(response=_response, data=_data)
|
|
562
|
+
if _response.status_code == 403:
|
|
563
|
+
raise ForbiddenError(
|
|
564
|
+
headers=dict(_response.headers),
|
|
565
|
+
body=typing.cast(
|
|
566
|
+
Error,
|
|
567
|
+
parse_obj_as(
|
|
568
|
+
type_=Error, # type: ignore
|
|
569
|
+
object_=_response.json(),
|
|
570
|
+
),
|
|
571
|
+
),
|
|
572
|
+
)
|
|
573
|
+
if _response.status_code == 404:
|
|
574
|
+
raise NotFoundError(
|
|
575
|
+
headers=dict(_response.headers),
|
|
576
|
+
body=typing.cast(
|
|
577
|
+
Error,
|
|
578
|
+
parse_obj_as(
|
|
579
|
+
type_=Error, # type: ignore
|
|
580
|
+
object_=_response.json(),
|
|
581
|
+
),
|
|
582
|
+
),
|
|
583
|
+
)
|
|
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
|
+
|
|
232
589
|
|
|
233
590
|
class AsyncRawOrdersClient:
|
|
234
591
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
@@ -279,6 +636,7 @@ class AsyncRawOrdersClient:
|
|
|
279
636
|
billing_contact_id: typing.Optional[str] = OMIT,
|
|
280
637
|
description: typing.Optional[str] = OMIT,
|
|
281
638
|
end_date: typing.Optional[str] = OMIT,
|
|
639
|
+
plan_id: typing.Optional[str] = OMIT,
|
|
282
640
|
order_lines: typing.Optional[typing.Sequence[OrderLineCreate]] = OMIT,
|
|
283
641
|
request_options: typing.Optional[RequestOptions] = None,
|
|
284
642
|
) -> AsyncHttpResponse[Order]:
|
|
@@ -301,6 +659,9 @@ class AsyncRawOrdersClient:
|
|
|
301
659
|
|
|
302
660
|
end_date : typing.Optional[str]
|
|
303
661
|
|
|
662
|
+
plan_id : typing.Optional[str]
|
|
663
|
+
Optional plan ID to associate with this order
|
|
664
|
+
|
|
304
665
|
order_lines : typing.Optional[typing.Sequence[OrderLineCreate]]
|
|
305
666
|
|
|
306
667
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -323,6 +684,7 @@ class AsyncRawOrdersClient:
|
|
|
323
684
|
"startDate": start_date,
|
|
324
685
|
"endDate": end_date,
|
|
325
686
|
"currency": currency,
|
|
687
|
+
"planId": plan_id,
|
|
326
688
|
"orderLines": convert_and_respect_annotation_metadata(
|
|
327
689
|
object_=order_lines, annotation=typing.Sequence[OrderLineCreate], direction="write"
|
|
328
690
|
),
|
|
@@ -447,3 +809,346 @@ class AsyncRawOrdersClient:
|
|
|
447
809
|
except JSONDecodeError:
|
|
448
810
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
449
811
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
812
|
+
|
|
813
|
+
async def activate_and_pay(
|
|
814
|
+
self,
|
|
815
|
+
order_id: str,
|
|
816
|
+
*,
|
|
817
|
+
confirmation_token: str,
|
|
818
|
+
return_url: str,
|
|
819
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
820
|
+
) -> AsyncHttpResponse[Order]:
|
|
821
|
+
"""
|
|
822
|
+
Activates the order and processes the initial payment using the provided Stripe confirmation token.
|
|
823
|
+
|
|
824
|
+
Parameters
|
|
825
|
+
----------
|
|
826
|
+
order_id : str
|
|
827
|
+
The order ID (can be internal ID or display ID)
|
|
828
|
+
|
|
829
|
+
confirmation_token : str
|
|
830
|
+
Stripe confirmation token for the payment method
|
|
831
|
+
|
|
832
|
+
return_url : str
|
|
833
|
+
URL to redirect to after payment processing
|
|
834
|
+
|
|
835
|
+
request_options : typing.Optional[RequestOptions]
|
|
836
|
+
Request-specific configuration.
|
|
837
|
+
|
|
838
|
+
Returns
|
|
839
|
+
-------
|
|
840
|
+
AsyncHttpResponse[Order]
|
|
841
|
+
Order activated and payment processed successfully
|
|
842
|
+
"""
|
|
843
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
844
|
+
f"orders/{jsonable_encoder(order_id)}/activate-and-pay",
|
|
845
|
+
method="POST",
|
|
846
|
+
json={
|
|
847
|
+
"confirmationToken": confirmation_token,
|
|
848
|
+
"returnUrl": return_url,
|
|
849
|
+
},
|
|
850
|
+
headers={
|
|
851
|
+
"content-type": "application/json",
|
|
852
|
+
},
|
|
853
|
+
request_options=request_options,
|
|
854
|
+
omit=OMIT,
|
|
855
|
+
)
|
|
856
|
+
try:
|
|
857
|
+
if 200 <= _response.status_code < 300:
|
|
858
|
+
_data = typing.cast(
|
|
859
|
+
Order,
|
|
860
|
+
parse_obj_as(
|
|
861
|
+
type_=Order, # type: ignore
|
|
862
|
+
object_=_response.json(),
|
|
863
|
+
),
|
|
864
|
+
)
|
|
865
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
866
|
+
if _response.status_code == 400:
|
|
867
|
+
raise BadRequestError(
|
|
868
|
+
headers=dict(_response.headers),
|
|
869
|
+
body=typing.cast(
|
|
870
|
+
Error,
|
|
871
|
+
parse_obj_as(
|
|
872
|
+
type_=Error, # type: ignore
|
|
873
|
+
object_=_response.json(),
|
|
874
|
+
),
|
|
875
|
+
),
|
|
876
|
+
)
|
|
877
|
+
if _response.status_code == 403:
|
|
878
|
+
raise ForbiddenError(
|
|
879
|
+
headers=dict(_response.headers),
|
|
880
|
+
body=typing.cast(
|
|
881
|
+
Error,
|
|
882
|
+
parse_obj_as(
|
|
883
|
+
type_=Error, # type: ignore
|
|
884
|
+
object_=_response.json(),
|
|
885
|
+
),
|
|
886
|
+
),
|
|
887
|
+
)
|
|
888
|
+
if _response.status_code == 404:
|
|
889
|
+
raise NotFoundError(
|
|
890
|
+
headers=dict(_response.headers),
|
|
891
|
+
body=typing.cast(
|
|
892
|
+
Error,
|
|
893
|
+
parse_obj_as(
|
|
894
|
+
type_=Error, # type: ignore
|
|
895
|
+
object_=_response.json(),
|
|
896
|
+
),
|
|
897
|
+
),
|
|
898
|
+
)
|
|
899
|
+
_response_json = _response.json()
|
|
900
|
+
except JSONDecodeError:
|
|
901
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
902
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
903
|
+
|
|
904
|
+
async def cancel_renewal(
|
|
905
|
+
self,
|
|
906
|
+
order_id: str,
|
|
907
|
+
*,
|
|
908
|
+
order_version: int,
|
|
909
|
+
cancel_from_date: dt.datetime,
|
|
910
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
911
|
+
) -> AsyncHttpResponse[CancelRenewalResponse]:
|
|
912
|
+
"""
|
|
913
|
+
Schedules the cancellation of an order's renewal from a specified date. The order will remain active until the cancellation date.
|
|
914
|
+
|
|
915
|
+
Parameters
|
|
916
|
+
----------
|
|
917
|
+
order_id : str
|
|
918
|
+
The order ID (can be internal ID or display ID)
|
|
919
|
+
|
|
920
|
+
order_version : int
|
|
921
|
+
The current version of the order (for optimistic locking)
|
|
922
|
+
|
|
923
|
+
cancel_from_date : dt.datetime
|
|
924
|
+
The date from which the renewal should be cancelled (ISO 8601 format)
|
|
925
|
+
|
|
926
|
+
request_options : typing.Optional[RequestOptions]
|
|
927
|
+
Request-specific configuration.
|
|
928
|
+
|
|
929
|
+
Returns
|
|
930
|
+
-------
|
|
931
|
+
AsyncHttpResponse[CancelRenewalResponse]
|
|
932
|
+
Order renewal cancelled successfully
|
|
933
|
+
"""
|
|
934
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
935
|
+
f"orders/{jsonable_encoder(order_id)}/cancel",
|
|
936
|
+
method="POST",
|
|
937
|
+
json={
|
|
938
|
+
"orderVersion": order_version,
|
|
939
|
+
"cancelFromDate": cancel_from_date,
|
|
940
|
+
},
|
|
941
|
+
headers={
|
|
942
|
+
"content-type": "application/json",
|
|
943
|
+
},
|
|
944
|
+
request_options=request_options,
|
|
945
|
+
omit=OMIT,
|
|
946
|
+
)
|
|
947
|
+
try:
|
|
948
|
+
if 200 <= _response.status_code < 300:
|
|
949
|
+
_data = typing.cast(
|
|
950
|
+
CancelRenewalResponse,
|
|
951
|
+
parse_obj_as(
|
|
952
|
+
type_=CancelRenewalResponse, # type: ignore
|
|
953
|
+
object_=_response.json(),
|
|
954
|
+
),
|
|
955
|
+
)
|
|
956
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
957
|
+
if _response.status_code == 400:
|
|
958
|
+
raise BadRequestError(
|
|
959
|
+
headers=dict(_response.headers),
|
|
960
|
+
body=typing.cast(
|
|
961
|
+
Error,
|
|
962
|
+
parse_obj_as(
|
|
963
|
+
type_=Error, # type: ignore
|
|
964
|
+
object_=_response.json(),
|
|
965
|
+
),
|
|
966
|
+
),
|
|
967
|
+
)
|
|
968
|
+
if _response.status_code == 403:
|
|
969
|
+
raise ForbiddenError(
|
|
970
|
+
headers=dict(_response.headers),
|
|
971
|
+
body=typing.cast(
|
|
972
|
+
Error,
|
|
973
|
+
parse_obj_as(
|
|
974
|
+
type_=Error, # type: ignore
|
|
975
|
+
object_=_response.json(),
|
|
976
|
+
),
|
|
977
|
+
),
|
|
978
|
+
)
|
|
979
|
+
if _response.status_code == 404:
|
|
980
|
+
raise NotFoundError(
|
|
981
|
+
headers=dict(_response.headers),
|
|
982
|
+
body=typing.cast(
|
|
983
|
+
Error,
|
|
984
|
+
parse_obj_as(
|
|
985
|
+
type_=Error, # type: ignore
|
|
986
|
+
object_=_response.json(),
|
|
987
|
+
),
|
|
988
|
+
),
|
|
989
|
+
)
|
|
990
|
+
_response_json = _response.json()
|
|
991
|
+
except JSONDecodeError:
|
|
992
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
993
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
994
|
+
|
|
995
|
+
async def schedule_plan_change(
|
|
996
|
+
self,
|
|
997
|
+
order_id: str,
|
|
998
|
+
*,
|
|
999
|
+
order_version: int,
|
|
1000
|
+
effective_date: dt.datetime,
|
|
1001
|
+
updated_order_line_attributes: typing.Sequence[ProrationAttributeUpdate],
|
|
1002
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1003
|
+
) -> AsyncHttpResponse[ProrationUpgradeResponse]:
|
|
1004
|
+
"""
|
|
1005
|
+
Schedules a plan upgrade or downgrade for an order with automatic proration calculation. Credits are applied for the unused portion of the current billing period.
|
|
1006
|
+
|
|
1007
|
+
Parameters
|
|
1008
|
+
----------
|
|
1009
|
+
order_id : str
|
|
1010
|
+
The order ID (can be internal ID or display ID)
|
|
1011
|
+
|
|
1012
|
+
order_version : int
|
|
1013
|
+
The current version of the order (for optimistic locking)
|
|
1014
|
+
|
|
1015
|
+
effective_date : dt.datetime
|
|
1016
|
+
The date when the plan change should take effect (ISO 8601 format)
|
|
1017
|
+
|
|
1018
|
+
updated_order_line_attributes : typing.Sequence[ProrationAttributeUpdate]
|
|
1019
|
+
The list of order line attributes to update
|
|
1020
|
+
|
|
1021
|
+
request_options : typing.Optional[RequestOptions]
|
|
1022
|
+
Request-specific configuration.
|
|
1023
|
+
|
|
1024
|
+
Returns
|
|
1025
|
+
-------
|
|
1026
|
+
AsyncHttpResponse[ProrationUpgradeResponse]
|
|
1027
|
+
Plan change scheduled successfully
|
|
1028
|
+
"""
|
|
1029
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1030
|
+
f"orders/{jsonable_encoder(order_id)}/schedule-plan-change",
|
|
1031
|
+
method="POST",
|
|
1032
|
+
json={
|
|
1033
|
+
"orderVersion": order_version,
|
|
1034
|
+
"effectiveDate": effective_date,
|
|
1035
|
+
"updatedOrderLineAttributes": convert_and_respect_annotation_metadata(
|
|
1036
|
+
object_=updated_order_line_attributes,
|
|
1037
|
+
annotation=typing.Sequence[ProrationAttributeUpdate],
|
|
1038
|
+
direction="write",
|
|
1039
|
+
),
|
|
1040
|
+
},
|
|
1041
|
+
headers={
|
|
1042
|
+
"content-type": "application/json",
|
|
1043
|
+
},
|
|
1044
|
+
request_options=request_options,
|
|
1045
|
+
omit=OMIT,
|
|
1046
|
+
)
|
|
1047
|
+
try:
|
|
1048
|
+
if 200 <= _response.status_code < 300:
|
|
1049
|
+
_data = typing.cast(
|
|
1050
|
+
ProrationUpgradeResponse,
|
|
1051
|
+
parse_obj_as(
|
|
1052
|
+
type_=ProrationUpgradeResponse, # type: ignore
|
|
1053
|
+
object_=_response.json(),
|
|
1054
|
+
),
|
|
1055
|
+
)
|
|
1056
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1057
|
+
if _response.status_code == 400:
|
|
1058
|
+
raise BadRequestError(
|
|
1059
|
+
headers=dict(_response.headers),
|
|
1060
|
+
body=typing.cast(
|
|
1061
|
+
Error,
|
|
1062
|
+
parse_obj_as(
|
|
1063
|
+
type_=Error, # type: ignore
|
|
1064
|
+
object_=_response.json(),
|
|
1065
|
+
),
|
|
1066
|
+
),
|
|
1067
|
+
)
|
|
1068
|
+
if _response.status_code == 403:
|
|
1069
|
+
raise ForbiddenError(
|
|
1070
|
+
headers=dict(_response.headers),
|
|
1071
|
+
body=typing.cast(
|
|
1072
|
+
Error,
|
|
1073
|
+
parse_obj_as(
|
|
1074
|
+
type_=Error, # type: ignore
|
|
1075
|
+
object_=_response.json(),
|
|
1076
|
+
),
|
|
1077
|
+
),
|
|
1078
|
+
)
|
|
1079
|
+
if _response.status_code == 404:
|
|
1080
|
+
raise NotFoundError(
|
|
1081
|
+
headers=dict(_response.headers),
|
|
1082
|
+
body=typing.cast(
|
|
1083
|
+
Error,
|
|
1084
|
+
parse_obj_as(
|
|
1085
|
+
type_=Error, # type: ignore
|
|
1086
|
+
object_=_response.json(),
|
|
1087
|
+
),
|
|
1088
|
+
),
|
|
1089
|
+
)
|
|
1090
|
+
_response_json = _response.json()
|
|
1091
|
+
except JSONDecodeError:
|
|
1092
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1093
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1094
|
+
|
|
1095
|
+
async def get_invoices(
|
|
1096
|
+
self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1097
|
+
) -> AsyncHttpResponse[typing.List[Invoice]]:
|
|
1098
|
+
"""
|
|
1099
|
+
Retrieves all invoices associated with a specific order.
|
|
1100
|
+
|
|
1101
|
+
Parameters
|
|
1102
|
+
----------
|
|
1103
|
+
order_id : str
|
|
1104
|
+
The order ID (can be internal ID or display ID)
|
|
1105
|
+
|
|
1106
|
+
request_options : typing.Optional[RequestOptions]
|
|
1107
|
+
Request-specific configuration.
|
|
1108
|
+
|
|
1109
|
+
Returns
|
|
1110
|
+
-------
|
|
1111
|
+
AsyncHttpResponse[typing.List[Invoice]]
|
|
1112
|
+
Success response
|
|
1113
|
+
"""
|
|
1114
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1115
|
+
f"orders/{jsonable_encoder(order_id)}/invoices",
|
|
1116
|
+
method="GET",
|
|
1117
|
+
request_options=request_options,
|
|
1118
|
+
)
|
|
1119
|
+
try:
|
|
1120
|
+
if 200 <= _response.status_code < 300:
|
|
1121
|
+
_data = typing.cast(
|
|
1122
|
+
typing.List[Invoice],
|
|
1123
|
+
parse_obj_as(
|
|
1124
|
+
type_=typing.List[Invoice], # type: ignore
|
|
1125
|
+
object_=_response.json(),
|
|
1126
|
+
),
|
|
1127
|
+
)
|
|
1128
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1129
|
+
if _response.status_code == 403:
|
|
1130
|
+
raise ForbiddenError(
|
|
1131
|
+
headers=dict(_response.headers),
|
|
1132
|
+
body=typing.cast(
|
|
1133
|
+
Error,
|
|
1134
|
+
parse_obj_as(
|
|
1135
|
+
type_=Error, # type: ignore
|
|
1136
|
+
object_=_response.json(),
|
|
1137
|
+
),
|
|
1138
|
+
),
|
|
1139
|
+
)
|
|
1140
|
+
if _response.status_code == 404:
|
|
1141
|
+
raise NotFoundError(
|
|
1142
|
+
headers=dict(_response.headers),
|
|
1143
|
+
body=typing.cast(
|
|
1144
|
+
Error,
|
|
1145
|
+
parse_obj_as(
|
|
1146
|
+
type_=Error, # type: ignore
|
|
1147
|
+
object_=_response.json(),
|
|
1148
|
+
),
|
|
1149
|
+
),
|
|
1150
|
+
)
|
|
1151
|
+
_response_json = _response.json()
|
|
1152
|
+
except JSONDecodeError:
|
|
1153
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1154
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|