mollie-api-py 1.0.0__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.
- mollie/__init__.py +18 -0
- mollie/_hooks/__init__.py +5 -0
- mollie/_hooks/mollie_hooks.py +165 -0
- mollie/_hooks/registration.py +18 -0
- mollie/_hooks/sdkhooks.py +76 -0
- mollie/_hooks/types.py +113 -0
- mollie/_version.py +15 -0
- mollie/balance_transfers.py +651 -0
- mollie/balances.py +1105 -0
- mollie/basesdk.py +360 -0
- mollie/capabilities.py +209 -0
- mollie/captures.py +677 -0
- mollie/chargebacks_sdk.py +675 -0
- mollie/client_links.py +325 -0
- mollie/clients.py +409 -0
- mollie/customers.py +1563 -0
- mollie/delayed_routing.py +421 -0
- mollie/httpclient.py +125 -0
- mollie/invoices.py +429 -0
- mollie/mandates.py +895 -0
- mollie/methods.py +789 -0
- mollie/models/__init__.py +4002 -0
- mollie/models/address.py +29 -0
- mollie/models/amount.py +25 -0
- mollie/models/amount_nullable.py +24 -0
- mollie/models/apierror.py +40 -0
- mollie/models/balance_card_audience.py +10 -0
- mollie/models/balance_card_issuer.py +12 -0
- mollie/models/balance_card_region.py +12 -0
- mollie/models/balance_fee_type.py +43 -0
- mollie/models/balance_prepayment_part_type.py +13 -0
- mollie/models/balance_report_grouping.py +10 -0
- mollie/models/balance_transaction_type.py +47 -0
- mollie/models/balance_transfer_category.py +17 -0
- mollie/models/balance_transfer_category_response.py +18 -0
- mollie/models/balance_transfer_destination_type.py +14 -0
- mollie/models/balance_transfer_party_type.py +10 -0
- mollie/models/balance_transfer_party_type_response.py +11 -0
- mollie/models/balance_transfer_status.py +13 -0
- mollie/models/balance_transfer_status_reason_response.py +19 -0
- mollie/models/billingaddress.py +154 -0
- mollie/models/cancel_paymentop.py +93 -0
- mollie/models/cancel_refundop.py +86 -0
- mollie/models/cancel_subscriptionop.py +100 -0
- mollie/models/capability_requirement_status.py +15 -0
- mollie/models/capability_status.py +12 -0
- mollie/models/capability_status_reason.py +10 -0
- mollie/models/capture_mode.py +15 -0
- mollie/models/capture_mode_response.py +16 -0
- mollie/models/capture_response.py +265 -0
- mollie/models/client_link_request.py +210 -0
- mollie/models/client_link_response.py +56 -0
- mollie/models/clienterror.py +30 -0
- mollie/models/components_sub_totals.py +127 -0
- mollie/models/create_captureop.py +43 -0
- mollie/models/create_client_linkop.py +29 -0
- mollie/models/create_connect_balance_transferop.py +32 -0
- mollie/models/create_customer_paymentop.py +43 -0
- mollie/models/create_customerop.py +29 -0
- mollie/models/create_mandateop.py +43 -0
- mollie/models/create_payment_linkop.py +325 -0
- mollie/models/create_paymentop.py +73 -0
- mollie/models/create_profileop.py +29 -0
- mollie/models/create_refundop.py +43 -0
- mollie/models/create_sales_invoiceop.py +29 -0
- mollie/models/create_subscriptionop.py +43 -0
- mollie/models/create_webhook.py +123 -0
- mollie/models/create_webhookop.py +69 -0
- mollie/models/currencies.py +20 -0
- mollie/models/customer_response.py +169 -0
- mollie/models/delete_customerop.py +91 -0
- mollie/models/delete_payment_linkop.py +91 -0
- mollie/models/delete_profileop.py +29 -0
- mollie/models/delete_sales_invoiceop.py +44 -0
- mollie/models/delete_values_sales_invoice.py +54 -0
- mollie/models/delete_webhookop.py +56 -0
- mollie/models/entity_balance.py +325 -0
- mollie/models/entity_balance_report.py +541 -0
- mollie/models/entity_balance_transaction.py +1068 -0
- mollie/models/entity_balance_transfer.py +62 -0
- mollie/models/entity_balance_transfer_party.py +28 -0
- mollie/models/entity_balance_transfer_party_response.py +32 -0
- mollie/models/entity_balance_transfer_response.py +159 -0
- mollie/models/entity_capability.py +75 -0
- mollie/models/entity_capability_requirement.py +87 -0
- mollie/models/entity_capture.py +63 -0
- mollie/models/entity_chargeback.py +247 -0
- mollie/models/entity_customer.py +86 -0
- mollie/models/entity_event.py +46 -0
- mollie/models/entity_invoice.py +247 -0
- mollie/models/entity_method_get.py +329 -0
- mollie/models/entity_onboarding_status.py +95 -0
- mollie/models/entity_organization.py +178 -0
- mollie/models/entity_payment_route.py +111 -0
- mollie/models/entity_payment_route_response.py +140 -0
- mollie/models/entity_permission.py +61 -0
- mollie/models/entity_refund_response.py +361 -0
- mollie/models/entity_route.py +96 -0
- mollie/models/entity_settlement.py +467 -0
- mollie/models/entity_terminal.py +160 -0
- mollie/models/entity_webhook.py +122 -0
- mollie/models/entity_webhook_event.py +149 -0
- mollie/models/error_response.py +70 -0
- mollie/models/get_balance_reportop.py +126 -0
- mollie/models/get_balanceop.py +71 -0
- mollie/models/get_captureop.py +129 -0
- mollie/models/get_chargebackop.py +129 -0
- mollie/models/get_clientop.py +216 -0
- mollie/models/get_connect_balance_transferop.py +71 -0
- mollie/models/get_current_organizationop.py +22 -0
- mollie/models/get_current_profileop.py +22 -0
- mollie/models/get_customerop.py +286 -0
- mollie/models/get_invoiceop.py +29 -0
- mollie/models/get_mandateop.py +86 -0
- mollie/models/get_methodop.py +199 -0
- mollie/models/get_next_settlementop.py +22 -0
- mollie/models/get_onboarding_statusop.py +22 -0
- mollie/models/get_open_settlementop.py +22 -0
- mollie/models/get_organizationop.py +71 -0
- mollie/models/get_partner_statusop.py +231 -0
- mollie/models/get_payment_link_paymentsop.py +188 -0
- mollie/models/get_payment_linkop.py +77 -0
- mollie/models/get_paymentop.py +128 -0
- mollie/models/get_permissionop.py +73 -0
- mollie/models/get_primary_balanceop.py +22 -0
- mollie/models/get_profileop.py +71 -0
- mollie/models/get_refundop.py +129 -0
- mollie/models/get_sales_invoiceop.py +75 -0
- mollie/models/get_settlementop.py +29 -0
- mollie/models/get_subscriptionop.py +86 -0
- mollie/models/get_terminalop.py +77 -0
- mollie/models/get_webhook_eventop.py +71 -0
- mollie/models/get_webhookop.py +71 -0
- mollie/models/internal/__init__.py +54 -0
- mollie/models/internal/globals.py +59 -0
- mollie/models/line_categories.py +13 -0
- mollie/models/line_categories_response.py +14 -0
- mollie/models/list_all_chargebacksop.py +236 -0
- mollie/models/list_all_methodsop.py +249 -0
- mollie/models/list_all_refundsop.py +230 -0
- mollie/models/list_all_subscriptionsop.py +202 -0
- mollie/models/list_balance_transactionsop.py +174 -0
- mollie/models/list_balancesop.py +171 -0
- mollie/models/list_capabilitiesop.py +62 -0
- mollie/models/list_capture_response.py +264 -0
- mollie/models/list_capturesop.py +185 -0
- mollie/models/list_chargebacksop.py +185 -0
- mollie/models/list_clientsop.py +269 -0
- mollie/models/list_connect_balance_transfersop.py +177 -0
- mollie/models/list_customer_paymentsop.py +231 -0
- mollie/models/list_customer_response.py +164 -0
- mollie/models/list_customersop.py +172 -0
- mollie/models/list_entity_balance.py +322 -0
- mollie/models/list_entity_chargeback.py +244 -0
- mollie/models/list_entity_invoice.py +244 -0
- mollie/models/list_entity_method.py +315 -0
- mollie/models/list_entity_method_all.py +391 -0
- mollie/models/list_entity_permission.py +56 -0
- mollie/models/list_entity_refund.py +352 -0
- mollie/models/list_entity_settlement.py +457 -0
- mollie/models/list_entity_terminal.py +157 -0
- mollie/models/list_entity_webhook.py +117 -0
- mollie/models/list_invoicesop.py +175 -0
- mollie/models/list_links.py +68 -0
- mollie/models/list_mandate_response.py +261 -0
- mollie/models/list_mandatesop.py +186 -0
- mollie/models/list_methodsop.py +332 -0
- mollie/models/list_payment_linksop.py +159 -0
- mollie/models/list_payment_response.py +1953 -0
- mollie/models/list_paymentsop.py +217 -0
- mollie/models/list_permissionsop.py +85 -0
- mollie/models/list_profile_response.py +194 -0
- mollie/models/list_profilesop.py +118 -0
- mollie/models/list_refundsop.py +189 -0
- mollie/models/list_route_get_response.py +97 -0
- mollie/models/list_sales_invoice_response.py +505 -0
- mollie/models/list_sales_invoicesop.py +172 -0
- mollie/models/list_settlement_capturesop.py +187 -0
- mollie/models/list_settlement_chargebacksop.py +187 -0
- mollie/models/list_settlement_paymentsop.py +233 -0
- mollie/models/list_settlement_refundsop.py +191 -0
- mollie/models/list_settlementsop.py +178 -0
- mollie/models/list_subscription_paymentsop.py +242 -0
- mollie/models/list_subscription_response.py +344 -0
- mollie/models/list_subscriptionsop.py +189 -0
- mollie/models/list_terminalsop.py +172 -0
- mollie/models/list_webhooksop.py +189 -0
- mollie/models/locale.py +32 -0
- mollie/models/locale_response.py +33 -0
- mollie/models/mandate_details_card_label_response.py +22 -0
- mollie/models/mandate_method.py +15 -0
- mollie/models/mandate_method_response.py +16 -0
- mollie/models/mandate_request.py +160 -0
- mollie/models/mandate_response.py +264 -0
- mollie/models/metadata.py +19 -0
- mollie/models/method.py +50 -0
- mollie/models/method_include_wallets_parameter.py +8 -0
- mollie/models/method_resource_parameter.py +9 -0
- mollie/models/method_response.py +59 -0
- mollie/models/method_status.py +15 -0
- mollie/models/mode.py +12 -0
- mollie/models/no_response_error.py +17 -0
- mollie/models/onboarding_vat_regulation.py +16 -0
- mollie/models/organization_vat_regulation.py +17 -0
- mollie/models/payment_address.py +130 -0
- mollie/models/payment_create_routeop.py +43 -0
- mollie/models/payment_details_card_audition_response.py +12 -0
- mollie/models/payment_details_card_funding_response.py +14 -0
- mollie/models/payment_details_card_label_response.py +23 -0
- mollie/models/payment_details_card_security_response.py +12 -0
- mollie/models/payment_details_failure_reason_response.py +25 -0
- mollie/models/payment_details_fee_region_response.py +20 -0
- mollie/models/payment_details_receipt_card_read_method_response.py +17 -0
- mollie/models/payment_details_receipt_card_verification_method_response.py +21 -0
- mollie/models/payment_details_seller_protection_response.py +20 -0
- mollie/models/payment_details_wallet_response.py +11 -0
- mollie/models/payment_line_item.py +96 -0
- mollie/models/payment_line_item_response.py +104 -0
- mollie/models/payment_line_type.py +20 -0
- mollie/models/payment_line_type_response.py +21 -0
- mollie/models/payment_link_method.py +36 -0
- mollie/models/payment_link_method_response.py +37 -0
- mollie/models/payment_link_response.py +348 -0
- mollie/models/payment_link_sequence_type.py +9 -0
- mollie/models/payment_link_sequence_type_response.py +10 -0
- mollie/models/payment_list_routesop.py +140 -0
- mollie/models/payment_method.py +53 -0
- mollie/models/payment_request.py +919 -0
- mollie/models/payment_response.py +1953 -0
- mollie/models/profile_request.py +67 -0
- mollie/models/profile_response.py +197 -0
- mollie/models/profile_review_status_response.py +12 -0
- mollie/models/recurring_line_item.py +77 -0
- mollie/models/refund_external_reference_type.py +10 -0
- mollie/models/refund_external_reference_type_response.py +11 -0
- mollie/models/refund_request.py +200 -0
- mollie/models/release_authorizationop.py +108 -0
- mollie/models/request_apple_pay_payment_sessionop.py +76 -0
- mollie/models/responsevalidationerror.py +27 -0
- mollie/models/revoke_mandateop.py +100 -0
- mollie/models/route_create_response.py +97 -0
- mollie/models/route_destination_type.py +10 -0
- mollie/models/route_destination_type_response.py +11 -0
- mollie/models/sales_invoice_discount.py +21 -0
- mollie/models/sales_invoice_discount_response.py +25 -0
- mollie/models/sales_invoice_discount_type.py +11 -0
- mollie/models/sales_invoice_discount_type_response.py +12 -0
- mollie/models/sales_invoice_email_details.py +20 -0
- mollie/models/sales_invoice_line_item.py +67 -0
- mollie/models/sales_invoice_line_item_response.py +70 -0
- mollie/models/sales_invoice_payment_details.py +59 -0
- mollie/models/sales_invoice_payment_details_response.py +66 -0
- mollie/models/sales_invoice_payment_details_source.py +12 -0
- mollie/models/sales_invoice_payment_details_source_response.py +13 -0
- mollie/models/sales_invoice_payment_term.py +16 -0
- mollie/models/sales_invoice_payment_term_response.py +17 -0
- mollie/models/sales_invoice_recipient.py +176 -0
- mollie/models/sales_invoice_recipient_locale.py +18 -0
- mollie/models/sales_invoice_recipient_locale_response.py +19 -0
- mollie/models/sales_invoice_recipient_response.py +182 -0
- mollie/models/sales_invoice_recipient_type.py +13 -0
- mollie/models/sales_invoice_recipient_type_response.py +14 -0
- mollie/models/sales_invoice_request.py +256 -0
- mollie/models/sales_invoice_response.py +509 -0
- mollie/models/sales_invoice_status.py +25 -0
- mollie/models/sales_invoice_status_response.py +26 -0
- mollie/models/sales_invoice_vat_mode.py +13 -0
- mollie/models/sales_invoice_vat_mode_response.py +14 -0
- mollie/models/sales_invoice_vat_scheme.py +11 -0
- mollie/models/sales_invoice_vat_scheme_response.py +12 -0
- mollie/models/security.py +35 -0
- mollie/models/sequence_type.py +10 -0
- mollie/models/sequence_type_response.py +11 -0
- mollie/models/sorting.py +9 -0
- mollie/models/status_reason.py +168 -0
- mollie/models/sub_group.py +52 -0
- mollie/models/sub_totals.py +120 -0
- mollie/models/submit_onboarding_dataop.py +214 -0
- mollie/models/subscription_method.py +12 -0
- mollie/models/subscription_method_response.py +13 -0
- mollie/models/subscription_request.py +213 -0
- mollie/models/subscription_response.py +349 -0
- mollie/models/terminal_brand.py +12 -0
- mollie/models/terminal_model.py +16 -0
- mollie/models/test_webhookop.py +64 -0
- mollie/models/update_customerop.py +43 -0
- mollie/models/update_payment_linkop.py +172 -0
- mollie/models/update_paymentop.py +332 -0
- mollie/models/update_profileop.py +147 -0
- mollie/models/update_sales_invoiceop.py +44 -0
- mollie/models/update_subscriptionop.py +188 -0
- mollie/models/update_values_sales_invoice.py +176 -0
- mollie/models/update_webhookop.py +83 -0
- mollie/models/url.py +24 -0
- mollie/models/url_nullable.py +25 -0
- mollie/models/webhook_event_types.py +18 -0
- mollie/models/webhook_status.py +14 -0
- mollie/onboarding.py +403 -0
- mollie/organizations.py +579 -0
- mollie/payment_links.py +1323 -0
- mollie/payments_sdk.py +1385 -0
- mollie/permissions.py +397 -0
- mollie/profiles.py +1209 -0
- mollie/py.typed +1 -0
- mollie/refunds_sdk.py +1111 -0
- mollie/sales_invoices.py +1121 -0
- mollie/sdk.py +265 -0
- mollie/sdkconfiguration.py +50 -0
- mollie/settlements.py +1735 -0
- mollie/subscriptions.py +1617 -0
- mollie/terminals.py +427 -0
- mollie/types/__init__.py +21 -0
- mollie/types/basemodel.py +39 -0
- mollie/utils/__init__.py +200 -0
- mollie/utils/annotations.py +79 -0
- mollie/utils/datetimes.py +23 -0
- mollie/utils/enums.py +74 -0
- mollie/utils/eventstreaming.py +248 -0
- mollie/utils/forms.py +223 -0
- mollie/utils/headers.py +136 -0
- mollie/utils/logger.py +27 -0
- mollie/utils/metadata.py +118 -0
- mollie/utils/queryparams.py +205 -0
- mollie/utils/requestbodies.py +66 -0
- mollie/utils/retries.py +217 -0
- mollie/utils/security.py +195 -0
- mollie/utils/serializers.py +249 -0
- mollie/utils/unmarshal_json_response.py +24 -0
- mollie/utils/url.py +155 -0
- mollie/utils/values.py +137 -0
- mollie/wallets.py +263 -0
- mollie/webhook_events.py +211 -0
- mollie/webhooks.py +1305 -0
- mollie_api_py-1.0.0.dist-info/METADATA +834 -0
- mollie_api_py-1.0.0.dist-info/RECORD +337 -0
- mollie_api_py-1.0.0.dist-info/WHEEL +4 -0
- mollie_api_py-1.0.0.dist-info/licenses/LICENSE.md +24 -0
mollie/subscriptions.py
ADDED
|
@@ -0,0 +1,1617 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from .basesdk import BaseSDK
|
|
4
|
+
from mollie import models, utils
|
|
5
|
+
from mollie._hooks import HookContext
|
|
6
|
+
from mollie.types import OptionalNullable, UNSET
|
|
7
|
+
from mollie.utils import get_security_from_env
|
|
8
|
+
from mollie.utils.unmarshal_json_response import unmarshal_json_response
|
|
9
|
+
from typing import Any, Mapping, Optional, Union
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Subscriptions(BaseSDK):
|
|
13
|
+
def create(
|
|
14
|
+
self,
|
|
15
|
+
*,
|
|
16
|
+
customer_id: str,
|
|
17
|
+
idempotency_key: Optional[str] = None,
|
|
18
|
+
subscription_request: Optional[
|
|
19
|
+
Union[models.SubscriptionRequest, models.SubscriptionRequestTypedDict]
|
|
20
|
+
] = None,
|
|
21
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
22
|
+
server_url: Optional[str] = None,
|
|
23
|
+
timeout_ms: Optional[int] = None,
|
|
24
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
25
|
+
) -> models.SubscriptionResponse:
|
|
26
|
+
r"""Create subscription
|
|
27
|
+
|
|
28
|
+
With subscriptions, you can schedule recurring payments to take place at regular intervals.
|
|
29
|
+
|
|
30
|
+
For example, by simply specifying an `amount` and an `interval`, you can create an endless subscription to charge a
|
|
31
|
+
monthly fee, until you cancel the subscription.
|
|
32
|
+
|
|
33
|
+
Or, you could use the times parameter to only charge a limited number of times, for example to split a big
|
|
34
|
+
transaction in multiple parts.
|
|
35
|
+
|
|
36
|
+
A few example usages:
|
|
37
|
+
|
|
38
|
+
`amount[currency]=\"EUR\"` `amount[value]=\"5.00\"` `interval=\"2 weeks\"`
|
|
39
|
+
Your customer will be charged €5 once every two weeks.
|
|
40
|
+
|
|
41
|
+
`amount[currency]=\"EUR\"` `amount[value]=\"20.00\"` `interval=\"1 day\" times=5`
|
|
42
|
+
Your customer will be charged €20 every day, for five consecutive days.
|
|
43
|
+
|
|
44
|
+
`amount[currency]=\"EUR\"` `amount[value]=\"10.00\"` `interval=\"1 month\"`
|
|
45
|
+
`startDate=\"2018-04-30\"`
|
|
46
|
+
Your customer will be charged €10 on the last day of each month, starting in April 2018.
|
|
47
|
+
|
|
48
|
+
:param customer_id: Provide the ID of the related customer.
|
|
49
|
+
:param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
|
|
50
|
+
:param subscription_request:
|
|
51
|
+
:param retries: Override the default retry configuration for this method
|
|
52
|
+
:param server_url: Override the default server URL for this method
|
|
53
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
54
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
55
|
+
"""
|
|
56
|
+
base_url = None
|
|
57
|
+
url_variables = None
|
|
58
|
+
if timeout_ms is None:
|
|
59
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
60
|
+
|
|
61
|
+
if server_url is not None:
|
|
62
|
+
base_url = server_url
|
|
63
|
+
else:
|
|
64
|
+
base_url = self._get_url(base_url, url_variables)
|
|
65
|
+
|
|
66
|
+
request = models.CreateSubscriptionRequest(
|
|
67
|
+
customer_id=customer_id,
|
|
68
|
+
idempotency_key=idempotency_key,
|
|
69
|
+
subscription_request=utils.get_pydantic_model(
|
|
70
|
+
subscription_request, Optional[models.SubscriptionRequest]
|
|
71
|
+
),
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
req = self._build_request(
|
|
75
|
+
method="POST",
|
|
76
|
+
path="/customers/{customerId}/subscriptions",
|
|
77
|
+
base_url=base_url,
|
|
78
|
+
url_variables=url_variables,
|
|
79
|
+
request=request,
|
|
80
|
+
request_body_required=False,
|
|
81
|
+
request_has_path_params=True,
|
|
82
|
+
request_has_query_params=True,
|
|
83
|
+
user_agent_header="user-agent",
|
|
84
|
+
accept_header_value="application/hal+json",
|
|
85
|
+
http_headers=http_headers,
|
|
86
|
+
security=self.sdk_configuration.security,
|
|
87
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
88
|
+
request.subscription_request,
|
|
89
|
+
False,
|
|
90
|
+
True,
|
|
91
|
+
"json",
|
|
92
|
+
Optional[models.SubscriptionRequest],
|
|
93
|
+
),
|
|
94
|
+
timeout_ms=timeout_ms,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
if retries == UNSET:
|
|
98
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
99
|
+
retries = self.sdk_configuration.retry_config
|
|
100
|
+
else:
|
|
101
|
+
retries = utils.RetryConfig(
|
|
102
|
+
"backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
retry_config = None
|
|
106
|
+
if isinstance(retries, utils.RetryConfig):
|
|
107
|
+
retry_config = (retries, ["5xx"])
|
|
108
|
+
|
|
109
|
+
http_res = self.do_request(
|
|
110
|
+
hook_ctx=HookContext(
|
|
111
|
+
config=self.sdk_configuration,
|
|
112
|
+
base_url=base_url or "",
|
|
113
|
+
operation_id="create-subscription",
|
|
114
|
+
oauth2_scopes=None,
|
|
115
|
+
security_source=get_security_from_env(
|
|
116
|
+
self.sdk_configuration.security, models.Security
|
|
117
|
+
),
|
|
118
|
+
),
|
|
119
|
+
request=req,
|
|
120
|
+
error_status_codes=["404", "4XX", "5XX"],
|
|
121
|
+
retry_config=retry_config,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
response_data: Any = None
|
|
125
|
+
if utils.match_response(http_res, "201", "application/hal+json"):
|
|
126
|
+
return unmarshal_json_response(models.SubscriptionResponse, http_res)
|
|
127
|
+
if utils.match_response(http_res, "404", "application/hal+json"):
|
|
128
|
+
response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
|
|
129
|
+
raise models.ErrorResponse(response_data, http_res)
|
|
130
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
131
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
132
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
133
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
134
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
135
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
136
|
+
|
|
137
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
138
|
+
|
|
139
|
+
async def create_async(
|
|
140
|
+
self,
|
|
141
|
+
*,
|
|
142
|
+
customer_id: str,
|
|
143
|
+
idempotency_key: Optional[str] = None,
|
|
144
|
+
subscription_request: Optional[
|
|
145
|
+
Union[models.SubscriptionRequest, models.SubscriptionRequestTypedDict]
|
|
146
|
+
] = None,
|
|
147
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
148
|
+
server_url: Optional[str] = None,
|
|
149
|
+
timeout_ms: Optional[int] = None,
|
|
150
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
151
|
+
) -> models.SubscriptionResponse:
|
|
152
|
+
r"""Create subscription
|
|
153
|
+
|
|
154
|
+
With subscriptions, you can schedule recurring payments to take place at regular intervals.
|
|
155
|
+
|
|
156
|
+
For example, by simply specifying an `amount` and an `interval`, you can create an endless subscription to charge a
|
|
157
|
+
monthly fee, until you cancel the subscription.
|
|
158
|
+
|
|
159
|
+
Or, you could use the times parameter to only charge a limited number of times, for example to split a big
|
|
160
|
+
transaction in multiple parts.
|
|
161
|
+
|
|
162
|
+
A few example usages:
|
|
163
|
+
|
|
164
|
+
`amount[currency]=\"EUR\"` `amount[value]=\"5.00\"` `interval=\"2 weeks\"`
|
|
165
|
+
Your customer will be charged €5 once every two weeks.
|
|
166
|
+
|
|
167
|
+
`amount[currency]=\"EUR\"` `amount[value]=\"20.00\"` `interval=\"1 day\" times=5`
|
|
168
|
+
Your customer will be charged €20 every day, for five consecutive days.
|
|
169
|
+
|
|
170
|
+
`amount[currency]=\"EUR\"` `amount[value]=\"10.00\"` `interval=\"1 month\"`
|
|
171
|
+
`startDate=\"2018-04-30\"`
|
|
172
|
+
Your customer will be charged €10 on the last day of each month, starting in April 2018.
|
|
173
|
+
|
|
174
|
+
:param customer_id: Provide the ID of the related customer.
|
|
175
|
+
:param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
|
|
176
|
+
:param subscription_request:
|
|
177
|
+
:param retries: Override the default retry configuration for this method
|
|
178
|
+
:param server_url: Override the default server URL for this method
|
|
179
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
180
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
181
|
+
"""
|
|
182
|
+
base_url = None
|
|
183
|
+
url_variables = None
|
|
184
|
+
if timeout_ms is None:
|
|
185
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
186
|
+
|
|
187
|
+
if server_url is not None:
|
|
188
|
+
base_url = server_url
|
|
189
|
+
else:
|
|
190
|
+
base_url = self._get_url(base_url, url_variables)
|
|
191
|
+
|
|
192
|
+
request = models.CreateSubscriptionRequest(
|
|
193
|
+
customer_id=customer_id,
|
|
194
|
+
idempotency_key=idempotency_key,
|
|
195
|
+
subscription_request=utils.get_pydantic_model(
|
|
196
|
+
subscription_request, Optional[models.SubscriptionRequest]
|
|
197
|
+
),
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
req = self._build_request_async(
|
|
201
|
+
method="POST",
|
|
202
|
+
path="/customers/{customerId}/subscriptions",
|
|
203
|
+
base_url=base_url,
|
|
204
|
+
url_variables=url_variables,
|
|
205
|
+
request=request,
|
|
206
|
+
request_body_required=False,
|
|
207
|
+
request_has_path_params=True,
|
|
208
|
+
request_has_query_params=True,
|
|
209
|
+
user_agent_header="user-agent",
|
|
210
|
+
accept_header_value="application/hal+json",
|
|
211
|
+
http_headers=http_headers,
|
|
212
|
+
security=self.sdk_configuration.security,
|
|
213
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
214
|
+
request.subscription_request,
|
|
215
|
+
False,
|
|
216
|
+
True,
|
|
217
|
+
"json",
|
|
218
|
+
Optional[models.SubscriptionRequest],
|
|
219
|
+
),
|
|
220
|
+
timeout_ms=timeout_ms,
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
if retries == UNSET:
|
|
224
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
225
|
+
retries = self.sdk_configuration.retry_config
|
|
226
|
+
else:
|
|
227
|
+
retries = utils.RetryConfig(
|
|
228
|
+
"backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
retry_config = None
|
|
232
|
+
if isinstance(retries, utils.RetryConfig):
|
|
233
|
+
retry_config = (retries, ["5xx"])
|
|
234
|
+
|
|
235
|
+
http_res = await self.do_request_async(
|
|
236
|
+
hook_ctx=HookContext(
|
|
237
|
+
config=self.sdk_configuration,
|
|
238
|
+
base_url=base_url or "",
|
|
239
|
+
operation_id="create-subscription",
|
|
240
|
+
oauth2_scopes=None,
|
|
241
|
+
security_source=get_security_from_env(
|
|
242
|
+
self.sdk_configuration.security, models.Security
|
|
243
|
+
),
|
|
244
|
+
),
|
|
245
|
+
request=req,
|
|
246
|
+
error_status_codes=["404", "4XX", "5XX"],
|
|
247
|
+
retry_config=retry_config,
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
response_data: Any = None
|
|
251
|
+
if utils.match_response(http_res, "201", "application/hal+json"):
|
|
252
|
+
return unmarshal_json_response(models.SubscriptionResponse, http_res)
|
|
253
|
+
if utils.match_response(http_res, "404", "application/hal+json"):
|
|
254
|
+
response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
|
|
255
|
+
raise models.ErrorResponse(response_data, http_res)
|
|
256
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
257
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
258
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
259
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
260
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
261
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
262
|
+
|
|
263
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
264
|
+
|
|
265
|
+
def list(
|
|
266
|
+
self,
|
|
267
|
+
*,
|
|
268
|
+
customer_id: str,
|
|
269
|
+
from_: Optional[str] = None,
|
|
270
|
+
limit: OptionalNullable[int] = UNSET,
|
|
271
|
+
sort: Optional[models.Sorting] = None,
|
|
272
|
+
testmode: Optional[bool] = None,
|
|
273
|
+
idempotency_key: Optional[str] = None,
|
|
274
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
275
|
+
server_url: Optional[str] = None,
|
|
276
|
+
timeout_ms: Optional[int] = None,
|
|
277
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
278
|
+
) -> models.ListSubscriptionsResponse:
|
|
279
|
+
r"""List customer subscriptions
|
|
280
|
+
|
|
281
|
+
Retrieve all subscriptions of a customer.
|
|
282
|
+
|
|
283
|
+
The results are paginated.
|
|
284
|
+
|
|
285
|
+
:param customer_id: Provide the ID of the related customer.
|
|
286
|
+
:param from_: Provide an ID to start the result set from the item with the given ID and onwards. This allows you to paginate the result set.
|
|
287
|
+
:param limit: The maximum number of items to return. Defaults to 50 items.
|
|
288
|
+
:param sort: Used for setting the direction of the result set. Defaults to descending order, meaning the results are ordered from newest to oldest.
|
|
289
|
+
:param testmode: Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter can be omitted. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
|
|
290
|
+
:param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
|
|
291
|
+
:param retries: Override the default retry configuration for this method
|
|
292
|
+
:param server_url: Override the default server URL for this method
|
|
293
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
294
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
295
|
+
"""
|
|
296
|
+
base_url = None
|
|
297
|
+
url_variables = None
|
|
298
|
+
if timeout_ms is None:
|
|
299
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
300
|
+
|
|
301
|
+
if server_url is not None:
|
|
302
|
+
base_url = server_url
|
|
303
|
+
else:
|
|
304
|
+
base_url = self._get_url(base_url, url_variables)
|
|
305
|
+
|
|
306
|
+
request = models.ListSubscriptionsRequest(
|
|
307
|
+
customer_id=customer_id,
|
|
308
|
+
from_=from_,
|
|
309
|
+
limit=limit,
|
|
310
|
+
sort=sort,
|
|
311
|
+
testmode=testmode,
|
|
312
|
+
idempotency_key=idempotency_key,
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
req = self._build_request(
|
|
316
|
+
method="GET",
|
|
317
|
+
path="/customers/{customerId}/subscriptions",
|
|
318
|
+
base_url=base_url,
|
|
319
|
+
url_variables=url_variables,
|
|
320
|
+
request=request,
|
|
321
|
+
request_body_required=False,
|
|
322
|
+
request_has_path_params=True,
|
|
323
|
+
request_has_query_params=True,
|
|
324
|
+
user_agent_header="user-agent",
|
|
325
|
+
accept_header_value="application/hal+json",
|
|
326
|
+
http_headers=http_headers,
|
|
327
|
+
_globals=models.ListSubscriptionsGlobals(
|
|
328
|
+
testmode=self.sdk_configuration.globals.testmode,
|
|
329
|
+
),
|
|
330
|
+
security=self.sdk_configuration.security,
|
|
331
|
+
timeout_ms=timeout_ms,
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
if retries == UNSET:
|
|
335
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
336
|
+
retries = self.sdk_configuration.retry_config
|
|
337
|
+
else:
|
|
338
|
+
retries = utils.RetryConfig(
|
|
339
|
+
"backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
retry_config = None
|
|
343
|
+
if isinstance(retries, utils.RetryConfig):
|
|
344
|
+
retry_config = (retries, ["5xx"])
|
|
345
|
+
|
|
346
|
+
http_res = self.do_request(
|
|
347
|
+
hook_ctx=HookContext(
|
|
348
|
+
config=self.sdk_configuration,
|
|
349
|
+
base_url=base_url or "",
|
|
350
|
+
operation_id="list-subscriptions",
|
|
351
|
+
oauth2_scopes=None,
|
|
352
|
+
security_source=get_security_from_env(
|
|
353
|
+
self.sdk_configuration.security, models.Security
|
|
354
|
+
),
|
|
355
|
+
),
|
|
356
|
+
request=req,
|
|
357
|
+
error_status_codes=["400", "404", "4XX", "5XX"],
|
|
358
|
+
retry_config=retry_config,
|
|
359
|
+
)
|
|
360
|
+
|
|
361
|
+
response_data: Any = None
|
|
362
|
+
if utils.match_response(http_res, "200", "application/hal+json"):
|
|
363
|
+
return unmarshal_json_response(models.ListSubscriptionsResponse, http_res)
|
|
364
|
+
if utils.match_response(http_res, ["400", "404"], "application/hal+json"):
|
|
365
|
+
response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
|
|
366
|
+
raise models.ErrorResponse(response_data, http_res)
|
|
367
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
368
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
369
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
370
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
371
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
372
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
373
|
+
|
|
374
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
375
|
+
|
|
376
|
+
async def list_async(
|
|
377
|
+
self,
|
|
378
|
+
*,
|
|
379
|
+
customer_id: str,
|
|
380
|
+
from_: Optional[str] = None,
|
|
381
|
+
limit: OptionalNullable[int] = UNSET,
|
|
382
|
+
sort: Optional[models.Sorting] = None,
|
|
383
|
+
testmode: Optional[bool] = None,
|
|
384
|
+
idempotency_key: Optional[str] = None,
|
|
385
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
386
|
+
server_url: Optional[str] = None,
|
|
387
|
+
timeout_ms: Optional[int] = None,
|
|
388
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
389
|
+
) -> models.ListSubscriptionsResponse:
|
|
390
|
+
r"""List customer subscriptions
|
|
391
|
+
|
|
392
|
+
Retrieve all subscriptions of a customer.
|
|
393
|
+
|
|
394
|
+
The results are paginated.
|
|
395
|
+
|
|
396
|
+
:param customer_id: Provide the ID of the related customer.
|
|
397
|
+
:param from_: Provide an ID to start the result set from the item with the given ID and onwards. This allows you to paginate the result set.
|
|
398
|
+
:param limit: The maximum number of items to return. Defaults to 50 items.
|
|
399
|
+
:param sort: Used for setting the direction of the result set. Defaults to descending order, meaning the results are ordered from newest to oldest.
|
|
400
|
+
:param testmode: Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter can be omitted. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
|
|
401
|
+
:param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
|
|
402
|
+
:param retries: Override the default retry configuration for this method
|
|
403
|
+
:param server_url: Override the default server URL for this method
|
|
404
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
405
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
406
|
+
"""
|
|
407
|
+
base_url = None
|
|
408
|
+
url_variables = None
|
|
409
|
+
if timeout_ms is None:
|
|
410
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
411
|
+
|
|
412
|
+
if server_url is not None:
|
|
413
|
+
base_url = server_url
|
|
414
|
+
else:
|
|
415
|
+
base_url = self._get_url(base_url, url_variables)
|
|
416
|
+
|
|
417
|
+
request = models.ListSubscriptionsRequest(
|
|
418
|
+
customer_id=customer_id,
|
|
419
|
+
from_=from_,
|
|
420
|
+
limit=limit,
|
|
421
|
+
sort=sort,
|
|
422
|
+
testmode=testmode,
|
|
423
|
+
idempotency_key=idempotency_key,
|
|
424
|
+
)
|
|
425
|
+
|
|
426
|
+
req = self._build_request_async(
|
|
427
|
+
method="GET",
|
|
428
|
+
path="/customers/{customerId}/subscriptions",
|
|
429
|
+
base_url=base_url,
|
|
430
|
+
url_variables=url_variables,
|
|
431
|
+
request=request,
|
|
432
|
+
request_body_required=False,
|
|
433
|
+
request_has_path_params=True,
|
|
434
|
+
request_has_query_params=True,
|
|
435
|
+
user_agent_header="user-agent",
|
|
436
|
+
accept_header_value="application/hal+json",
|
|
437
|
+
http_headers=http_headers,
|
|
438
|
+
_globals=models.ListSubscriptionsGlobals(
|
|
439
|
+
testmode=self.sdk_configuration.globals.testmode,
|
|
440
|
+
),
|
|
441
|
+
security=self.sdk_configuration.security,
|
|
442
|
+
timeout_ms=timeout_ms,
|
|
443
|
+
)
|
|
444
|
+
|
|
445
|
+
if retries == UNSET:
|
|
446
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
447
|
+
retries = self.sdk_configuration.retry_config
|
|
448
|
+
else:
|
|
449
|
+
retries = utils.RetryConfig(
|
|
450
|
+
"backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
|
|
451
|
+
)
|
|
452
|
+
|
|
453
|
+
retry_config = None
|
|
454
|
+
if isinstance(retries, utils.RetryConfig):
|
|
455
|
+
retry_config = (retries, ["5xx"])
|
|
456
|
+
|
|
457
|
+
http_res = await self.do_request_async(
|
|
458
|
+
hook_ctx=HookContext(
|
|
459
|
+
config=self.sdk_configuration,
|
|
460
|
+
base_url=base_url or "",
|
|
461
|
+
operation_id="list-subscriptions",
|
|
462
|
+
oauth2_scopes=None,
|
|
463
|
+
security_source=get_security_from_env(
|
|
464
|
+
self.sdk_configuration.security, models.Security
|
|
465
|
+
),
|
|
466
|
+
),
|
|
467
|
+
request=req,
|
|
468
|
+
error_status_codes=["400", "404", "4XX", "5XX"],
|
|
469
|
+
retry_config=retry_config,
|
|
470
|
+
)
|
|
471
|
+
|
|
472
|
+
response_data: Any = None
|
|
473
|
+
if utils.match_response(http_res, "200", "application/hal+json"):
|
|
474
|
+
return unmarshal_json_response(models.ListSubscriptionsResponse, http_res)
|
|
475
|
+
if utils.match_response(http_res, ["400", "404"], "application/hal+json"):
|
|
476
|
+
response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
|
|
477
|
+
raise models.ErrorResponse(response_data, http_res)
|
|
478
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
479
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
480
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
481
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
482
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
483
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
484
|
+
|
|
485
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
486
|
+
|
|
487
|
+
def get(
|
|
488
|
+
self,
|
|
489
|
+
*,
|
|
490
|
+
customer_id: str,
|
|
491
|
+
subscription_id: str,
|
|
492
|
+
testmode: Optional[bool] = None,
|
|
493
|
+
idempotency_key: Optional[str] = None,
|
|
494
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
495
|
+
server_url: Optional[str] = None,
|
|
496
|
+
timeout_ms: Optional[int] = None,
|
|
497
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
498
|
+
) -> models.SubscriptionResponse:
|
|
499
|
+
r"""Get subscription
|
|
500
|
+
|
|
501
|
+
Retrieve a single subscription by its ID and the ID of its parent customer.
|
|
502
|
+
|
|
503
|
+
:param customer_id: Provide the ID of the related customer.
|
|
504
|
+
:param subscription_id: Provide the ID of the related subscription.
|
|
505
|
+
:param testmode: Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter can be omitted. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
|
|
506
|
+
:param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
|
|
507
|
+
:param retries: Override the default retry configuration for this method
|
|
508
|
+
:param server_url: Override the default server URL for this method
|
|
509
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
510
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
511
|
+
"""
|
|
512
|
+
base_url = None
|
|
513
|
+
url_variables = None
|
|
514
|
+
if timeout_ms is None:
|
|
515
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
516
|
+
|
|
517
|
+
if server_url is not None:
|
|
518
|
+
base_url = server_url
|
|
519
|
+
else:
|
|
520
|
+
base_url = self._get_url(base_url, url_variables)
|
|
521
|
+
|
|
522
|
+
request = models.GetSubscriptionRequest(
|
|
523
|
+
customer_id=customer_id,
|
|
524
|
+
subscription_id=subscription_id,
|
|
525
|
+
testmode=testmode,
|
|
526
|
+
idempotency_key=idempotency_key,
|
|
527
|
+
)
|
|
528
|
+
|
|
529
|
+
req = self._build_request(
|
|
530
|
+
method="GET",
|
|
531
|
+
path="/customers/{customerId}/subscriptions/{subscriptionId}",
|
|
532
|
+
base_url=base_url,
|
|
533
|
+
url_variables=url_variables,
|
|
534
|
+
request=request,
|
|
535
|
+
request_body_required=False,
|
|
536
|
+
request_has_path_params=True,
|
|
537
|
+
request_has_query_params=True,
|
|
538
|
+
user_agent_header="user-agent",
|
|
539
|
+
accept_header_value="application/hal+json",
|
|
540
|
+
http_headers=http_headers,
|
|
541
|
+
_globals=models.GetSubscriptionGlobals(
|
|
542
|
+
testmode=self.sdk_configuration.globals.testmode,
|
|
543
|
+
),
|
|
544
|
+
security=self.sdk_configuration.security,
|
|
545
|
+
timeout_ms=timeout_ms,
|
|
546
|
+
)
|
|
547
|
+
|
|
548
|
+
if retries == UNSET:
|
|
549
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
550
|
+
retries = self.sdk_configuration.retry_config
|
|
551
|
+
else:
|
|
552
|
+
retries = utils.RetryConfig(
|
|
553
|
+
"backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
|
|
554
|
+
)
|
|
555
|
+
|
|
556
|
+
retry_config = None
|
|
557
|
+
if isinstance(retries, utils.RetryConfig):
|
|
558
|
+
retry_config = (retries, ["5xx"])
|
|
559
|
+
|
|
560
|
+
http_res = self.do_request(
|
|
561
|
+
hook_ctx=HookContext(
|
|
562
|
+
config=self.sdk_configuration,
|
|
563
|
+
base_url=base_url or "",
|
|
564
|
+
operation_id="get-subscription",
|
|
565
|
+
oauth2_scopes=None,
|
|
566
|
+
security_source=get_security_from_env(
|
|
567
|
+
self.sdk_configuration.security, models.Security
|
|
568
|
+
),
|
|
569
|
+
),
|
|
570
|
+
request=req,
|
|
571
|
+
error_status_codes=["404", "4XX", "5XX"],
|
|
572
|
+
retry_config=retry_config,
|
|
573
|
+
)
|
|
574
|
+
|
|
575
|
+
response_data: Any = None
|
|
576
|
+
if utils.match_response(http_res, "200", "application/hal+json"):
|
|
577
|
+
return unmarshal_json_response(models.SubscriptionResponse, http_res)
|
|
578
|
+
if utils.match_response(http_res, "404", "application/hal+json"):
|
|
579
|
+
response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
|
|
580
|
+
raise models.ErrorResponse(response_data, http_res)
|
|
581
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
582
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
583
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
584
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
585
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
586
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
587
|
+
|
|
588
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
589
|
+
|
|
590
|
+
async def get_async(
|
|
591
|
+
self,
|
|
592
|
+
*,
|
|
593
|
+
customer_id: str,
|
|
594
|
+
subscription_id: str,
|
|
595
|
+
testmode: Optional[bool] = None,
|
|
596
|
+
idempotency_key: Optional[str] = None,
|
|
597
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
598
|
+
server_url: Optional[str] = None,
|
|
599
|
+
timeout_ms: Optional[int] = None,
|
|
600
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
601
|
+
) -> models.SubscriptionResponse:
|
|
602
|
+
r"""Get subscription
|
|
603
|
+
|
|
604
|
+
Retrieve a single subscription by its ID and the ID of its parent customer.
|
|
605
|
+
|
|
606
|
+
:param customer_id: Provide the ID of the related customer.
|
|
607
|
+
:param subscription_id: Provide the ID of the related subscription.
|
|
608
|
+
:param testmode: Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter can be omitted. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
|
|
609
|
+
:param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
|
|
610
|
+
:param retries: Override the default retry configuration for this method
|
|
611
|
+
:param server_url: Override the default server URL for this method
|
|
612
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
613
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
614
|
+
"""
|
|
615
|
+
base_url = None
|
|
616
|
+
url_variables = None
|
|
617
|
+
if timeout_ms is None:
|
|
618
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
619
|
+
|
|
620
|
+
if server_url is not None:
|
|
621
|
+
base_url = server_url
|
|
622
|
+
else:
|
|
623
|
+
base_url = self._get_url(base_url, url_variables)
|
|
624
|
+
|
|
625
|
+
request = models.GetSubscriptionRequest(
|
|
626
|
+
customer_id=customer_id,
|
|
627
|
+
subscription_id=subscription_id,
|
|
628
|
+
testmode=testmode,
|
|
629
|
+
idempotency_key=idempotency_key,
|
|
630
|
+
)
|
|
631
|
+
|
|
632
|
+
req = self._build_request_async(
|
|
633
|
+
method="GET",
|
|
634
|
+
path="/customers/{customerId}/subscriptions/{subscriptionId}",
|
|
635
|
+
base_url=base_url,
|
|
636
|
+
url_variables=url_variables,
|
|
637
|
+
request=request,
|
|
638
|
+
request_body_required=False,
|
|
639
|
+
request_has_path_params=True,
|
|
640
|
+
request_has_query_params=True,
|
|
641
|
+
user_agent_header="user-agent",
|
|
642
|
+
accept_header_value="application/hal+json",
|
|
643
|
+
http_headers=http_headers,
|
|
644
|
+
_globals=models.GetSubscriptionGlobals(
|
|
645
|
+
testmode=self.sdk_configuration.globals.testmode,
|
|
646
|
+
),
|
|
647
|
+
security=self.sdk_configuration.security,
|
|
648
|
+
timeout_ms=timeout_ms,
|
|
649
|
+
)
|
|
650
|
+
|
|
651
|
+
if retries == UNSET:
|
|
652
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
653
|
+
retries = self.sdk_configuration.retry_config
|
|
654
|
+
else:
|
|
655
|
+
retries = utils.RetryConfig(
|
|
656
|
+
"backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
|
|
657
|
+
)
|
|
658
|
+
|
|
659
|
+
retry_config = None
|
|
660
|
+
if isinstance(retries, utils.RetryConfig):
|
|
661
|
+
retry_config = (retries, ["5xx"])
|
|
662
|
+
|
|
663
|
+
http_res = await self.do_request_async(
|
|
664
|
+
hook_ctx=HookContext(
|
|
665
|
+
config=self.sdk_configuration,
|
|
666
|
+
base_url=base_url or "",
|
|
667
|
+
operation_id="get-subscription",
|
|
668
|
+
oauth2_scopes=None,
|
|
669
|
+
security_source=get_security_from_env(
|
|
670
|
+
self.sdk_configuration.security, models.Security
|
|
671
|
+
),
|
|
672
|
+
),
|
|
673
|
+
request=req,
|
|
674
|
+
error_status_codes=["404", "4XX", "5XX"],
|
|
675
|
+
retry_config=retry_config,
|
|
676
|
+
)
|
|
677
|
+
|
|
678
|
+
response_data: Any = None
|
|
679
|
+
if utils.match_response(http_res, "200", "application/hal+json"):
|
|
680
|
+
return unmarshal_json_response(models.SubscriptionResponse, http_res)
|
|
681
|
+
if utils.match_response(http_res, "404", "application/hal+json"):
|
|
682
|
+
response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
|
|
683
|
+
raise models.ErrorResponse(response_data, http_res)
|
|
684
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
685
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
686
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
687
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
688
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
689
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
690
|
+
|
|
691
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
692
|
+
|
|
693
|
+
def update(
|
|
694
|
+
self,
|
|
695
|
+
*,
|
|
696
|
+
customer_id: str,
|
|
697
|
+
subscription_id: str,
|
|
698
|
+
idempotency_key: Optional[str] = None,
|
|
699
|
+
request_body: Optional[
|
|
700
|
+
Union[
|
|
701
|
+
models.UpdateSubscriptionRequestBody,
|
|
702
|
+
models.UpdateSubscriptionRequestBodyTypedDict,
|
|
703
|
+
]
|
|
704
|
+
] = None,
|
|
705
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
706
|
+
server_url: Optional[str] = None,
|
|
707
|
+
timeout_ms: Optional[int] = None,
|
|
708
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
709
|
+
) -> models.SubscriptionResponse:
|
|
710
|
+
r"""Update subscription
|
|
711
|
+
|
|
712
|
+
Update an existing subscription.
|
|
713
|
+
|
|
714
|
+
Canceled subscriptions cannot be updated.
|
|
715
|
+
|
|
716
|
+
For an in-depth explanation of each parameter, refer to the [Create subscription](create-subscription) endpoint.
|
|
717
|
+
|
|
718
|
+
:param customer_id: Provide the ID of the related customer.
|
|
719
|
+
:param subscription_id: Provide the ID of the related subscription.
|
|
720
|
+
:param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
|
|
721
|
+
:param request_body:
|
|
722
|
+
:param retries: Override the default retry configuration for this method
|
|
723
|
+
:param server_url: Override the default server URL for this method
|
|
724
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
725
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
726
|
+
"""
|
|
727
|
+
base_url = None
|
|
728
|
+
url_variables = None
|
|
729
|
+
if timeout_ms is None:
|
|
730
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
731
|
+
|
|
732
|
+
if server_url is not None:
|
|
733
|
+
base_url = server_url
|
|
734
|
+
else:
|
|
735
|
+
base_url = self._get_url(base_url, url_variables)
|
|
736
|
+
|
|
737
|
+
request = models.UpdateSubscriptionRequest(
|
|
738
|
+
customer_id=customer_id,
|
|
739
|
+
subscription_id=subscription_id,
|
|
740
|
+
idempotency_key=idempotency_key,
|
|
741
|
+
request_body=utils.get_pydantic_model(
|
|
742
|
+
request_body, Optional[models.UpdateSubscriptionRequestBody]
|
|
743
|
+
),
|
|
744
|
+
)
|
|
745
|
+
|
|
746
|
+
req = self._build_request(
|
|
747
|
+
method="PATCH",
|
|
748
|
+
path="/customers/{customerId}/subscriptions/{subscriptionId}",
|
|
749
|
+
base_url=base_url,
|
|
750
|
+
url_variables=url_variables,
|
|
751
|
+
request=request,
|
|
752
|
+
request_body_required=False,
|
|
753
|
+
request_has_path_params=True,
|
|
754
|
+
request_has_query_params=True,
|
|
755
|
+
user_agent_header="user-agent",
|
|
756
|
+
accept_header_value="application/hal+json",
|
|
757
|
+
http_headers=http_headers,
|
|
758
|
+
security=self.sdk_configuration.security,
|
|
759
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
760
|
+
request.request_body,
|
|
761
|
+
False,
|
|
762
|
+
True,
|
|
763
|
+
"json",
|
|
764
|
+
Optional[models.UpdateSubscriptionRequestBody],
|
|
765
|
+
),
|
|
766
|
+
timeout_ms=timeout_ms,
|
|
767
|
+
)
|
|
768
|
+
|
|
769
|
+
if retries == UNSET:
|
|
770
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
771
|
+
retries = self.sdk_configuration.retry_config
|
|
772
|
+
else:
|
|
773
|
+
retries = utils.RetryConfig(
|
|
774
|
+
"backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
|
|
775
|
+
)
|
|
776
|
+
|
|
777
|
+
retry_config = None
|
|
778
|
+
if isinstance(retries, utils.RetryConfig):
|
|
779
|
+
retry_config = (retries, ["5xx"])
|
|
780
|
+
|
|
781
|
+
http_res = self.do_request(
|
|
782
|
+
hook_ctx=HookContext(
|
|
783
|
+
config=self.sdk_configuration,
|
|
784
|
+
base_url=base_url or "",
|
|
785
|
+
operation_id="update-subscription",
|
|
786
|
+
oauth2_scopes=None,
|
|
787
|
+
security_source=get_security_from_env(
|
|
788
|
+
self.sdk_configuration.security, models.Security
|
|
789
|
+
),
|
|
790
|
+
),
|
|
791
|
+
request=req,
|
|
792
|
+
error_status_codes=["404", "4XX", "5XX"],
|
|
793
|
+
retry_config=retry_config,
|
|
794
|
+
)
|
|
795
|
+
|
|
796
|
+
response_data: Any = None
|
|
797
|
+
if utils.match_response(http_res, "200", "application/hal+json"):
|
|
798
|
+
return unmarshal_json_response(models.SubscriptionResponse, http_res)
|
|
799
|
+
if utils.match_response(http_res, "404", "application/hal+json"):
|
|
800
|
+
response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
|
|
801
|
+
raise models.ErrorResponse(response_data, http_res)
|
|
802
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
803
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
804
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
805
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
806
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
807
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
808
|
+
|
|
809
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
810
|
+
|
|
811
|
+
async def update_async(
|
|
812
|
+
self,
|
|
813
|
+
*,
|
|
814
|
+
customer_id: str,
|
|
815
|
+
subscription_id: str,
|
|
816
|
+
idempotency_key: Optional[str] = None,
|
|
817
|
+
request_body: Optional[
|
|
818
|
+
Union[
|
|
819
|
+
models.UpdateSubscriptionRequestBody,
|
|
820
|
+
models.UpdateSubscriptionRequestBodyTypedDict,
|
|
821
|
+
]
|
|
822
|
+
] = None,
|
|
823
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
824
|
+
server_url: Optional[str] = None,
|
|
825
|
+
timeout_ms: Optional[int] = None,
|
|
826
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
827
|
+
) -> models.SubscriptionResponse:
|
|
828
|
+
r"""Update subscription
|
|
829
|
+
|
|
830
|
+
Update an existing subscription.
|
|
831
|
+
|
|
832
|
+
Canceled subscriptions cannot be updated.
|
|
833
|
+
|
|
834
|
+
For an in-depth explanation of each parameter, refer to the [Create subscription](create-subscription) endpoint.
|
|
835
|
+
|
|
836
|
+
:param customer_id: Provide the ID of the related customer.
|
|
837
|
+
:param subscription_id: Provide the ID of the related subscription.
|
|
838
|
+
:param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
|
|
839
|
+
:param request_body:
|
|
840
|
+
:param retries: Override the default retry configuration for this method
|
|
841
|
+
:param server_url: Override the default server URL for this method
|
|
842
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
843
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
844
|
+
"""
|
|
845
|
+
base_url = None
|
|
846
|
+
url_variables = None
|
|
847
|
+
if timeout_ms is None:
|
|
848
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
849
|
+
|
|
850
|
+
if server_url is not None:
|
|
851
|
+
base_url = server_url
|
|
852
|
+
else:
|
|
853
|
+
base_url = self._get_url(base_url, url_variables)
|
|
854
|
+
|
|
855
|
+
request = models.UpdateSubscriptionRequest(
|
|
856
|
+
customer_id=customer_id,
|
|
857
|
+
subscription_id=subscription_id,
|
|
858
|
+
idempotency_key=idempotency_key,
|
|
859
|
+
request_body=utils.get_pydantic_model(
|
|
860
|
+
request_body, Optional[models.UpdateSubscriptionRequestBody]
|
|
861
|
+
),
|
|
862
|
+
)
|
|
863
|
+
|
|
864
|
+
req = self._build_request_async(
|
|
865
|
+
method="PATCH",
|
|
866
|
+
path="/customers/{customerId}/subscriptions/{subscriptionId}",
|
|
867
|
+
base_url=base_url,
|
|
868
|
+
url_variables=url_variables,
|
|
869
|
+
request=request,
|
|
870
|
+
request_body_required=False,
|
|
871
|
+
request_has_path_params=True,
|
|
872
|
+
request_has_query_params=True,
|
|
873
|
+
user_agent_header="user-agent",
|
|
874
|
+
accept_header_value="application/hal+json",
|
|
875
|
+
http_headers=http_headers,
|
|
876
|
+
security=self.sdk_configuration.security,
|
|
877
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
878
|
+
request.request_body,
|
|
879
|
+
False,
|
|
880
|
+
True,
|
|
881
|
+
"json",
|
|
882
|
+
Optional[models.UpdateSubscriptionRequestBody],
|
|
883
|
+
),
|
|
884
|
+
timeout_ms=timeout_ms,
|
|
885
|
+
)
|
|
886
|
+
|
|
887
|
+
if retries == UNSET:
|
|
888
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
889
|
+
retries = self.sdk_configuration.retry_config
|
|
890
|
+
else:
|
|
891
|
+
retries = utils.RetryConfig(
|
|
892
|
+
"backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
|
|
893
|
+
)
|
|
894
|
+
|
|
895
|
+
retry_config = None
|
|
896
|
+
if isinstance(retries, utils.RetryConfig):
|
|
897
|
+
retry_config = (retries, ["5xx"])
|
|
898
|
+
|
|
899
|
+
http_res = await self.do_request_async(
|
|
900
|
+
hook_ctx=HookContext(
|
|
901
|
+
config=self.sdk_configuration,
|
|
902
|
+
base_url=base_url or "",
|
|
903
|
+
operation_id="update-subscription",
|
|
904
|
+
oauth2_scopes=None,
|
|
905
|
+
security_source=get_security_from_env(
|
|
906
|
+
self.sdk_configuration.security, models.Security
|
|
907
|
+
),
|
|
908
|
+
),
|
|
909
|
+
request=req,
|
|
910
|
+
error_status_codes=["404", "4XX", "5XX"],
|
|
911
|
+
retry_config=retry_config,
|
|
912
|
+
)
|
|
913
|
+
|
|
914
|
+
response_data: Any = None
|
|
915
|
+
if utils.match_response(http_res, "200", "application/hal+json"):
|
|
916
|
+
return unmarshal_json_response(models.SubscriptionResponse, http_res)
|
|
917
|
+
if utils.match_response(http_res, "404", "application/hal+json"):
|
|
918
|
+
response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
|
|
919
|
+
raise models.ErrorResponse(response_data, http_res)
|
|
920
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
921
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
922
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
923
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
924
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
925
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
926
|
+
|
|
927
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
928
|
+
|
|
929
|
+
def cancel(
|
|
930
|
+
self,
|
|
931
|
+
*,
|
|
932
|
+
customer_id: str,
|
|
933
|
+
subscription_id: str,
|
|
934
|
+
idempotency_key: Optional[str] = None,
|
|
935
|
+
request_body: Optional[
|
|
936
|
+
Union[
|
|
937
|
+
models.CancelSubscriptionRequestBody,
|
|
938
|
+
models.CancelSubscriptionRequestBodyTypedDict,
|
|
939
|
+
]
|
|
940
|
+
] = None,
|
|
941
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
942
|
+
server_url: Optional[str] = None,
|
|
943
|
+
timeout_ms: Optional[int] = None,
|
|
944
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
945
|
+
) -> models.SubscriptionResponse:
|
|
946
|
+
r"""Cancel subscription
|
|
947
|
+
|
|
948
|
+
Cancel an existing subscription. Canceling a subscription has no effect on the mandates of the customer.
|
|
949
|
+
|
|
950
|
+
:param customer_id: Provide the ID of the related customer.
|
|
951
|
+
:param subscription_id: Provide the ID of the related subscription.
|
|
952
|
+
:param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
|
|
953
|
+
:param request_body:
|
|
954
|
+
:param retries: Override the default retry configuration for this method
|
|
955
|
+
:param server_url: Override the default server URL for this method
|
|
956
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
957
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
958
|
+
"""
|
|
959
|
+
base_url = None
|
|
960
|
+
url_variables = None
|
|
961
|
+
if timeout_ms is None:
|
|
962
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
963
|
+
|
|
964
|
+
if server_url is not None:
|
|
965
|
+
base_url = server_url
|
|
966
|
+
else:
|
|
967
|
+
base_url = self._get_url(base_url, url_variables)
|
|
968
|
+
|
|
969
|
+
request = models.CancelSubscriptionRequest(
|
|
970
|
+
customer_id=customer_id,
|
|
971
|
+
subscription_id=subscription_id,
|
|
972
|
+
idempotency_key=idempotency_key,
|
|
973
|
+
request_body=utils.get_pydantic_model(
|
|
974
|
+
request_body, Optional[models.CancelSubscriptionRequestBody]
|
|
975
|
+
),
|
|
976
|
+
)
|
|
977
|
+
|
|
978
|
+
req = self._build_request(
|
|
979
|
+
method="DELETE",
|
|
980
|
+
path="/customers/{customerId}/subscriptions/{subscriptionId}",
|
|
981
|
+
base_url=base_url,
|
|
982
|
+
url_variables=url_variables,
|
|
983
|
+
request=request,
|
|
984
|
+
request_body_required=False,
|
|
985
|
+
request_has_path_params=True,
|
|
986
|
+
request_has_query_params=True,
|
|
987
|
+
user_agent_header="user-agent",
|
|
988
|
+
accept_header_value="application/hal+json",
|
|
989
|
+
http_headers=http_headers,
|
|
990
|
+
security=self.sdk_configuration.security,
|
|
991
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
992
|
+
request.request_body,
|
|
993
|
+
False,
|
|
994
|
+
True,
|
|
995
|
+
"json",
|
|
996
|
+
Optional[models.CancelSubscriptionRequestBody],
|
|
997
|
+
),
|
|
998
|
+
timeout_ms=timeout_ms,
|
|
999
|
+
)
|
|
1000
|
+
|
|
1001
|
+
if retries == UNSET:
|
|
1002
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1003
|
+
retries = self.sdk_configuration.retry_config
|
|
1004
|
+
else:
|
|
1005
|
+
retries = utils.RetryConfig(
|
|
1006
|
+
"backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
|
|
1007
|
+
)
|
|
1008
|
+
|
|
1009
|
+
retry_config = None
|
|
1010
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1011
|
+
retry_config = (retries, ["5xx"])
|
|
1012
|
+
|
|
1013
|
+
http_res = self.do_request(
|
|
1014
|
+
hook_ctx=HookContext(
|
|
1015
|
+
config=self.sdk_configuration,
|
|
1016
|
+
base_url=base_url or "",
|
|
1017
|
+
operation_id="cancel-subscription",
|
|
1018
|
+
oauth2_scopes=None,
|
|
1019
|
+
security_source=get_security_from_env(
|
|
1020
|
+
self.sdk_configuration.security, models.Security
|
|
1021
|
+
),
|
|
1022
|
+
),
|
|
1023
|
+
request=req,
|
|
1024
|
+
error_status_codes=["404", "4XX", "5XX"],
|
|
1025
|
+
retry_config=retry_config,
|
|
1026
|
+
)
|
|
1027
|
+
|
|
1028
|
+
response_data: Any = None
|
|
1029
|
+
if utils.match_response(http_res, "200", "application/hal+json"):
|
|
1030
|
+
return unmarshal_json_response(models.SubscriptionResponse, http_res)
|
|
1031
|
+
if utils.match_response(http_res, "404", "application/hal+json"):
|
|
1032
|
+
response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
|
|
1033
|
+
raise models.ErrorResponse(response_data, http_res)
|
|
1034
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1035
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1036
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
1037
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1038
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1039
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
1040
|
+
|
|
1041
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
1042
|
+
|
|
1043
|
+
async def cancel_async(
|
|
1044
|
+
self,
|
|
1045
|
+
*,
|
|
1046
|
+
customer_id: str,
|
|
1047
|
+
subscription_id: str,
|
|
1048
|
+
idempotency_key: Optional[str] = None,
|
|
1049
|
+
request_body: Optional[
|
|
1050
|
+
Union[
|
|
1051
|
+
models.CancelSubscriptionRequestBody,
|
|
1052
|
+
models.CancelSubscriptionRequestBodyTypedDict,
|
|
1053
|
+
]
|
|
1054
|
+
] = None,
|
|
1055
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1056
|
+
server_url: Optional[str] = None,
|
|
1057
|
+
timeout_ms: Optional[int] = None,
|
|
1058
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1059
|
+
) -> models.SubscriptionResponse:
|
|
1060
|
+
r"""Cancel subscription
|
|
1061
|
+
|
|
1062
|
+
Cancel an existing subscription. Canceling a subscription has no effect on the mandates of the customer.
|
|
1063
|
+
|
|
1064
|
+
:param customer_id: Provide the ID of the related customer.
|
|
1065
|
+
:param subscription_id: Provide the ID of the related subscription.
|
|
1066
|
+
:param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
|
|
1067
|
+
:param request_body:
|
|
1068
|
+
:param retries: Override the default retry configuration for this method
|
|
1069
|
+
:param server_url: Override the default server URL for this method
|
|
1070
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1071
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1072
|
+
"""
|
|
1073
|
+
base_url = None
|
|
1074
|
+
url_variables = None
|
|
1075
|
+
if timeout_ms is None:
|
|
1076
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1077
|
+
|
|
1078
|
+
if server_url is not None:
|
|
1079
|
+
base_url = server_url
|
|
1080
|
+
else:
|
|
1081
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1082
|
+
|
|
1083
|
+
request = models.CancelSubscriptionRequest(
|
|
1084
|
+
customer_id=customer_id,
|
|
1085
|
+
subscription_id=subscription_id,
|
|
1086
|
+
idempotency_key=idempotency_key,
|
|
1087
|
+
request_body=utils.get_pydantic_model(
|
|
1088
|
+
request_body, Optional[models.CancelSubscriptionRequestBody]
|
|
1089
|
+
),
|
|
1090
|
+
)
|
|
1091
|
+
|
|
1092
|
+
req = self._build_request_async(
|
|
1093
|
+
method="DELETE",
|
|
1094
|
+
path="/customers/{customerId}/subscriptions/{subscriptionId}",
|
|
1095
|
+
base_url=base_url,
|
|
1096
|
+
url_variables=url_variables,
|
|
1097
|
+
request=request,
|
|
1098
|
+
request_body_required=False,
|
|
1099
|
+
request_has_path_params=True,
|
|
1100
|
+
request_has_query_params=True,
|
|
1101
|
+
user_agent_header="user-agent",
|
|
1102
|
+
accept_header_value="application/hal+json",
|
|
1103
|
+
http_headers=http_headers,
|
|
1104
|
+
security=self.sdk_configuration.security,
|
|
1105
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1106
|
+
request.request_body,
|
|
1107
|
+
False,
|
|
1108
|
+
True,
|
|
1109
|
+
"json",
|
|
1110
|
+
Optional[models.CancelSubscriptionRequestBody],
|
|
1111
|
+
),
|
|
1112
|
+
timeout_ms=timeout_ms,
|
|
1113
|
+
)
|
|
1114
|
+
|
|
1115
|
+
if retries == UNSET:
|
|
1116
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1117
|
+
retries = self.sdk_configuration.retry_config
|
|
1118
|
+
else:
|
|
1119
|
+
retries = utils.RetryConfig(
|
|
1120
|
+
"backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
|
|
1121
|
+
)
|
|
1122
|
+
|
|
1123
|
+
retry_config = None
|
|
1124
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1125
|
+
retry_config = (retries, ["5xx"])
|
|
1126
|
+
|
|
1127
|
+
http_res = await self.do_request_async(
|
|
1128
|
+
hook_ctx=HookContext(
|
|
1129
|
+
config=self.sdk_configuration,
|
|
1130
|
+
base_url=base_url or "",
|
|
1131
|
+
operation_id="cancel-subscription",
|
|
1132
|
+
oauth2_scopes=None,
|
|
1133
|
+
security_source=get_security_from_env(
|
|
1134
|
+
self.sdk_configuration.security, models.Security
|
|
1135
|
+
),
|
|
1136
|
+
),
|
|
1137
|
+
request=req,
|
|
1138
|
+
error_status_codes=["404", "4XX", "5XX"],
|
|
1139
|
+
retry_config=retry_config,
|
|
1140
|
+
)
|
|
1141
|
+
|
|
1142
|
+
response_data: Any = None
|
|
1143
|
+
if utils.match_response(http_res, "200", "application/hal+json"):
|
|
1144
|
+
return unmarshal_json_response(models.SubscriptionResponse, http_res)
|
|
1145
|
+
if utils.match_response(http_res, "404", "application/hal+json"):
|
|
1146
|
+
response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
|
|
1147
|
+
raise models.ErrorResponse(response_data, http_res)
|
|
1148
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1149
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1150
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
1151
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1152
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1153
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
1154
|
+
|
|
1155
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
1156
|
+
|
|
1157
|
+
def all(
|
|
1158
|
+
self,
|
|
1159
|
+
*,
|
|
1160
|
+
from_: OptionalNullable[str] = UNSET,
|
|
1161
|
+
limit: OptionalNullable[int] = UNSET,
|
|
1162
|
+
profile_id: OptionalNullable[str] = UNSET,
|
|
1163
|
+
testmode: Optional[bool] = None,
|
|
1164
|
+
idempotency_key: Optional[str] = None,
|
|
1165
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1166
|
+
server_url: Optional[str] = None,
|
|
1167
|
+
timeout_ms: Optional[int] = None,
|
|
1168
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1169
|
+
) -> models.ListAllSubscriptionsResponse:
|
|
1170
|
+
r"""List all subscriptions
|
|
1171
|
+
|
|
1172
|
+
Retrieve all subscriptions initiated across all your customers.
|
|
1173
|
+
|
|
1174
|
+
The results are paginated.
|
|
1175
|
+
|
|
1176
|
+
:param from_: Provide an ID to start the result set from the item with the given ID and onwards. This allows you to paginate the result set.
|
|
1177
|
+
:param limit: The maximum number of items to return. Defaults to 50 items.
|
|
1178
|
+
:param profile_id: The identifier referring to the [profile](get-profile) you wish to retrieve subscriptions for. Most API credentials are linked to a single profile. In these cases the `profileId` is already implied. To retrieve all subscriptions across the organization, use an organization-level API credential and omit the `profileId` parameter.
|
|
1179
|
+
:param testmode: Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter can be omitted. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
|
|
1180
|
+
:param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
|
|
1181
|
+
:param retries: Override the default retry configuration for this method
|
|
1182
|
+
:param server_url: Override the default server URL for this method
|
|
1183
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1184
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1185
|
+
"""
|
|
1186
|
+
base_url = None
|
|
1187
|
+
url_variables = None
|
|
1188
|
+
if timeout_ms is None:
|
|
1189
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1190
|
+
|
|
1191
|
+
if server_url is not None:
|
|
1192
|
+
base_url = server_url
|
|
1193
|
+
else:
|
|
1194
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1195
|
+
|
|
1196
|
+
request = models.ListAllSubscriptionsRequest(
|
|
1197
|
+
from_=from_,
|
|
1198
|
+
limit=limit,
|
|
1199
|
+
profile_id=profile_id,
|
|
1200
|
+
testmode=testmode,
|
|
1201
|
+
idempotency_key=idempotency_key,
|
|
1202
|
+
)
|
|
1203
|
+
|
|
1204
|
+
req = self._build_request(
|
|
1205
|
+
method="GET",
|
|
1206
|
+
path="/subscriptions",
|
|
1207
|
+
base_url=base_url,
|
|
1208
|
+
url_variables=url_variables,
|
|
1209
|
+
request=request,
|
|
1210
|
+
request_body_required=False,
|
|
1211
|
+
request_has_path_params=False,
|
|
1212
|
+
request_has_query_params=True,
|
|
1213
|
+
user_agent_header="user-agent",
|
|
1214
|
+
accept_header_value="application/hal+json",
|
|
1215
|
+
http_headers=http_headers,
|
|
1216
|
+
_globals=models.ListAllSubscriptionsGlobals(
|
|
1217
|
+
profile_id=self.sdk_configuration.globals.profile_id,
|
|
1218
|
+
testmode=self.sdk_configuration.globals.testmode,
|
|
1219
|
+
),
|
|
1220
|
+
security=self.sdk_configuration.security,
|
|
1221
|
+
timeout_ms=timeout_ms,
|
|
1222
|
+
)
|
|
1223
|
+
|
|
1224
|
+
if retries == UNSET:
|
|
1225
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1226
|
+
retries = self.sdk_configuration.retry_config
|
|
1227
|
+
else:
|
|
1228
|
+
retries = utils.RetryConfig(
|
|
1229
|
+
"backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
|
|
1230
|
+
)
|
|
1231
|
+
|
|
1232
|
+
retry_config = None
|
|
1233
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1234
|
+
retry_config = (retries, ["5xx"])
|
|
1235
|
+
|
|
1236
|
+
http_res = self.do_request(
|
|
1237
|
+
hook_ctx=HookContext(
|
|
1238
|
+
config=self.sdk_configuration,
|
|
1239
|
+
base_url=base_url or "",
|
|
1240
|
+
operation_id="list-all-subscriptions",
|
|
1241
|
+
oauth2_scopes=None,
|
|
1242
|
+
security_source=get_security_from_env(
|
|
1243
|
+
self.sdk_configuration.security, models.Security
|
|
1244
|
+
),
|
|
1245
|
+
),
|
|
1246
|
+
request=req,
|
|
1247
|
+
error_status_codes=["400", "404", "4XX", "5XX"],
|
|
1248
|
+
retry_config=retry_config,
|
|
1249
|
+
)
|
|
1250
|
+
|
|
1251
|
+
response_data: Any = None
|
|
1252
|
+
if utils.match_response(http_res, "200", "application/hal+json"):
|
|
1253
|
+
return unmarshal_json_response(
|
|
1254
|
+
models.ListAllSubscriptionsResponse, http_res
|
|
1255
|
+
)
|
|
1256
|
+
if utils.match_response(http_res, ["400", "404"], "application/hal+json"):
|
|
1257
|
+
response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
|
|
1258
|
+
raise models.ErrorResponse(response_data, http_res)
|
|
1259
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1260
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1261
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
1262
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1263
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1264
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
1265
|
+
|
|
1266
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
1267
|
+
|
|
1268
|
+
async def all_async(
|
|
1269
|
+
self,
|
|
1270
|
+
*,
|
|
1271
|
+
from_: OptionalNullable[str] = UNSET,
|
|
1272
|
+
limit: OptionalNullable[int] = UNSET,
|
|
1273
|
+
profile_id: OptionalNullable[str] = UNSET,
|
|
1274
|
+
testmode: Optional[bool] = None,
|
|
1275
|
+
idempotency_key: Optional[str] = None,
|
|
1276
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1277
|
+
server_url: Optional[str] = None,
|
|
1278
|
+
timeout_ms: Optional[int] = None,
|
|
1279
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1280
|
+
) -> models.ListAllSubscriptionsResponse:
|
|
1281
|
+
r"""List all subscriptions
|
|
1282
|
+
|
|
1283
|
+
Retrieve all subscriptions initiated across all your customers.
|
|
1284
|
+
|
|
1285
|
+
The results are paginated.
|
|
1286
|
+
|
|
1287
|
+
:param from_: Provide an ID to start the result set from the item with the given ID and onwards. This allows you to paginate the result set.
|
|
1288
|
+
:param limit: The maximum number of items to return. Defaults to 50 items.
|
|
1289
|
+
:param profile_id: The identifier referring to the [profile](get-profile) you wish to retrieve subscriptions for. Most API credentials are linked to a single profile. In these cases the `profileId` is already implied. To retrieve all subscriptions across the organization, use an organization-level API credential and omit the `profileId` parameter.
|
|
1290
|
+
:param testmode: Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter can be omitted. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
|
|
1291
|
+
:param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
|
|
1292
|
+
:param retries: Override the default retry configuration for this method
|
|
1293
|
+
:param server_url: Override the default server URL for this method
|
|
1294
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1295
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1296
|
+
"""
|
|
1297
|
+
base_url = None
|
|
1298
|
+
url_variables = None
|
|
1299
|
+
if timeout_ms is None:
|
|
1300
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1301
|
+
|
|
1302
|
+
if server_url is not None:
|
|
1303
|
+
base_url = server_url
|
|
1304
|
+
else:
|
|
1305
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1306
|
+
|
|
1307
|
+
request = models.ListAllSubscriptionsRequest(
|
|
1308
|
+
from_=from_,
|
|
1309
|
+
limit=limit,
|
|
1310
|
+
profile_id=profile_id,
|
|
1311
|
+
testmode=testmode,
|
|
1312
|
+
idempotency_key=idempotency_key,
|
|
1313
|
+
)
|
|
1314
|
+
|
|
1315
|
+
req = self._build_request_async(
|
|
1316
|
+
method="GET",
|
|
1317
|
+
path="/subscriptions",
|
|
1318
|
+
base_url=base_url,
|
|
1319
|
+
url_variables=url_variables,
|
|
1320
|
+
request=request,
|
|
1321
|
+
request_body_required=False,
|
|
1322
|
+
request_has_path_params=False,
|
|
1323
|
+
request_has_query_params=True,
|
|
1324
|
+
user_agent_header="user-agent",
|
|
1325
|
+
accept_header_value="application/hal+json",
|
|
1326
|
+
http_headers=http_headers,
|
|
1327
|
+
_globals=models.ListAllSubscriptionsGlobals(
|
|
1328
|
+
profile_id=self.sdk_configuration.globals.profile_id,
|
|
1329
|
+
testmode=self.sdk_configuration.globals.testmode,
|
|
1330
|
+
),
|
|
1331
|
+
security=self.sdk_configuration.security,
|
|
1332
|
+
timeout_ms=timeout_ms,
|
|
1333
|
+
)
|
|
1334
|
+
|
|
1335
|
+
if retries == UNSET:
|
|
1336
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1337
|
+
retries = self.sdk_configuration.retry_config
|
|
1338
|
+
else:
|
|
1339
|
+
retries = utils.RetryConfig(
|
|
1340
|
+
"backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
|
|
1341
|
+
)
|
|
1342
|
+
|
|
1343
|
+
retry_config = None
|
|
1344
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1345
|
+
retry_config = (retries, ["5xx"])
|
|
1346
|
+
|
|
1347
|
+
http_res = await self.do_request_async(
|
|
1348
|
+
hook_ctx=HookContext(
|
|
1349
|
+
config=self.sdk_configuration,
|
|
1350
|
+
base_url=base_url or "",
|
|
1351
|
+
operation_id="list-all-subscriptions",
|
|
1352
|
+
oauth2_scopes=None,
|
|
1353
|
+
security_source=get_security_from_env(
|
|
1354
|
+
self.sdk_configuration.security, models.Security
|
|
1355
|
+
),
|
|
1356
|
+
),
|
|
1357
|
+
request=req,
|
|
1358
|
+
error_status_codes=["400", "404", "4XX", "5XX"],
|
|
1359
|
+
retry_config=retry_config,
|
|
1360
|
+
)
|
|
1361
|
+
|
|
1362
|
+
response_data: Any = None
|
|
1363
|
+
if utils.match_response(http_res, "200", "application/hal+json"):
|
|
1364
|
+
return unmarshal_json_response(
|
|
1365
|
+
models.ListAllSubscriptionsResponse, http_res
|
|
1366
|
+
)
|
|
1367
|
+
if utils.match_response(http_res, ["400", "404"], "application/hal+json"):
|
|
1368
|
+
response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
|
|
1369
|
+
raise models.ErrorResponse(response_data, http_res)
|
|
1370
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1371
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1372
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
1373
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1374
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1375
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
1376
|
+
|
|
1377
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
1378
|
+
|
|
1379
|
+
def list_payments(
|
|
1380
|
+
self,
|
|
1381
|
+
*,
|
|
1382
|
+
customer_id: str,
|
|
1383
|
+
subscription_id: str,
|
|
1384
|
+
from_: Optional[str] = None,
|
|
1385
|
+
limit: OptionalNullable[int] = UNSET,
|
|
1386
|
+
sort: Optional[models.Sorting] = None,
|
|
1387
|
+
profile_id: Optional[str] = None,
|
|
1388
|
+
testmode: Optional[bool] = None,
|
|
1389
|
+
idempotency_key: Optional[str] = None,
|
|
1390
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1391
|
+
server_url: Optional[str] = None,
|
|
1392
|
+
timeout_ms: Optional[int] = None,
|
|
1393
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1394
|
+
) -> models.ListSubscriptionPaymentsResponse:
|
|
1395
|
+
r"""List subscription payments
|
|
1396
|
+
|
|
1397
|
+
Retrieve all payments of a specific subscription.
|
|
1398
|
+
|
|
1399
|
+
The results are paginated.
|
|
1400
|
+
|
|
1401
|
+
:param customer_id: Provide the ID of the related customer.
|
|
1402
|
+
:param subscription_id: Provide the ID of the related subscription.
|
|
1403
|
+
:param from_: Provide an ID to start the result set from the item with the given ID and onwards. This allows you to paginate the result set.
|
|
1404
|
+
:param limit: The maximum number of items to return. Defaults to 50 items.
|
|
1405
|
+
:param sort: Used for setting the direction of the result set. Defaults to descending order, meaning the results are ordered from newest to oldest.
|
|
1406
|
+
:param profile_id: The identifier referring to the [profile](get-profile) you wish to retrieve the resources for. Most API credentials are linked to a single profile. In these cases the `profileId` can be omitted. For organization-level credentials such as OAuth access tokens however, the `profileId` parameter is required.
|
|
1407
|
+
:param testmode: Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter can be omitted. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
|
|
1408
|
+
:param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
|
|
1409
|
+
:param retries: Override the default retry configuration for this method
|
|
1410
|
+
:param server_url: Override the default server URL for this method
|
|
1411
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1412
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1413
|
+
"""
|
|
1414
|
+
base_url = None
|
|
1415
|
+
url_variables = None
|
|
1416
|
+
if timeout_ms is None:
|
|
1417
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1418
|
+
|
|
1419
|
+
if server_url is not None:
|
|
1420
|
+
base_url = server_url
|
|
1421
|
+
else:
|
|
1422
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1423
|
+
|
|
1424
|
+
request = models.ListSubscriptionPaymentsRequest(
|
|
1425
|
+
customer_id=customer_id,
|
|
1426
|
+
subscription_id=subscription_id,
|
|
1427
|
+
from_=from_,
|
|
1428
|
+
limit=limit,
|
|
1429
|
+
sort=sort,
|
|
1430
|
+
profile_id=profile_id,
|
|
1431
|
+
testmode=testmode,
|
|
1432
|
+
idempotency_key=idempotency_key,
|
|
1433
|
+
)
|
|
1434
|
+
|
|
1435
|
+
req = self._build_request(
|
|
1436
|
+
method="GET",
|
|
1437
|
+
path="/customers/{customerId}/subscriptions/{subscriptionId}/payments",
|
|
1438
|
+
base_url=base_url,
|
|
1439
|
+
url_variables=url_variables,
|
|
1440
|
+
request=request,
|
|
1441
|
+
request_body_required=False,
|
|
1442
|
+
request_has_path_params=True,
|
|
1443
|
+
request_has_query_params=True,
|
|
1444
|
+
user_agent_header="user-agent",
|
|
1445
|
+
accept_header_value="application/hal+json",
|
|
1446
|
+
http_headers=http_headers,
|
|
1447
|
+
_globals=models.ListSubscriptionPaymentsGlobals(
|
|
1448
|
+
profile_id=self.sdk_configuration.globals.profile_id,
|
|
1449
|
+
testmode=self.sdk_configuration.globals.testmode,
|
|
1450
|
+
),
|
|
1451
|
+
security=self.sdk_configuration.security,
|
|
1452
|
+
timeout_ms=timeout_ms,
|
|
1453
|
+
)
|
|
1454
|
+
|
|
1455
|
+
if retries == UNSET:
|
|
1456
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1457
|
+
retries = self.sdk_configuration.retry_config
|
|
1458
|
+
else:
|
|
1459
|
+
retries = utils.RetryConfig(
|
|
1460
|
+
"backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
|
|
1461
|
+
)
|
|
1462
|
+
|
|
1463
|
+
retry_config = None
|
|
1464
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1465
|
+
retry_config = (retries, ["5xx"])
|
|
1466
|
+
|
|
1467
|
+
http_res = self.do_request(
|
|
1468
|
+
hook_ctx=HookContext(
|
|
1469
|
+
config=self.sdk_configuration,
|
|
1470
|
+
base_url=base_url or "",
|
|
1471
|
+
operation_id="list-subscription-payments",
|
|
1472
|
+
oauth2_scopes=None,
|
|
1473
|
+
security_source=get_security_from_env(
|
|
1474
|
+
self.sdk_configuration.security, models.Security
|
|
1475
|
+
),
|
|
1476
|
+
),
|
|
1477
|
+
request=req,
|
|
1478
|
+
error_status_codes=["400", "4XX", "5XX"],
|
|
1479
|
+
retry_config=retry_config,
|
|
1480
|
+
)
|
|
1481
|
+
|
|
1482
|
+
response_data: Any = None
|
|
1483
|
+
if utils.match_response(http_res, "200", "application/hal+json"):
|
|
1484
|
+
return unmarshal_json_response(
|
|
1485
|
+
models.ListSubscriptionPaymentsResponse, http_res
|
|
1486
|
+
)
|
|
1487
|
+
if utils.match_response(http_res, "400", "application/hal+json"):
|
|
1488
|
+
response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
|
|
1489
|
+
raise models.ErrorResponse(response_data, http_res)
|
|
1490
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1491
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1492
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
1493
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1494
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1495
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
1496
|
+
|
|
1497
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
1498
|
+
|
|
1499
|
+
async def list_payments_async(
|
|
1500
|
+
self,
|
|
1501
|
+
*,
|
|
1502
|
+
customer_id: str,
|
|
1503
|
+
subscription_id: str,
|
|
1504
|
+
from_: Optional[str] = None,
|
|
1505
|
+
limit: OptionalNullable[int] = UNSET,
|
|
1506
|
+
sort: Optional[models.Sorting] = None,
|
|
1507
|
+
profile_id: Optional[str] = None,
|
|
1508
|
+
testmode: Optional[bool] = None,
|
|
1509
|
+
idempotency_key: Optional[str] = None,
|
|
1510
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1511
|
+
server_url: Optional[str] = None,
|
|
1512
|
+
timeout_ms: Optional[int] = None,
|
|
1513
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1514
|
+
) -> models.ListSubscriptionPaymentsResponse:
|
|
1515
|
+
r"""List subscription payments
|
|
1516
|
+
|
|
1517
|
+
Retrieve all payments of a specific subscription.
|
|
1518
|
+
|
|
1519
|
+
The results are paginated.
|
|
1520
|
+
|
|
1521
|
+
:param customer_id: Provide the ID of the related customer.
|
|
1522
|
+
:param subscription_id: Provide the ID of the related subscription.
|
|
1523
|
+
:param from_: Provide an ID to start the result set from the item with the given ID and onwards. This allows you to paginate the result set.
|
|
1524
|
+
:param limit: The maximum number of items to return. Defaults to 50 items.
|
|
1525
|
+
:param sort: Used for setting the direction of the result set. Defaults to descending order, meaning the results are ordered from newest to oldest.
|
|
1526
|
+
:param profile_id: The identifier referring to the [profile](get-profile) you wish to retrieve the resources for. Most API credentials are linked to a single profile. In these cases the `profileId` can be omitted. For organization-level credentials such as OAuth access tokens however, the `profileId` parameter is required.
|
|
1527
|
+
:param testmode: Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter can be omitted. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
|
|
1528
|
+
:param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
|
|
1529
|
+
:param retries: Override the default retry configuration for this method
|
|
1530
|
+
:param server_url: Override the default server URL for this method
|
|
1531
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1532
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1533
|
+
"""
|
|
1534
|
+
base_url = None
|
|
1535
|
+
url_variables = None
|
|
1536
|
+
if timeout_ms is None:
|
|
1537
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1538
|
+
|
|
1539
|
+
if server_url is not None:
|
|
1540
|
+
base_url = server_url
|
|
1541
|
+
else:
|
|
1542
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1543
|
+
|
|
1544
|
+
request = models.ListSubscriptionPaymentsRequest(
|
|
1545
|
+
customer_id=customer_id,
|
|
1546
|
+
subscription_id=subscription_id,
|
|
1547
|
+
from_=from_,
|
|
1548
|
+
limit=limit,
|
|
1549
|
+
sort=sort,
|
|
1550
|
+
profile_id=profile_id,
|
|
1551
|
+
testmode=testmode,
|
|
1552
|
+
idempotency_key=idempotency_key,
|
|
1553
|
+
)
|
|
1554
|
+
|
|
1555
|
+
req = self._build_request_async(
|
|
1556
|
+
method="GET",
|
|
1557
|
+
path="/customers/{customerId}/subscriptions/{subscriptionId}/payments",
|
|
1558
|
+
base_url=base_url,
|
|
1559
|
+
url_variables=url_variables,
|
|
1560
|
+
request=request,
|
|
1561
|
+
request_body_required=False,
|
|
1562
|
+
request_has_path_params=True,
|
|
1563
|
+
request_has_query_params=True,
|
|
1564
|
+
user_agent_header="user-agent",
|
|
1565
|
+
accept_header_value="application/hal+json",
|
|
1566
|
+
http_headers=http_headers,
|
|
1567
|
+
_globals=models.ListSubscriptionPaymentsGlobals(
|
|
1568
|
+
profile_id=self.sdk_configuration.globals.profile_id,
|
|
1569
|
+
testmode=self.sdk_configuration.globals.testmode,
|
|
1570
|
+
),
|
|
1571
|
+
security=self.sdk_configuration.security,
|
|
1572
|
+
timeout_ms=timeout_ms,
|
|
1573
|
+
)
|
|
1574
|
+
|
|
1575
|
+
if retries == UNSET:
|
|
1576
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1577
|
+
retries = self.sdk_configuration.retry_config
|
|
1578
|
+
else:
|
|
1579
|
+
retries = utils.RetryConfig(
|
|
1580
|
+
"backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
|
|
1581
|
+
)
|
|
1582
|
+
|
|
1583
|
+
retry_config = None
|
|
1584
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1585
|
+
retry_config = (retries, ["5xx"])
|
|
1586
|
+
|
|
1587
|
+
http_res = await self.do_request_async(
|
|
1588
|
+
hook_ctx=HookContext(
|
|
1589
|
+
config=self.sdk_configuration,
|
|
1590
|
+
base_url=base_url or "",
|
|
1591
|
+
operation_id="list-subscription-payments",
|
|
1592
|
+
oauth2_scopes=None,
|
|
1593
|
+
security_source=get_security_from_env(
|
|
1594
|
+
self.sdk_configuration.security, models.Security
|
|
1595
|
+
),
|
|
1596
|
+
),
|
|
1597
|
+
request=req,
|
|
1598
|
+
error_status_codes=["400", "4XX", "5XX"],
|
|
1599
|
+
retry_config=retry_config,
|
|
1600
|
+
)
|
|
1601
|
+
|
|
1602
|
+
response_data: Any = None
|
|
1603
|
+
if utils.match_response(http_res, "200", "application/hal+json"):
|
|
1604
|
+
return unmarshal_json_response(
|
|
1605
|
+
models.ListSubscriptionPaymentsResponse, http_res
|
|
1606
|
+
)
|
|
1607
|
+
if utils.match_response(http_res, "400", "application/hal+json"):
|
|
1608
|
+
response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
|
|
1609
|
+
raise models.ErrorResponse(response_data, http_res)
|
|
1610
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1611
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1612
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
1613
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1614
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1615
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
1616
|
+
|
|
1617
|
+
raise models.APIError("Unexpected response received", http_res)
|