paid-python 0.6.0__tar.gz → 1.0.0a1__tar.gz
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_python-0.6.0 → paid_python-1.0.0a1}/PKG-INFO +27 -11
- {paid_python-0.6.0 → paid_python-1.0.0a1}/README.md +21 -7
- {paid_python-0.6.0 → paid_python-1.0.0a1}/pyproject.toml +20 -46
- paid_python-1.0.0a1/src/paid/__init__.py +102 -0
- paid_python-1.0.0a1/src/paid/client.py +158 -0
- paid_python-1.0.0a1/src/paid/contacts/client.py +826 -0
- paid_python-1.0.0a1/src/paid/contacts/raw_client.py +1460 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/core/client_wrapper.py +9 -10
- paid_python-1.0.0a1/src/paid/customers/client.py +910 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/customers/raw_client.py +731 -537
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/environment.py +1 -1
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/errors/bad_request_error.py +2 -2
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/errors/forbidden_error.py +2 -2
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/errors/internal_server_error.py +2 -2
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/errors/not_found_error.py +2 -2
- paid_python-1.0.0a1/src/paid/invoices/client.py +369 -0
- paid_python-1.0.0a1/src/paid/invoices/raw_client.py +692 -0
- paid_python-1.0.0a1/src/paid/orders/client.py +700 -0
- paid_python-1.0.0a1/src/paid/orders/raw_client.py +1167 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/products/client.py +129 -265
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/products/raw_client.py +563 -233
- paid_python-1.0.0a1/src/paid/signals/client.py +130 -0
- paid_python-1.0.0a1/src/paid/signals/raw_client.py +190 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/autoinstrumentation.py +12 -6
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/context_manager.py +2 -6
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/distributed_tracing.py +3 -3
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/signal.py +3 -3
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/openai_agents/openaiAgentsHook.py +1 -1
- paid_python-1.0.0a1/src/paid/types/__init__.py +81 -0
- paid_python-1.0.0a1/src/paid/types/attribution.py +8 -0
- paid_python-0.6.0/src/paid/types/agent_attribute.py → paid_python-1.0.0a1/src/paid/types/bulk_signals_response.py +4 -5
- paid_python-1.0.0a1/src/paid/types/contact.py +34 -0
- paid_python-0.6.0/src/paid/types/address.py → paid_python-1.0.0a1/src/paid/types/contact_billing_address.py +6 -7
- paid_python-0.6.0/src/paid/types/cost_amount.py → paid_python-1.0.0a1/src/paid/types/contact_list_response.py +5 -14
- paid_python-1.0.0a1/src/paid/types/customer.py +39 -0
- paid_python-1.0.0a1/src/paid/types/customer_attribution.py +8 -0
- paid_python-1.0.0a1/src/paid/types/customer_billing_address.py +26 -0
- paid_python-0.6.0/src/paid/types/usage_summary_order.py → paid_python-1.0.0a1/src/paid/types/customer_by_external_id.py +3 -5
- paid_python-0.6.0/src/paid/types/usage_summary_order_line.py → paid_python-1.0.0a1/src/paid/types/customer_by_id.py +3 -5
- paid_python-1.0.0a1/src/paid/types/customer_creation_state.py +5 -0
- paid_python-1.0.0a1/src/paid/types/customer_list_response.py +22 -0
- paid_python-1.0.0a1/src/paid/types/empty_response.py +17 -0
- paid_python-0.6.0/src/paid/types/error.py → paid_python-1.0.0a1/src/paid/types/error_response.py +4 -7
- paid_python-1.0.0a1/src/paid/types/invoice.py +57 -0
- paid_python-1.0.0a1/src/paid/types/invoice_line.py +42 -0
- paid_python-1.0.0a1/src/paid/types/invoice_line_payment_status.py +7 -0
- paid_python-1.0.0a1/src/paid/types/invoice_lines_response.py +22 -0
- paid_python-1.0.0a1/src/paid/types/invoice_list_response.py +22 -0
- paid_python-1.0.0a1/src/paid/types/invoice_payment_status.py +5 -0
- paid_python-1.0.0a1/src/paid/types/invoice_source.py +5 -0
- paid_python-1.0.0a1/src/paid/types/invoice_status.py +7 -0
- paid_python-1.0.0a1/src/paid/types/invoice_tax_status.py +7 -0
- paid_python-1.0.0a1/src/paid/types/order.py +50 -0
- paid_python-1.0.0a1/src/paid/types/order_creation_state.py +5 -0
- paid_python-0.6.0/src/paid/types/order_line_attribute.py → paid_python-1.0.0a1/src/paid/types/order_line.py +8 -8
- paid_python-1.0.0a1/src/paid/types/order_lines_response.py +22 -0
- paid_python-1.0.0a1/src/paid/types/order_list_response.py +22 -0
- paid_python-1.0.0a1/src/paid/types/pagination.py +24 -0
- paid_python-0.6.0/src/paid/types/agent.py → paid_python-1.0.0a1/src/paid/types/product.py +8 -8
- paid_python-0.6.0/src/paid/types/tier.py → paid_python-1.0.0a1/src/paid/types/product_by_external_id.py +5 -4
- paid_python-0.6.0/src/paid/types/traces_response.py → paid_python-1.0.0a1/src/paid/types/product_by_id.py +5 -7
- paid_python-1.0.0a1/src/paid/types/product_list_response.py +22 -0
- paid_python-0.6.0/src/paid/types/agent_price_point_tiers.py → paid_python-1.0.0a1/src/paid/types/signal.py +8 -4
- paid_python-0.6.0/src/paid/types/contact.py → paid_python-1.0.0a1/src/paid/types/update_contact_request.py +5 -17
- paid_python-1.0.0a1/src/paid/types/update_customer_request.py +38 -0
- paid_python-0.6.0/src/paid/types/product_update.py → paid_python-1.0.0a1/src/paid/types/update_product_request.py +2 -12
- paid_python-0.6.0/src/paid/__init__.py +0 -132
- paid_python-0.6.0/src/paid/agents/client.py +0 -880
- paid_python-0.6.0/src/paid/agents/raw_client.py +0 -785
- paid_python-0.6.0/src/paid/client.py +0 -635
- paid_python-0.6.0/src/paid/contacts/client.py +0 -544
- paid_python-0.6.0/src/paid/contacts/raw_client.py +0 -532
- paid_python-0.6.0/src/paid/customers/client.py +0 -1206
- paid_python-0.6.0/src/paid/orders/__init__.py +0 -7
- paid_python-0.6.0/src/paid/orders/client.py +0 -457
- paid_python-0.6.0/src/paid/orders/lines/client.py +0 -144
- paid_python-0.6.0/src/paid/orders/lines/raw_client.py +0 -129
- paid_python-0.6.0/src/paid/orders/raw_client.py +0 -459
- paid_python-0.6.0/src/paid/plans/client.py +0 -332
- paid_python-0.6.0/src/paid/plans/raw_client.py +0 -464
- paid_python-0.6.0/src/paid/products/__init__.py +0 -7
- paid_python-0.6.0/src/paid/products/types/__init__.py +0 -7
- paid_python-0.6.0/src/paid/products/types/product_create_type.py +0 -5
- paid_python-0.6.0/src/paid/traces/client.py +0 -218
- paid_python-0.6.0/src/paid/traces/raw_client.py +0 -226
- paid_python-0.6.0/src/paid/types/__init__.py +0 -105
- paid_python-0.6.0/src/paid/types/agent_price_point.py +0 -27
- paid_python-0.6.0/src/paid/types/agent_update.py +0 -29
- paid_python-0.6.0/src/paid/types/api_error.py +0 -29
- paid_python-0.6.0/src/paid/types/billing_frequency.py +0 -5
- paid_python-0.6.0/src/paid/types/charge_type.py +0 -5
- paid_python-0.6.0/src/paid/types/cost_trace.py +0 -55
- paid_python-0.6.0/src/paid/types/cost_traces_response.py +0 -26
- paid_python-0.6.0/src/paid/types/creation_source.py +0 -5
- paid_python-0.6.0/src/paid/types/creation_state.py +0 -5
- paid_python-0.6.0/src/paid/types/customer.py +0 -46
- paid_python-0.6.0/src/paid/types/customer_update.py +0 -40
- paid_python-0.6.0/src/paid/types/entitlement_usage.py +0 -48
- paid_python-0.6.0/src/paid/types/order.py +0 -49
- paid_python-0.6.0/src/paid/types/order_line.py +0 -45
- paid_python-0.6.0/src/paid/types/order_line_attribute_create_one.py +0 -5
- paid_python-0.6.0/src/paid/types/order_line_attribute_pricing.py +0 -33
- paid_python-0.6.0/src/paid/types/order_line_create.py +0 -72
- paid_python-0.6.0/src/paid/types/pagination_meta.py +0 -84
- paid_python-0.6.0/src/paid/types/plan.py +0 -81
- paid_python-0.6.0/src/paid/types/plan_group.py +0 -60
- paid_python-0.6.0/src/paid/types/plan_plan_products_item.py +0 -35
- paid_python-0.6.0/src/paid/types/plan_plan_products_item_plan_product_attribute_item.py +0 -34
- paid_python-0.6.0/src/paid/types/price_point.py +0 -25
- paid_python-0.6.0/src/paid/types/pricing.py +0 -31
- paid_python-0.6.0/src/paid/types/pricing_model_type.py +0 -7
- paid_python-0.6.0/src/paid/types/product.py +0 -56
- paid_python-0.6.0/src/paid/types/product_type.py +0 -5
- paid_python-0.6.0/src/paid/types/product_update_type.py +0 -5
- paid_python-0.6.0/src/paid/types/salutation.py +0 -5
- paid_python-0.6.0/src/paid/types/signal.py +0 -53
- paid_python-0.6.0/src/paid/types/signal_v_2.py +0 -56
- paid_python-0.6.0/src/paid/types/tax_exempt_status.py +0 -5
- paid_python-0.6.0/src/paid/types/trace.py +0 -69
- paid_python-0.6.0/src/paid/types/usage_pagination_meta.py +0 -43
- paid_python-0.6.0/src/paid/types/usage_summaries_response.py +0 -26
- paid_python-0.6.0/src/paid/types/usage_summary.py +0 -121
- paid_python-0.6.0/src/paid/usage/__init__.py +0 -7
- paid_python-0.6.0/src/paid/usage/client.py +0 -321
- paid_python-0.6.0/src/paid/usage/raw_client.py +0 -387
- paid_python-0.6.0/src/paid/usage/types/__init__.py +0 -7
- paid_python-0.6.0/src/paid/usage/types/usage_check_usage_response.py +0 -53
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/__init__.py +0 -54
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/__init__.py +0 -399
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/audio_wrappers.py +0 -247
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/chat_wrappers.py +0 -1192
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/completion_wrappers.py +0 -292
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/config.py +0 -15
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py +0 -311
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/event_emitter.py +0 -108
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/event_models.py +0 -41
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py +0 -68
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/span_utils.py +0 -0
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/utils.py +0 -213
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/v0/__init__.py +0 -176
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/v1/__init__.py +0 -394
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/v1/assistant_wrappers.py +0 -329
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/v1/event_handler_wrapper.py +0 -134
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/v1/responses_wrappers.py +0 -1113
- paid_python-0.6.0/vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/version.py +0 -1
- {paid_python-0.6.0 → paid_python-1.0.0a1}/LICENSE +0 -0
- {paid_python-0.6.0/src/paid/agents → paid_python-1.0.0a1/src/paid/contacts}/__init__.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/core/__init__.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/core/api_error.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/core/datetime_utils.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/core/file.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/core/force_multipart.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/core/http_client.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/core/http_response.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/core/jsonable_encoder.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/core/pydantic_utilities.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/core/query_encoder.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/core/remove_none_from_dict.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/core/request_options.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/core/serialization.py +0 -0
- {paid_python-0.6.0/src/paid/contacts → paid_python-1.0.0a1/src/paid/customers}/__init__.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/errors/__init__.py +0 -0
- {paid_python-0.6.0/src/paid/customers → paid_python-1.0.0a1/src/paid/invoices}/__init__.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/logger.py +0 -0
- {paid_python-0.6.0/src/paid/orders/lines → paid_python-1.0.0a1/src/paid/orders}/__init__.py +0 -0
- {paid_python-0.6.0/src/paid/plans → paid_python-1.0.0a1/src/paid/products}/__init__.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/py.typed +0 -0
- {paid_python-0.6.0/src/paid/traces → paid_python-1.0.0a1/src/paid/signals}/__init__.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/__init__.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/context_data.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/tracing.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/__init__.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/anthropic/__init__.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/anthropic/anthropicWrapper.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/bedrock/__init__.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/bedrock/bedrockWrapper.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/gemini/__init__.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/gemini/geminiWrapper.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/langchain/__init__.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/langchain/paidLangChainCallback.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/llamaindex/__init__.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/llamaindex/llamaIndexWrapper.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/mistral/__init__.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/mistral/mistralWrapper.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/openai/__init__.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/openai/openAiWrapper.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/openai_agents/__init__.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/tracing/wrappers/utils.py +0 -0
- {paid_python-0.6.0 → paid_python-1.0.0a1}/src/paid/version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: paid-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0a1
|
|
4
4
|
Summary:
|
|
5
5
|
Requires-Python: >=3.9,<3.14
|
|
6
6
|
Classifier: Intended Audience :: Developers
|
|
@@ -15,9 +15,10 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.10
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
19
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
20
|
Classifier: Typing :: Typed
|
|
20
|
-
Requires-Dist: httpx (>=0.21.
|
|
21
|
+
Requires-Dist: httpx (>=0.21.2)
|
|
21
22
|
Requires-Dist: mutagen (>=1.47.0)
|
|
22
23
|
Requires-Dist: openinference-instrumentation-bedrock (>=0.1.0)
|
|
23
24
|
Requires-Dist: openinference-instrumentation-google-genai (>=0.1.8)
|
|
@@ -26,9 +27,10 @@ Requires-Dist: openinference-instrumentation-openai-agents (>=1.0.0)
|
|
|
26
27
|
Requires-Dist: opentelemetry-api (>=1.23.0)
|
|
27
28
|
Requires-Dist: opentelemetry-exporter-otlp-proto-http (>=1.23.0)
|
|
28
29
|
Requires-Dist: opentelemetry-instrumentation-anthropic (>=0.47.0)
|
|
30
|
+
Requires-Dist: opentelemetry-instrumentation-openai (>=0.50.0)
|
|
29
31
|
Requires-Dist: opentelemetry-sdk (>=1.23.0)
|
|
30
|
-
Requires-Dist: pydantic (>=1.9.
|
|
31
|
-
Requires-Dist: pydantic-core (>=2.18.0)
|
|
32
|
+
Requires-Dist: pydantic (>=1.9.2)
|
|
33
|
+
Requires-Dist: pydantic-core (>=2.18.2,<3.0.0)
|
|
32
34
|
Requires-Dist: python-dotenv (>=0.15.0)
|
|
33
35
|
Requires-Dist: typing_extensions (>=4.0.0)
|
|
34
36
|
Description-Content-Type: text/markdown
|
|
@@ -76,7 +78,7 @@ from paid import Paid
|
|
|
76
78
|
|
|
77
79
|
client = Paid(token="API_KEY")
|
|
78
80
|
|
|
79
|
-
client.customers.
|
|
81
|
+
client.customers.create_a_new_customer(
|
|
80
82
|
name="name"
|
|
81
83
|
)
|
|
82
84
|
```
|
|
@@ -87,7 +89,7 @@ The SDK provides Python classes for all request and response types. These are au
|
|
|
87
89
|
|
|
88
90
|
```python
|
|
89
91
|
# Example of creating a customer
|
|
90
|
-
response = client.customers.
|
|
92
|
+
response = client.customers.create_a_new_customer(
|
|
91
93
|
name="John Doe",
|
|
92
94
|
)
|
|
93
95
|
|
|
@@ -101,13 +103,21 @@ print(response.email)
|
|
|
101
103
|
When the API returns a non-success status code (4xx or 5xx response), the SDK will raise an appropriate error.
|
|
102
104
|
|
|
103
105
|
```python
|
|
106
|
+
from paid import BadRequestError, NotFoundError
|
|
107
|
+
from paid.core.api_error import ApiError
|
|
108
|
+
|
|
104
109
|
try:
|
|
105
|
-
client.customers.
|
|
106
|
-
except
|
|
110
|
+
client.customers.create_a_new_customer(name="John Doe")
|
|
111
|
+
except BadRequestError as e:
|
|
112
|
+
print(e.status_code) # 400
|
|
113
|
+
print(e.body) # ErrorResponse with error details
|
|
114
|
+
except NotFoundError as e:
|
|
115
|
+
print(e.status_code) # 404
|
|
116
|
+
print(e.body)
|
|
117
|
+
except ApiError as e:
|
|
118
|
+
# Catch-all for other API errors
|
|
107
119
|
print(e.status_code)
|
|
108
|
-
print(e.message)
|
|
109
120
|
print(e.body)
|
|
110
|
-
print(e.raw_response)
|
|
111
121
|
```
|
|
112
122
|
|
|
113
123
|
## Logging
|
|
@@ -152,6 +162,7 @@ export PAID_ENABLED=false
|
|
|
152
162
|
```
|
|
153
163
|
|
|
154
164
|
This is useful for:
|
|
165
|
+
|
|
155
166
|
- Development/testing environments where tracing isn't needed
|
|
156
167
|
- Temporarily disabling tracing without modifying code
|
|
157
168
|
- Feature flagging in different deployment environments
|
|
@@ -213,11 +224,13 @@ Both approaches:
|
|
|
213
224
|
- Support the same parameters: `external_customer_id`, `external_product_id`, `tracing_token`, `store_prompt`, `metadata`
|
|
214
225
|
|
|
215
226
|
* Note - if it happens that you're calling `paid_tracing` from non-main thread, then it's advised to initialize from main thread:
|
|
227
|
+
|
|
216
228
|
```python
|
|
217
229
|
from paid.tracing import initialize_tracing
|
|
218
230
|
initialize_tracing()
|
|
219
231
|
```
|
|
220
|
-
|
|
232
|
+
|
|
233
|
+
- `initialize_tracing` also accepts optional arguments like OTEL collector endpoint and api key if you want to reroute your tracing somewhere else :)
|
|
221
234
|
|
|
222
235
|
### Using the Paid wrappers
|
|
223
236
|
|
|
@@ -300,6 +313,7 @@ You can attach custom metadata to your traces by passing a `metadata` dictionary
|
|
|
300
313
|
|
|
301
314
|
process_event(incoming_event)
|
|
302
315
|
```
|
|
316
|
+
|
|
303
317
|
</Tab>
|
|
304
318
|
|
|
305
319
|
<Tab title="Python - Context Manager">
|
|
@@ -334,6 +348,7 @@ You can attach custom metadata to your traces by passing a `metadata` dictionary
|
|
|
334
348
|
):
|
|
335
349
|
process_event(incoming_event)
|
|
336
350
|
```
|
|
351
|
+
|
|
337
352
|
</Tab>
|
|
338
353
|
|
|
339
354
|
<Tab title="Node.js">
|
|
@@ -770,6 +785,7 @@ await do_work()
|
|
|
770
785
|
### Paid OTEL Tracer Provider
|
|
771
786
|
|
|
772
787
|
If you would like to use the Paid OTEL tracer provider:
|
|
788
|
+
|
|
773
789
|
```python
|
|
774
790
|
from paid.tracing import get_paid_tracer_provider
|
|
775
791
|
paid_tracer_provider = get_paid_tracer_provider()
|
|
@@ -41,7 +41,7 @@ from paid import Paid
|
|
|
41
41
|
|
|
42
42
|
client = Paid(token="API_KEY")
|
|
43
43
|
|
|
44
|
-
client.customers.
|
|
44
|
+
client.customers.create_a_new_customer(
|
|
45
45
|
name="name"
|
|
46
46
|
)
|
|
47
47
|
```
|
|
@@ -52,7 +52,7 @@ The SDK provides Python classes for all request and response types. These are au
|
|
|
52
52
|
|
|
53
53
|
```python
|
|
54
54
|
# Example of creating a customer
|
|
55
|
-
response = client.customers.
|
|
55
|
+
response = client.customers.create_a_new_customer(
|
|
56
56
|
name="John Doe",
|
|
57
57
|
)
|
|
58
58
|
|
|
@@ -66,13 +66,21 @@ print(response.email)
|
|
|
66
66
|
When the API returns a non-success status code (4xx or 5xx response), the SDK will raise an appropriate error.
|
|
67
67
|
|
|
68
68
|
```python
|
|
69
|
+
from paid import BadRequestError, NotFoundError
|
|
70
|
+
from paid.core.api_error import ApiError
|
|
71
|
+
|
|
69
72
|
try:
|
|
70
|
-
client.customers.
|
|
71
|
-
except
|
|
73
|
+
client.customers.create_a_new_customer(name="John Doe")
|
|
74
|
+
except BadRequestError as e:
|
|
75
|
+
print(e.status_code) # 400
|
|
76
|
+
print(e.body) # ErrorResponse with error details
|
|
77
|
+
except NotFoundError as e:
|
|
78
|
+
print(e.status_code) # 404
|
|
79
|
+
print(e.body)
|
|
80
|
+
except ApiError as e:
|
|
81
|
+
# Catch-all for other API errors
|
|
72
82
|
print(e.status_code)
|
|
73
|
-
print(e.message)
|
|
74
83
|
print(e.body)
|
|
75
|
-
print(e.raw_response)
|
|
76
84
|
```
|
|
77
85
|
|
|
78
86
|
## Logging
|
|
@@ -117,6 +125,7 @@ export PAID_ENABLED=false
|
|
|
117
125
|
```
|
|
118
126
|
|
|
119
127
|
This is useful for:
|
|
128
|
+
|
|
120
129
|
- Development/testing environments where tracing isn't needed
|
|
121
130
|
- Temporarily disabling tracing without modifying code
|
|
122
131
|
- Feature flagging in different deployment environments
|
|
@@ -178,11 +187,13 @@ Both approaches:
|
|
|
178
187
|
- Support the same parameters: `external_customer_id`, `external_product_id`, `tracing_token`, `store_prompt`, `metadata`
|
|
179
188
|
|
|
180
189
|
* Note - if it happens that you're calling `paid_tracing` from non-main thread, then it's advised to initialize from main thread:
|
|
190
|
+
|
|
181
191
|
```python
|
|
182
192
|
from paid.tracing import initialize_tracing
|
|
183
193
|
initialize_tracing()
|
|
184
194
|
```
|
|
185
|
-
|
|
195
|
+
|
|
196
|
+
- `initialize_tracing` also accepts optional arguments like OTEL collector endpoint and api key if you want to reroute your tracing somewhere else :)
|
|
186
197
|
|
|
187
198
|
### Using the Paid wrappers
|
|
188
199
|
|
|
@@ -265,6 +276,7 @@ You can attach custom metadata to your traces by passing a `metadata` dictionary
|
|
|
265
276
|
|
|
266
277
|
process_event(incoming_event)
|
|
267
278
|
```
|
|
279
|
+
|
|
268
280
|
</Tab>
|
|
269
281
|
|
|
270
282
|
<Tab title="Python - Context Manager">
|
|
@@ -299,6 +311,7 @@ You can attach custom metadata to your traces by passing a `metadata` dictionary
|
|
|
299
311
|
):
|
|
300
312
|
process_event(incoming_event)
|
|
301
313
|
```
|
|
314
|
+
|
|
302
315
|
</Tab>
|
|
303
316
|
|
|
304
317
|
<Tab title="Node.js">
|
|
@@ -735,6 +748,7 @@ await do_work()
|
|
|
735
748
|
### Paid OTEL Tracer Provider
|
|
736
749
|
|
|
737
750
|
If you would like to use the Paid OTEL tracer provider:
|
|
751
|
+
|
|
738
752
|
```python
|
|
739
753
|
from paid.tracing import get_paid_tracer_provider
|
|
740
754
|
paid_tracer_provider = get_paid_tracer_provider()
|
|
@@ -3,7 +3,7 @@ name = "paid-python"
|
|
|
3
3
|
|
|
4
4
|
[tool.poetry]
|
|
5
5
|
name = "paid-python"
|
|
6
|
-
version = "0.
|
|
6
|
+
version = "1.0.0-alpha1"
|
|
7
7
|
description = ""
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
authors = []
|
|
@@ -13,6 +13,7 @@ classifiers = [
|
|
|
13
13
|
"Intended Audience :: Developers",
|
|
14
14
|
"Programming Language :: Python",
|
|
15
15
|
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.8",
|
|
16
17
|
"Programming Language :: Python :: 3.9",
|
|
17
18
|
"Programming Language :: Python :: 3.10",
|
|
18
19
|
"Programming Language :: Python :: 3.11",
|
|
@@ -26,8 +27,7 @@ classifiers = [
|
|
|
26
27
|
"Typing :: Typed"
|
|
27
28
|
]
|
|
28
29
|
packages = [
|
|
29
|
-
{ include = "paid", from = "src"}
|
|
30
|
-
{ include = "opentelemetry", from = "vendor/patched-instrumentation-openllmetry/packages/opentelemetry-instrumentation-openai" },
|
|
30
|
+
{ include = "paid", from = "src"}
|
|
31
31
|
]
|
|
32
32
|
|
|
33
33
|
[project.urls]
|
|
@@ -35,21 +35,21 @@ Repository = 'https://github.com/paid-ai/paid-python'
|
|
|
35
35
|
|
|
36
36
|
[tool.poetry.dependencies]
|
|
37
37
|
python = ">=3.9,<3.14"
|
|
38
|
-
httpx = ">=0.21.
|
|
39
|
-
pydantic = ">=1.9.0"
|
|
40
|
-
pydantic-core = ">=2.18.0"
|
|
41
|
-
typing_extensions = ">= 4.0.0"
|
|
42
|
-
opentelemetry-api = ">=1.23.0"
|
|
43
|
-
opentelemetry-sdk = ">=1.23.0"
|
|
44
|
-
opentelemetry-exporter-otlp-proto-http = ">=1.23.0"
|
|
38
|
+
httpx = ">=0.21.2"
|
|
45
39
|
mutagen = ">=1.47.0"
|
|
46
|
-
python-dotenv = ">=0.15.0"
|
|
47
|
-
opentelemetry-instrumentation-anthropic = ">=0.47.0"
|
|
48
|
-
# opentelemetry-instrumentation-openai is vendored from git a submodule under vendor/patched-instrumentation-openllmetry
|
|
49
|
-
openinference-instrumentation-langchain = ">=0.1.55"
|
|
50
|
-
openinference-instrumentation-openai-agents = ">=1.0.0"
|
|
51
40
|
openinference-instrumentation-bedrock = ">=0.1.0"
|
|
52
41
|
openinference-instrumentation-google-genai = ">=0.1.8"
|
|
42
|
+
openinference-instrumentation-langchain = ">=0.1.55"
|
|
43
|
+
openinference-instrumentation-openai-agents = ">=1.0.0"
|
|
44
|
+
opentelemetry-api = ">=1.23.0"
|
|
45
|
+
opentelemetry-exporter-otlp-proto-http = ">=1.23.0"
|
|
46
|
+
opentelemetry-instrumentation-anthropic = ">=0.47.0"
|
|
47
|
+
opentelemetry-instrumentation-openai = ">=0.50.0"
|
|
48
|
+
opentelemetry-sdk = ">=1.23.0"
|
|
49
|
+
pydantic = ">= 1.9.2"
|
|
50
|
+
pydantic-core = "^2.18.2"
|
|
51
|
+
python-dotenv = ">=0.15.0"
|
|
52
|
+
typing_extensions = ">= 4.0.0"
|
|
53
53
|
|
|
54
54
|
[tool.poetry.group.dev.dependencies]
|
|
55
55
|
mypy = "==1.13.0"
|
|
@@ -57,48 +57,22 @@ pytest = "^7.4.0"
|
|
|
57
57
|
pytest-asyncio = "^0.23.5"
|
|
58
58
|
python-dateutil = "^2.9.0"
|
|
59
59
|
types-python-dateutil = "^2.9.0.20240316"
|
|
60
|
-
ruff = "==0.11.5"
|
|
61
|
-
|
|
62
|
-
# Peer-dependencies, but useful to have for development
|
|
63
|
-
mistralai = ">=1.9.0"
|
|
64
60
|
anthropic = ">=0.57.0"
|
|
65
|
-
llama-index-core = ">=0.13.0"
|
|
66
|
-
llama-index-llms-openai = ">=0.5.0"
|
|
67
61
|
google-genai = ">=1.19.0"
|
|
68
|
-
openai-agents = ">=0.2.0"
|
|
69
62
|
langchain-core = ">=0.1.0"
|
|
63
|
+
llama-index-core = ">=0.13.0"
|
|
64
|
+
llama-index-llms-openai = ">=0.5.0"
|
|
65
|
+
mistralai = ">=1.9.0"
|
|
70
66
|
openai = ">=1.12.0"
|
|
67
|
+
openai-agents = ">=0.2.0"
|
|
68
|
+
ruff = "==0.11.5"
|
|
71
69
|
|
|
72
70
|
[tool.pytest.ini_options]
|
|
73
71
|
testpaths = [ "tests" ]
|
|
74
72
|
asyncio_mode = "auto"
|
|
75
|
-
# TODO(Ata): remove this once the openai instrumentation isn't vendored anymore
|
|
76
|
-
norecursedirs = ["vendor/patched-instrumentation-openllmetry"]
|
|
77
73
|
|
|
78
74
|
[tool.mypy]
|
|
79
75
|
plugins = ["pydantic.mypy"]
|
|
80
|
-
exclude = [
|
|
81
|
-
# TODO(Ata): remove this once the openai instrumentation isn't vendored anymore
|
|
82
|
-
"^vendor/patched-instrumentation-openllmetry/",
|
|
83
|
-
]
|
|
84
|
-
|
|
85
|
-
[[tool.mypy.overrides]]
|
|
86
|
-
module = [
|
|
87
|
-
"anthropic",
|
|
88
|
-
"anthropic.*",
|
|
89
|
-
"openai",
|
|
90
|
-
"mistralai",
|
|
91
|
-
"mistralai.*",
|
|
92
|
-
"llama_index.*",
|
|
93
|
-
"google.*",
|
|
94
|
-
"agents",
|
|
95
|
-
"agents.*",
|
|
96
|
-
"langchain_core.*",
|
|
97
|
-
"opentelemetry.instrumentation.openai", # TODO(Ata): remove this once the openai instrumentation isn't vendored anymore
|
|
98
|
-
"opentelemetry.instrumentation.openai.*",
|
|
99
|
-
]
|
|
100
|
-
ignore_missing_imports = true
|
|
101
|
-
ignore_errors = true # remove once openai instrumentor is upstream
|
|
102
76
|
|
|
103
77
|
[tool.ruff]
|
|
104
78
|
line-length = 120
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
# isort: skip_file
|
|
4
|
+
|
|
5
|
+
from .types import (
|
|
6
|
+
Attribution,
|
|
7
|
+
BulkSignalsResponse,
|
|
8
|
+
Contact,
|
|
9
|
+
ContactBillingAddress,
|
|
10
|
+
ContactListResponse,
|
|
11
|
+
Customer,
|
|
12
|
+
CustomerAttribution,
|
|
13
|
+
CustomerBillingAddress,
|
|
14
|
+
CustomerByExternalId,
|
|
15
|
+
CustomerById,
|
|
16
|
+
CustomerCreationState,
|
|
17
|
+
CustomerListResponse,
|
|
18
|
+
EmptyResponse,
|
|
19
|
+
ErrorResponse,
|
|
20
|
+
Invoice,
|
|
21
|
+
InvoiceLine,
|
|
22
|
+
InvoiceLinePaymentStatus,
|
|
23
|
+
InvoiceLinesResponse,
|
|
24
|
+
InvoiceListResponse,
|
|
25
|
+
InvoicePaymentStatus,
|
|
26
|
+
InvoiceSource,
|
|
27
|
+
InvoiceStatus,
|
|
28
|
+
InvoiceTaxStatus,
|
|
29
|
+
Order,
|
|
30
|
+
OrderCreationState,
|
|
31
|
+
OrderLine,
|
|
32
|
+
OrderLinesResponse,
|
|
33
|
+
OrderListResponse,
|
|
34
|
+
Pagination,
|
|
35
|
+
Product,
|
|
36
|
+
ProductByExternalId,
|
|
37
|
+
ProductById,
|
|
38
|
+
ProductListResponse,
|
|
39
|
+
Signal,
|
|
40
|
+
UpdateContactRequest,
|
|
41
|
+
UpdateCustomerRequest,
|
|
42
|
+
UpdateProductRequest,
|
|
43
|
+
)
|
|
44
|
+
from .errors import BadRequestError, ForbiddenError, InternalServerError, NotFoundError
|
|
45
|
+
from . import contacts, customers, invoices, orders, products, signals
|
|
46
|
+
from .client import AsyncPaid, Paid
|
|
47
|
+
from .environment import PaidEnvironment
|
|
48
|
+
from .version import __version__
|
|
49
|
+
|
|
50
|
+
__all__ = [
|
|
51
|
+
"AsyncPaid",
|
|
52
|
+
"Attribution",
|
|
53
|
+
"BadRequestError",
|
|
54
|
+
"BulkSignalsResponse",
|
|
55
|
+
"Contact",
|
|
56
|
+
"ContactBillingAddress",
|
|
57
|
+
"ContactListResponse",
|
|
58
|
+
"Customer",
|
|
59
|
+
"CustomerAttribution",
|
|
60
|
+
"CustomerBillingAddress",
|
|
61
|
+
"CustomerByExternalId",
|
|
62
|
+
"CustomerById",
|
|
63
|
+
"CustomerCreationState",
|
|
64
|
+
"CustomerListResponse",
|
|
65
|
+
"EmptyResponse",
|
|
66
|
+
"ErrorResponse",
|
|
67
|
+
"ForbiddenError",
|
|
68
|
+
"InternalServerError",
|
|
69
|
+
"Invoice",
|
|
70
|
+
"InvoiceLine",
|
|
71
|
+
"InvoiceLinePaymentStatus",
|
|
72
|
+
"InvoiceLinesResponse",
|
|
73
|
+
"InvoiceListResponse",
|
|
74
|
+
"InvoicePaymentStatus",
|
|
75
|
+
"InvoiceSource",
|
|
76
|
+
"InvoiceStatus",
|
|
77
|
+
"InvoiceTaxStatus",
|
|
78
|
+
"NotFoundError",
|
|
79
|
+
"Order",
|
|
80
|
+
"OrderCreationState",
|
|
81
|
+
"OrderLine",
|
|
82
|
+
"OrderLinesResponse",
|
|
83
|
+
"OrderListResponse",
|
|
84
|
+
"Pagination",
|
|
85
|
+
"Paid",
|
|
86
|
+
"PaidEnvironment",
|
|
87
|
+
"Product",
|
|
88
|
+
"ProductByExternalId",
|
|
89
|
+
"ProductById",
|
|
90
|
+
"ProductListResponse",
|
|
91
|
+
"Signal",
|
|
92
|
+
"UpdateContactRequest",
|
|
93
|
+
"UpdateCustomerRequest",
|
|
94
|
+
"UpdateProductRequest",
|
|
95
|
+
"__version__",
|
|
96
|
+
"contacts",
|
|
97
|
+
"customers",
|
|
98
|
+
"invoices",
|
|
99
|
+
"orders",
|
|
100
|
+
"products",
|
|
101
|
+
"signals",
|
|
102
|
+
]
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
from .contacts.client import AsyncContactsClient, ContactsClient
|
|
7
|
+
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
+
from .customers.client import AsyncCustomersClient, CustomersClient
|
|
9
|
+
from .environment import PaidEnvironment
|
|
10
|
+
from .invoices.client import AsyncInvoicesClient, InvoicesClient
|
|
11
|
+
from .orders.client import AsyncOrdersClient, OrdersClient
|
|
12
|
+
from .products.client import AsyncProductsClient, ProductsClient
|
|
13
|
+
from .signals.client import AsyncSignalsClient, SignalsClient
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Paid:
|
|
17
|
+
"""
|
|
18
|
+
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
base_url : typing.Optional[str]
|
|
23
|
+
The base url to use for requests from the client.
|
|
24
|
+
|
|
25
|
+
environment : PaidEnvironment
|
|
26
|
+
The environment to use for requests from the client. from .environment import PaidEnvironment
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
Defaults to PaidEnvironment.DEFAULT
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
token : typing.Union[str, typing.Callable[[], str]]
|
|
35
|
+
timeout : typing.Optional[float]
|
|
36
|
+
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
37
|
+
|
|
38
|
+
follow_redirects : typing.Optional[bool]
|
|
39
|
+
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
|
40
|
+
|
|
41
|
+
httpx_client : typing.Optional[httpx.Client]
|
|
42
|
+
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
|
43
|
+
|
|
44
|
+
Examples
|
|
45
|
+
--------
|
|
46
|
+
from paid import Paid
|
|
47
|
+
|
|
48
|
+
client = Paid(
|
|
49
|
+
token="YOUR_TOKEN",
|
|
50
|
+
)
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
def __init__(
|
|
54
|
+
self,
|
|
55
|
+
*,
|
|
56
|
+
base_url: typing.Optional[str] = None,
|
|
57
|
+
environment: PaidEnvironment = PaidEnvironment.DEFAULT,
|
|
58
|
+
token: typing.Union[str, typing.Callable[[], str]],
|
|
59
|
+
timeout: typing.Optional[float] = None,
|
|
60
|
+
follow_redirects: typing.Optional[bool] = True,
|
|
61
|
+
httpx_client: typing.Optional[httpx.Client] = None,
|
|
62
|
+
):
|
|
63
|
+
_defaulted_timeout = (
|
|
64
|
+
timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
|
|
65
|
+
)
|
|
66
|
+
self._client_wrapper = SyncClientWrapper(
|
|
67
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
68
|
+
token=token,
|
|
69
|
+
httpx_client=httpx_client
|
|
70
|
+
if httpx_client is not None
|
|
71
|
+
else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
|
|
72
|
+
if follow_redirects is not None
|
|
73
|
+
else httpx.Client(timeout=_defaulted_timeout),
|
|
74
|
+
timeout=_defaulted_timeout,
|
|
75
|
+
)
|
|
76
|
+
self.products = ProductsClient(client_wrapper=self._client_wrapper)
|
|
77
|
+
self.customers = CustomersClient(client_wrapper=self._client_wrapper)
|
|
78
|
+
self.contacts = ContactsClient(client_wrapper=self._client_wrapper)
|
|
79
|
+
self.orders = OrdersClient(client_wrapper=self._client_wrapper)
|
|
80
|
+
self.invoices = InvoicesClient(client_wrapper=self._client_wrapper)
|
|
81
|
+
self.signals = SignalsClient(client_wrapper=self._client_wrapper)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class AsyncPaid:
|
|
85
|
+
"""
|
|
86
|
+
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
87
|
+
|
|
88
|
+
Parameters
|
|
89
|
+
----------
|
|
90
|
+
base_url : typing.Optional[str]
|
|
91
|
+
The base url to use for requests from the client.
|
|
92
|
+
|
|
93
|
+
environment : PaidEnvironment
|
|
94
|
+
The environment to use for requests from the client. from .environment import PaidEnvironment
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
Defaults to PaidEnvironment.DEFAULT
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
token : typing.Union[str, typing.Callable[[], str]]
|
|
103
|
+
timeout : typing.Optional[float]
|
|
104
|
+
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
105
|
+
|
|
106
|
+
follow_redirects : typing.Optional[bool]
|
|
107
|
+
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
|
108
|
+
|
|
109
|
+
httpx_client : typing.Optional[httpx.AsyncClient]
|
|
110
|
+
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
|
111
|
+
|
|
112
|
+
Examples
|
|
113
|
+
--------
|
|
114
|
+
from paid import AsyncPaid
|
|
115
|
+
|
|
116
|
+
client = AsyncPaid(
|
|
117
|
+
token="YOUR_TOKEN",
|
|
118
|
+
)
|
|
119
|
+
"""
|
|
120
|
+
|
|
121
|
+
def __init__(
|
|
122
|
+
self,
|
|
123
|
+
*,
|
|
124
|
+
base_url: typing.Optional[str] = None,
|
|
125
|
+
environment: PaidEnvironment = PaidEnvironment.DEFAULT,
|
|
126
|
+
token: typing.Union[str, typing.Callable[[], str]],
|
|
127
|
+
timeout: typing.Optional[float] = None,
|
|
128
|
+
follow_redirects: typing.Optional[bool] = True,
|
|
129
|
+
httpx_client: typing.Optional[httpx.AsyncClient] = None,
|
|
130
|
+
):
|
|
131
|
+
_defaulted_timeout = (
|
|
132
|
+
timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
|
|
133
|
+
)
|
|
134
|
+
self._client_wrapper = AsyncClientWrapper(
|
|
135
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
136
|
+
token=token,
|
|
137
|
+
httpx_client=httpx_client
|
|
138
|
+
if httpx_client is not None
|
|
139
|
+
else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
|
|
140
|
+
if follow_redirects is not None
|
|
141
|
+
else httpx.AsyncClient(timeout=_defaulted_timeout),
|
|
142
|
+
timeout=_defaulted_timeout,
|
|
143
|
+
)
|
|
144
|
+
self.products = AsyncProductsClient(client_wrapper=self._client_wrapper)
|
|
145
|
+
self.customers = AsyncCustomersClient(client_wrapper=self._client_wrapper)
|
|
146
|
+
self.contacts = AsyncContactsClient(client_wrapper=self._client_wrapper)
|
|
147
|
+
self.orders = AsyncOrdersClient(client_wrapper=self._client_wrapper)
|
|
148
|
+
self.invoices = AsyncInvoicesClient(client_wrapper=self._client_wrapper)
|
|
149
|
+
self.signals = AsyncSignalsClient(client_wrapper=self._client_wrapper)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def _get_base_url(*, base_url: typing.Optional[str] = None, environment: PaidEnvironment) -> str:
|
|
153
|
+
if base_url is not None:
|
|
154
|
+
return base_url
|
|
155
|
+
elif environment is not None:
|
|
156
|
+
return environment.value
|
|
157
|
+
else:
|
|
158
|
+
raise Exception("Please pass in either base_url or environment to construct the client")
|