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.
Files changed (54) hide show
  1. paid/__init__.py +33 -0
  2. paid/client.py +1 -472
  3. paid/core/client_wrapper.py +3 -2
  4. paid/customers/__init__.py +3 -0
  5. paid/customers/client.py +428 -4
  6. paid/customers/raw_client.py +594 -2
  7. paid/customers/types/__init__.py +8 -0
  8. paid/customers/types/customers_check_entitlement_request_view.py +5 -0
  9. paid/customers/types/customers_check_entitlement_response.py +22 -0
  10. paid/orders/client.py +445 -0
  11. paid/orders/raw_client.py +705 -0
  12. paid/plans/client.py +142 -0
  13. paid/plans/raw_client.py +238 -0
  14. paid/types/__init__.py +30 -0
  15. paid/types/cancel_renewal_response.py +49 -0
  16. paid/types/contact_create_for_customer.py +37 -0
  17. paid/types/invoice.py +75 -0
  18. paid/types/invoice_status.py +5 -0
  19. paid/types/payment_method.py +58 -0
  20. paid/types/payment_method_card.py +49 -0
  21. paid/types/payment_method_type.py +5 -0
  22. paid/types/payment_method_us_bank_account.py +36 -0
  23. paid/types/payment_method_us_bank_account_account_type.py +5 -0
  24. paid/types/plan_group.py +60 -0
  25. paid/types/plan_plan_products_item.py +6 -0
  26. paid/types/plan_with_features.py +69 -0
  27. paid/types/plan_with_features_features_item.py +34 -0
  28. paid/types/proration_attribute_update.py +44 -0
  29. paid/types/proration_detail.py +49 -0
  30. paid/types/proration_upgrade_response.py +73 -0
  31. paid/types/signal_v_2.py +5 -5
  32. paid/usage/client.py +6 -6
  33. {paid_python-0.5.0.dist-info → paid_python-1.0.0a0.dist-info}/METADATA +6 -4
  34. {paid_python-0.5.0.dist-info → paid_python-1.0.0a0.dist-info}/RECORD +36 -36
  35. opentelemetry/instrumentation/openai/__init__.py +0 -54
  36. opentelemetry/instrumentation/openai/shared/__init__.py +0 -399
  37. opentelemetry/instrumentation/openai/shared/audio_wrappers.py +0 -247
  38. opentelemetry/instrumentation/openai/shared/chat_wrappers.py +0 -1192
  39. opentelemetry/instrumentation/openai/shared/completion_wrappers.py +0 -292
  40. opentelemetry/instrumentation/openai/shared/config.py +0 -15
  41. opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py +0 -311
  42. opentelemetry/instrumentation/openai/shared/event_emitter.py +0 -108
  43. opentelemetry/instrumentation/openai/shared/event_models.py +0 -41
  44. opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py +0 -68
  45. opentelemetry/instrumentation/openai/shared/span_utils.py +0 -0
  46. opentelemetry/instrumentation/openai/utils.py +0 -213
  47. opentelemetry/instrumentation/openai/v0/__init__.py +0 -176
  48. opentelemetry/instrumentation/openai/v1/__init__.py +0 -394
  49. opentelemetry/instrumentation/openai/v1/assistant_wrappers.py +0 -329
  50. opentelemetry/instrumentation/openai/v1/event_handler_wrapper.py +0 -134
  51. opentelemetry/instrumentation/openai/v1/responses_wrappers.py +0 -1113
  52. opentelemetry/instrumentation/openai/version.py +0 -1
  53. {paid_python-0.5.0.dist-info → paid_python-1.0.0a0.dist-info}/LICENSE +0 -0
  54. {paid_python-0.5.0.dist-info → paid_python-1.0.0a0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,22 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class CustomersCheckEntitlementResponse(UniversalBaseModel):
10
+ entitled: bool = pydantic.Field()
11
+ """
12
+ Whether the customer is entitled to the specified event
13
+ """
14
+
15
+ if IS_PYDANTIC_V2:
16
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
17
+ else:
18
+
19
+ class Config:
20
+ frozen = True
21
+ smart_union = True
22
+ extra = pydantic.Extra.allow
paid/orders/client.py CHANGED
@@ -1,11 +1,16 @@
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
 
5
6
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6
7
  from ..core.request_options import RequestOptions
8
+ from ..types.cancel_renewal_response import CancelRenewalResponse
9
+ from ..types.invoice import Invoice
7
10
  from ..types.order import Order
8
11
  from ..types.order_line_create import OrderLineCreate
12
+ from ..types.proration_attribute_update import ProrationAttributeUpdate
13
+ from ..types.proration_upgrade_response import ProrationUpgradeResponse
9
14
  from .lines.client import AsyncLinesClient, LinesClient
10
15
  from .raw_client import AsyncRawOrdersClient, RawOrdersClient
11
16
 
@@ -64,6 +69,7 @@ class OrdersClient:
64
69
  billing_contact_id: typing.Optional[str] = OMIT,
65
70
  description: typing.Optional[str] = OMIT,
66
71
  end_date: typing.Optional[str] = OMIT,
72
+ plan_id: typing.Optional[str] = OMIT,
67
73
  order_lines: typing.Optional[typing.Sequence[OrderLineCreate]] = OMIT,
68
74
  request_options: typing.Optional[RequestOptions] = None,
69
75
  ) -> Order:
@@ -86,6 +92,9 @@ class OrdersClient:
86
92
 
87
93
  end_date : typing.Optional[str]
88
94
 
95
+ plan_id : typing.Optional[str]
96
+ Optional plan ID to associate with this order
97
+
89
98
  order_lines : typing.Optional[typing.Sequence[OrderLineCreate]]
90
99
 
91
100
  request_options : typing.Optional[RequestOptions]
@@ -121,6 +130,7 @@ class OrdersClient:
121
130
  billing_contact_id=billing_contact_id,
122
131
  description=description,
123
132
  end_date=end_date,
133
+ plan_id=plan_id,
124
134
  order_lines=order_lines,
125
135
  request_options=request_options,
126
136
  )
@@ -209,6 +219,206 @@ class OrdersClient:
209
219
  _response = self._raw_client.activate(order_id, request_options=request_options)
210
220
  return _response.data
211
221
 
222
+ def activate_and_pay(
223
+ self,
224
+ order_id: str,
225
+ *,
226
+ confirmation_token: str,
227
+ return_url: str,
228
+ request_options: typing.Optional[RequestOptions] = None,
229
+ ) -> Order:
230
+ """
231
+ Activates the order and processes the initial payment using the provided Stripe confirmation token.
232
+
233
+ Parameters
234
+ ----------
235
+ order_id : str
236
+ The order ID (can be internal ID or display ID)
237
+
238
+ confirmation_token : str
239
+ Stripe confirmation token for the payment method
240
+
241
+ return_url : str
242
+ URL to redirect to after payment processing
243
+
244
+ request_options : typing.Optional[RequestOptions]
245
+ Request-specific configuration.
246
+
247
+ Returns
248
+ -------
249
+ Order
250
+ Order activated and payment processed successfully
251
+
252
+ Examples
253
+ --------
254
+ from paid import Paid
255
+
256
+ client = Paid(
257
+ token="YOUR_TOKEN",
258
+ )
259
+ client.orders.activate_and_pay(
260
+ order_id="orderId",
261
+ confirmation_token="ctoken_1234567890",
262
+ return_url="https://example.com/payment-complete",
263
+ )
264
+ """
265
+ _response = self._raw_client.activate_and_pay(
266
+ order_id, confirmation_token=confirmation_token, return_url=return_url, request_options=request_options
267
+ )
268
+ return _response.data
269
+
270
+ def cancel_renewal(
271
+ self,
272
+ order_id: str,
273
+ *,
274
+ order_version: int,
275
+ cancel_from_date: dt.datetime,
276
+ request_options: typing.Optional[RequestOptions] = None,
277
+ ) -> CancelRenewalResponse:
278
+ """
279
+ Schedules the cancellation of an order's renewal from a specified date. The order will remain active until the cancellation date.
280
+
281
+ Parameters
282
+ ----------
283
+ order_id : str
284
+ The order ID (can be internal ID or display ID)
285
+
286
+ order_version : int
287
+ The current version of the order (for optimistic locking)
288
+
289
+ cancel_from_date : dt.datetime
290
+ The date from which the renewal should be cancelled (ISO 8601 format)
291
+
292
+ request_options : typing.Optional[RequestOptions]
293
+ Request-specific configuration.
294
+
295
+ Returns
296
+ -------
297
+ CancelRenewalResponse
298
+ Order renewal cancelled successfully
299
+
300
+ Examples
301
+ --------
302
+ import datetime
303
+
304
+ from paid import Paid
305
+
306
+ client = Paid(
307
+ token="YOUR_TOKEN",
308
+ )
309
+ client.orders.cancel_renewal(
310
+ order_id="orderId",
311
+ order_version=1,
312
+ cancel_from_date=datetime.datetime.fromisoformat(
313
+ "2025-12-31 00:00:00+00:00",
314
+ ),
315
+ )
316
+ """
317
+ _response = self._raw_client.cancel_renewal(
318
+ order_id, order_version=order_version, cancel_from_date=cancel_from_date, request_options=request_options
319
+ )
320
+ return _response.data
321
+
322
+ def schedule_plan_change(
323
+ self,
324
+ order_id: str,
325
+ *,
326
+ order_version: int,
327
+ effective_date: dt.datetime,
328
+ updated_order_line_attributes: typing.Sequence[ProrationAttributeUpdate],
329
+ request_options: typing.Optional[RequestOptions] = None,
330
+ ) -> ProrationUpgradeResponse:
331
+ """
332
+ 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.
333
+
334
+ Parameters
335
+ ----------
336
+ order_id : str
337
+ The order ID (can be internal ID or display ID)
338
+
339
+ order_version : int
340
+ The current version of the order (for optimistic locking)
341
+
342
+ effective_date : dt.datetime
343
+ The date when the plan change should take effect (ISO 8601 format)
344
+
345
+ updated_order_line_attributes : typing.Sequence[ProrationAttributeUpdate]
346
+ The list of order line attributes to update
347
+
348
+ request_options : typing.Optional[RequestOptions]
349
+ Request-specific configuration.
350
+
351
+ Returns
352
+ -------
353
+ ProrationUpgradeResponse
354
+ Plan change scheduled successfully
355
+
356
+ Examples
357
+ --------
358
+ import datetime
359
+
360
+ from paid import Paid, ProrationAttributeUpdate
361
+
362
+ client = Paid(
363
+ token="YOUR_TOKEN",
364
+ )
365
+ client.orders.schedule_plan_change(
366
+ order_id="orderId",
367
+ order_version=1,
368
+ effective_date=datetime.datetime.fromisoformat(
369
+ "2025-02-01 00:00:00+00:00",
370
+ ),
371
+ updated_order_line_attributes=[
372
+ ProrationAttributeUpdate(
373
+ order_line_attribute_id="a1b2c3d4-5678-90ab-cdef-1234567890ab",
374
+ new_pricing={"unitPrice": 200, "currency": "USD"},
375
+ new_quantity=10.0,
376
+ )
377
+ ],
378
+ )
379
+ """
380
+ _response = self._raw_client.schedule_plan_change(
381
+ order_id,
382
+ order_version=order_version,
383
+ effective_date=effective_date,
384
+ updated_order_line_attributes=updated_order_line_attributes,
385
+ request_options=request_options,
386
+ )
387
+ return _response.data
388
+
389
+ def get_invoices(
390
+ self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None
391
+ ) -> typing.List[Invoice]:
392
+ """
393
+ Retrieves all invoices associated with a specific order.
394
+
395
+ Parameters
396
+ ----------
397
+ order_id : str
398
+ The order ID (can be internal ID or display ID)
399
+
400
+ request_options : typing.Optional[RequestOptions]
401
+ Request-specific configuration.
402
+
403
+ Returns
404
+ -------
405
+ typing.List[Invoice]
406
+ Success response
407
+
408
+ Examples
409
+ --------
410
+ from paid import Paid
411
+
412
+ client = Paid(
413
+ token="YOUR_TOKEN",
414
+ )
415
+ client.orders.get_invoices(
416
+ order_id="orderId",
417
+ )
418
+ """
419
+ _response = self._raw_client.get_invoices(order_id, request_options=request_options)
420
+ return _response.data
421
+
212
422
 
213
423
  class AsyncOrdersClient:
214
424
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
@@ -269,6 +479,7 @@ class AsyncOrdersClient:
269
479
  billing_contact_id: typing.Optional[str] = OMIT,
270
480
  description: typing.Optional[str] = OMIT,
271
481
  end_date: typing.Optional[str] = OMIT,
482
+ plan_id: typing.Optional[str] = OMIT,
272
483
  order_lines: typing.Optional[typing.Sequence[OrderLineCreate]] = OMIT,
273
484
  request_options: typing.Optional[RequestOptions] = None,
274
485
  ) -> Order:
@@ -291,6 +502,9 @@ class AsyncOrdersClient:
291
502
 
292
503
  end_date : typing.Optional[str]
293
504
 
505
+ plan_id : typing.Optional[str]
506
+ Optional plan ID to associate with this order
507
+
294
508
  order_lines : typing.Optional[typing.Sequence[OrderLineCreate]]
295
509
 
296
510
  request_options : typing.Optional[RequestOptions]
@@ -334,6 +548,7 @@ class AsyncOrdersClient:
334
548
  billing_contact_id=billing_contact_id,
335
549
  description=description,
336
550
  end_date=end_date,
551
+ plan_id=plan_id,
337
552
  order_lines=order_lines,
338
553
  request_options=request_options,
339
554
  )
@@ -445,3 +660,233 @@ class AsyncOrdersClient:
445
660
  """
446
661
  _response = await self._raw_client.activate(order_id, request_options=request_options)
447
662
  return _response.data
663
+
664
+ async def activate_and_pay(
665
+ self,
666
+ order_id: str,
667
+ *,
668
+ confirmation_token: str,
669
+ return_url: str,
670
+ request_options: typing.Optional[RequestOptions] = None,
671
+ ) -> Order:
672
+ """
673
+ Activates the order and processes the initial payment using the provided Stripe confirmation token.
674
+
675
+ Parameters
676
+ ----------
677
+ order_id : str
678
+ The order ID (can be internal ID or display ID)
679
+
680
+ confirmation_token : str
681
+ Stripe confirmation token for the payment method
682
+
683
+ return_url : str
684
+ URL to redirect to after payment processing
685
+
686
+ request_options : typing.Optional[RequestOptions]
687
+ Request-specific configuration.
688
+
689
+ Returns
690
+ -------
691
+ Order
692
+ Order activated and payment processed successfully
693
+
694
+ Examples
695
+ --------
696
+ import asyncio
697
+
698
+ from paid import AsyncPaid
699
+
700
+ client = AsyncPaid(
701
+ token="YOUR_TOKEN",
702
+ )
703
+
704
+
705
+ async def main() -> None:
706
+ await client.orders.activate_and_pay(
707
+ order_id="orderId",
708
+ confirmation_token="ctoken_1234567890",
709
+ return_url="https://example.com/payment-complete",
710
+ )
711
+
712
+
713
+ asyncio.run(main())
714
+ """
715
+ _response = await self._raw_client.activate_and_pay(
716
+ order_id, confirmation_token=confirmation_token, return_url=return_url, request_options=request_options
717
+ )
718
+ return _response.data
719
+
720
+ async def cancel_renewal(
721
+ self,
722
+ order_id: str,
723
+ *,
724
+ order_version: int,
725
+ cancel_from_date: dt.datetime,
726
+ request_options: typing.Optional[RequestOptions] = None,
727
+ ) -> CancelRenewalResponse:
728
+ """
729
+ Schedules the cancellation of an order's renewal from a specified date. The order will remain active until the cancellation date.
730
+
731
+ Parameters
732
+ ----------
733
+ order_id : str
734
+ The order ID (can be internal ID or display ID)
735
+
736
+ order_version : int
737
+ The current version of the order (for optimistic locking)
738
+
739
+ cancel_from_date : dt.datetime
740
+ The date from which the renewal should be cancelled (ISO 8601 format)
741
+
742
+ request_options : typing.Optional[RequestOptions]
743
+ Request-specific configuration.
744
+
745
+ Returns
746
+ -------
747
+ CancelRenewalResponse
748
+ Order renewal cancelled successfully
749
+
750
+ Examples
751
+ --------
752
+ import asyncio
753
+ import datetime
754
+
755
+ from paid import AsyncPaid
756
+
757
+ client = AsyncPaid(
758
+ token="YOUR_TOKEN",
759
+ )
760
+
761
+
762
+ async def main() -> None:
763
+ await client.orders.cancel_renewal(
764
+ order_id="orderId",
765
+ order_version=1,
766
+ cancel_from_date=datetime.datetime.fromisoformat(
767
+ "2025-12-31 00:00:00+00:00",
768
+ ),
769
+ )
770
+
771
+
772
+ asyncio.run(main())
773
+ """
774
+ _response = await self._raw_client.cancel_renewal(
775
+ order_id, order_version=order_version, cancel_from_date=cancel_from_date, request_options=request_options
776
+ )
777
+ return _response.data
778
+
779
+ async def schedule_plan_change(
780
+ self,
781
+ order_id: str,
782
+ *,
783
+ order_version: int,
784
+ effective_date: dt.datetime,
785
+ updated_order_line_attributes: typing.Sequence[ProrationAttributeUpdate],
786
+ request_options: typing.Optional[RequestOptions] = None,
787
+ ) -> ProrationUpgradeResponse:
788
+ """
789
+ 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.
790
+
791
+ Parameters
792
+ ----------
793
+ order_id : str
794
+ The order ID (can be internal ID or display ID)
795
+
796
+ order_version : int
797
+ The current version of the order (for optimistic locking)
798
+
799
+ effective_date : dt.datetime
800
+ The date when the plan change should take effect (ISO 8601 format)
801
+
802
+ updated_order_line_attributes : typing.Sequence[ProrationAttributeUpdate]
803
+ The list of order line attributes to update
804
+
805
+ request_options : typing.Optional[RequestOptions]
806
+ Request-specific configuration.
807
+
808
+ Returns
809
+ -------
810
+ ProrationUpgradeResponse
811
+ Plan change scheduled successfully
812
+
813
+ Examples
814
+ --------
815
+ import asyncio
816
+ import datetime
817
+
818
+ from paid import AsyncPaid, ProrationAttributeUpdate
819
+
820
+ client = AsyncPaid(
821
+ token="YOUR_TOKEN",
822
+ )
823
+
824
+
825
+ async def main() -> None:
826
+ await client.orders.schedule_plan_change(
827
+ order_id="orderId",
828
+ order_version=1,
829
+ effective_date=datetime.datetime.fromisoformat(
830
+ "2025-02-01 00:00:00+00:00",
831
+ ),
832
+ updated_order_line_attributes=[
833
+ ProrationAttributeUpdate(
834
+ order_line_attribute_id="a1b2c3d4-5678-90ab-cdef-1234567890ab",
835
+ new_pricing={"unitPrice": 200, "currency": "USD"},
836
+ new_quantity=10.0,
837
+ )
838
+ ],
839
+ )
840
+
841
+
842
+ asyncio.run(main())
843
+ """
844
+ _response = await self._raw_client.schedule_plan_change(
845
+ order_id,
846
+ order_version=order_version,
847
+ effective_date=effective_date,
848
+ updated_order_line_attributes=updated_order_line_attributes,
849
+ request_options=request_options,
850
+ )
851
+ return _response.data
852
+
853
+ async def get_invoices(
854
+ self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None
855
+ ) -> typing.List[Invoice]:
856
+ """
857
+ Retrieves all invoices associated with a specific order.
858
+
859
+ Parameters
860
+ ----------
861
+ order_id : str
862
+ The order ID (can be internal ID or display ID)
863
+
864
+ request_options : typing.Optional[RequestOptions]
865
+ Request-specific configuration.
866
+
867
+ Returns
868
+ -------
869
+ typing.List[Invoice]
870
+ Success response
871
+
872
+ Examples
873
+ --------
874
+ import asyncio
875
+
876
+ from paid import AsyncPaid
877
+
878
+ client = AsyncPaid(
879
+ token="YOUR_TOKEN",
880
+ )
881
+
882
+
883
+ async def main() -> None:
884
+ await client.orders.get_invoices(
885
+ order_id="orderId",
886
+ )
887
+
888
+
889
+ asyncio.run(main())
890
+ """
891
+ _response = await self._raw_client.get_invoices(order_id, request_options=request_options)
892
+ return _response.data