diff --git a/stripe/api_resources/billing_portal/configuration.py b/stripe/api_resources/billing_portal/configuration.py index bc9c20c8e..fbcab4ded 100644 --- a/stripe/api_resources/billing_portal/configuration.py +++ b/stripe/api_resources/billing_portal/configuration.py @@ -2,7 +2,6 @@ # File generated from our OpenAPI spec from __future__ import absolute_import, division, print_function -from stripe import util from stripe.api_resources.abstract import ( CreateableAPIResource, ListableAPIResource, @@ -13,6 +12,7 @@ from stripe.stripe_object import StripeObject from typing import Any, Dict, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus class Configuration( @@ -83,35 +83,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - configuration, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/billing_portal/configurations/{configuration}".format( - configuration=util.sanitize_id(configuration) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/billing_portal/configurations/{configuration}".format( - configuration=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Configuration": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Configuration": diff --git a/stripe/api_resources/charge.py b/stripe/api_resources/charge.py index 807fd6835..8d3377965 100644 --- a/stripe/api_resources/charge.py +++ b/stripe/api_resources/charge.py @@ -14,6 +14,7 @@ from stripe.stripe_object import StripeObject from typing import Any, Dict, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -169,33 +170,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - charge, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/charges/{charge}".format(charge=util.sanitize_id(charge)), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/charges/{charge}".format( - charge=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Charge": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Charge": diff --git a/stripe/api_resources/coupon.py b/stripe/api_resources/coupon.py index aa01ccc6c..515a299a3 100644 --- a/stripe/api_resources/coupon.py +++ b/stripe/api_resources/coupon.py @@ -107,33 +107,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - coupon, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/coupons/{coupon}".format(coupon=util.sanitize_id(coupon)), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/coupons/{coupon}".format( - coupon=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Coupon": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Coupon": diff --git a/stripe/api_resources/credit_note.py b/stripe/api_resources/credit_note.py index 32b7db337..57b8d8ea5 100644 --- a/stripe/api_resources/credit_note.py +++ b/stripe/api_resources/credit_note.py @@ -14,6 +14,7 @@ from stripe.stripe_object import StripeObject from typing import Any, Dict, List, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -119,33 +120,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - id, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/credit_notes/{id}".format(id=util.sanitize_id(id)), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/credit_notes/{id}".format( - id=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "CreditNote": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def preview( diff --git a/stripe/api_resources/customer.py b/stripe/api_resources/customer.py index dfe725b32..70fb1de53 100644 --- a/stripe/api_resources/customer.py +++ b/stripe/api_resources/customer.py @@ -241,35 +241,9 @@ def list_payment_methods(self, idempotency_key=None, **params): ) @classmethod - def _cls_modify( - cls, - customer, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/customers/{customer}".format( - customer=util.sanitize_id(customer) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/customers/{customer}".format( - customer=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Customer": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> Any: diff --git a/stripe/api_resources/dispute.py b/stripe/api_resources/dispute.py index 803d8bc63..91592e6d2 100644 --- a/stripe/api_resources/dispute.py +++ b/stripe/api_resources/dispute.py @@ -12,6 +12,7 @@ from stripe.stripe_object import StripeObject from typing import Dict, List, Optional from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -106,33 +107,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - dispute, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/disputes/{dispute}".format(dispute=util.sanitize_id(dispute)), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/disputes/{dispute}".format( - dispute=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Dispute": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Dispute": diff --git a/stripe/api_resources/file_link.py b/stripe/api_resources/file_link.py index 47c002ac7..c07607fb8 100644 --- a/stripe/api_resources/file_link.py +++ b/stripe/api_resources/file_link.py @@ -2,7 +2,6 @@ # File generated from our OpenAPI spec from __future__ import absolute_import, division, print_function -from stripe import util from stripe.api_resources.abstract import ( CreateableAPIResource, ListableAPIResource, @@ -12,6 +11,7 @@ from stripe.api_resources.list_object import ListObject from typing import Dict, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -85,33 +85,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - link, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/file_links/{link}".format(link=util.sanitize_id(link)), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/file_links/{link}".format( - link=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "FileLink": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "FileLink": diff --git a/stripe/api_resources/identity/verification_session.py b/stripe/api_resources/identity/verification_session.py index b202409a5..8a979ea68 100644 --- a/stripe/api_resources/identity/verification_session.py +++ b/stripe/api_resources/identity/verification_session.py @@ -13,6 +13,7 @@ from stripe.stripe_object import StripeObject from typing import Dict, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -132,35 +133,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - session, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/identity/verification_sessions/{session}".format( - session=util.sanitize_id(session) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/identity/verification_sessions/{session}".format( - session=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "VerificationSession": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def _cls_redact( diff --git a/stripe/api_resources/invoice.py b/stripe/api_resources/invoice.py index 0c9bb25c6..5ecfdaea9 100644 --- a/stripe/api_resources/invoice.py +++ b/stripe/api_resources/invoice.py @@ -279,33 +279,9 @@ def mark_uncollectible(self, idempotency_key=None, **params): ) @classmethod - def _cls_modify( - cls, - invoice, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/invoices/{invoice}".format(invoice=util.sanitize_id(invoice)), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/invoices/{invoice}".format( - invoice=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Invoice": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def _cls_pay( diff --git a/stripe/api_resources/invoice_item.py b/stripe/api_resources/invoice_item.py index 8581ada5e..715bb98ef 100644 --- a/stripe/api_resources/invoice_item.py +++ b/stripe/api_resources/invoice_item.py @@ -133,35 +133,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - invoiceitem, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/invoiceitems/{invoiceitem}".format( - invoiceitem=util.sanitize_id(invoiceitem) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/invoiceitems/{invoiceitem}".format( - invoiceitem=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "InvoiceItem": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "InvoiceItem": diff --git a/stripe/api_resources/issuing/authorization.py b/stripe/api_resources/issuing/authorization.py index 2c0e3729a..0107974a7 100644 --- a/stripe/api_resources/issuing/authorization.py +++ b/stripe/api_resources/issuing/authorization.py @@ -12,6 +12,7 @@ from stripe.stripe_object import StripeObject from typing import Dict, List, Optional from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -144,35 +145,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - authorization, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/issuing/authorizations/{authorization}".format( - authorization=util.sanitize_id(authorization) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/issuing/authorizations/{authorization}".format( - authorization=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Authorization": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Authorization": diff --git a/stripe/api_resources/issuing/card.py b/stripe/api_resources/issuing/card.py index 300b7993b..aa7f11de8 100644 --- a/stripe/api_resources/issuing/card.py +++ b/stripe/api_resources/issuing/card.py @@ -14,6 +14,7 @@ from stripe.stripe_object import StripeObject from typing import Dict, Optional, cast from typing_extensions import Literal, Type +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -99,33 +100,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - card, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/issuing/cards/{card}".format(card=util.sanitize_id(card)), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/issuing/cards/{card}".format( - card=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Card": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Card": diff --git a/stripe/api_resources/issuing/cardholder.py b/stripe/api_resources/issuing/cardholder.py index 74bbdf8ab..a3b7d6f65 100644 --- a/stripe/api_resources/issuing/cardholder.py +++ b/stripe/api_resources/issuing/cardholder.py @@ -2,7 +2,6 @@ # File generated from our OpenAPI spec from __future__ import absolute_import, division, print_function -from stripe import util from stripe.api_resources.abstract import ( CreateableAPIResource, ListableAPIResource, @@ -12,6 +11,7 @@ from stripe.stripe_object import StripeObject from typing import Dict, List, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus class Cardholder( @@ -87,35 +87,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - cardholder, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/issuing/cardholders/{cardholder}".format( - cardholder=util.sanitize_id(cardholder) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/issuing/cardholders/{cardholder}".format( - cardholder=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Cardholder": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Cardholder": diff --git a/stripe/api_resources/issuing/dispute.py b/stripe/api_resources/issuing/dispute.py index df1742e20..afa7699f1 100644 --- a/stripe/api_resources/issuing/dispute.py +++ b/stripe/api_resources/issuing/dispute.py @@ -13,6 +13,7 @@ from stripe.stripe_object import StripeObject from typing import Dict, List, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -90,35 +91,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - dispute, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/issuing/disputes/{dispute}".format( - dispute=util.sanitize_id(dispute) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/issuing/disputes/{dispute}".format( - dispute=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Dispute": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Dispute": diff --git a/stripe/api_resources/issuing/transaction.py b/stripe/api_resources/issuing/transaction.py index 44adcf9d3..6059ad85c 100644 --- a/stripe/api_resources/issuing/transaction.py +++ b/stripe/api_resources/issuing/transaction.py @@ -2,7 +2,6 @@ # File generated from our OpenAPI spec from __future__ import absolute_import, division, print_function -from stripe import util from stripe.api_resources.abstract import ( ListableAPIResource, UpdateableAPIResource, @@ -12,6 +11,7 @@ from stripe.stripe_object import StripeObject from typing import Dict, Optional from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -79,35 +79,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - transaction, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/issuing/transactions/{transaction}".format( - transaction=util.sanitize_id(transaction) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/issuing/transactions/{transaction}".format( - transaction=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Transaction": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Transaction": diff --git a/stripe/api_resources/payment_intent.py b/stripe/api_resources/payment_intent.py index 7a822f41d..7b1631c4b 100644 --- a/stripe/api_resources/payment_intent.py +++ b/stripe/api_resources/payment_intent.py @@ -14,6 +14,7 @@ from stripe.stripe_object import StripeObject from typing import Any, Dict, List, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -286,35 +287,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - intent, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/payment_intents/{intent}".format( - intent=util.sanitize_id(intent) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/payment_intents/{intent}".format( - intent=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "PaymentIntent": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "PaymentIntent": diff --git a/stripe/api_resources/payment_link.py b/stripe/api_resources/payment_link.py index 41e6e4eb0..97659424a 100644 --- a/stripe/api_resources/payment_link.py +++ b/stripe/api_resources/payment_link.py @@ -13,6 +13,7 @@ from stripe.stripe_object import StripeObject from typing import Any, Dict, List, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -142,35 +143,9 @@ def list_line_items(self, idempotency_key=None, **params): ) @classmethod - def _cls_modify( - cls, - payment_link, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/payment_links/{payment_link}".format( - payment_link=util.sanitize_id(payment_link) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/payment_links/{payment_link}".format( - payment_link=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "PaymentLink": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "PaymentLink": diff --git a/stripe/api_resources/payment_method.py b/stripe/api_resources/payment_method.py index 2e81fd21f..624e358be 100644 --- a/stripe/api_resources/payment_method.py +++ b/stripe/api_resources/payment_method.py @@ -13,6 +13,7 @@ from stripe.stripe_object import StripeObject from typing import Dict, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -183,35 +184,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - payment_method, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/payment_methods/{payment_method}".format( - payment_method=util.sanitize_id(payment_method) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/payment_methods/{payment_method}".format( - payment_method=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "PaymentMethod": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "PaymentMethod": diff --git a/stripe/api_resources/payment_method_domain.py b/stripe/api_resources/payment_method_domain.py index 032ef7a6a..89c529219 100644 --- a/stripe/api_resources/payment_method_domain.py +++ b/stripe/api_resources/payment_method_domain.py @@ -12,6 +12,7 @@ from stripe.stripe_object import StripeObject from typing import cast from typing_extensions import Literal +from urllib.parse import quote_plus class PaymentMethodDomain( @@ -82,35 +83,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - payment_method_domain, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/payment_method_domains/{payment_method_domain}".format( - payment_method_domain=util.sanitize_id(payment_method_domain) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/payment_method_domains/{payment_method_domain}".format( - payment_method_domain=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "PaymentMethodDomain": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "PaymentMethodDomain": diff --git a/stripe/api_resources/payout.py b/stripe/api_resources/payout.py index 89bcaf23e..662686dd6 100644 --- a/stripe/api_resources/payout.py +++ b/stripe/api_resources/payout.py @@ -12,6 +12,7 @@ from stripe.api_resources.list_object import ListObject from typing import Any, Dict, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -137,33 +138,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - payout, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/payouts/{payout}".format(payout=util.sanitize_id(payout)), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/payouts/{payout}".format( - payout=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Payout": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Payout": diff --git a/stripe/api_resources/plan.py b/stripe/api_resources/plan.py index 7c9fade5b..ae8f29327 100644 --- a/stripe/api_resources/plan.py +++ b/stripe/api_resources/plan.py @@ -116,31 +116,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - plan, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/plans/{plan}".format(plan=util.sanitize_id(plan)), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/plans/{plan}".format(plan=util.sanitize_id(self.get("id"))), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Plan": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Plan": diff --git a/stripe/api_resources/price.py b/stripe/api_resources/price.py index 118c71d4b..6cce39f73 100644 --- a/stripe/api_resources/price.py +++ b/stripe/api_resources/price.py @@ -2,7 +2,6 @@ # File generated from our OpenAPI spec from __future__ import absolute_import, division, print_function -from stripe import util from stripe.api_resources.abstract import ( CreateableAPIResource, ListableAPIResource, @@ -14,6 +13,7 @@ from stripe.stripe_object import StripeObject from typing import Any, Dict, List, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus class Price( @@ -98,33 +98,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - price, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/prices/{price}".format(price=util.sanitize_id(price)), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/prices/{price}".format( - price=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Price": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Price": diff --git a/stripe/api_resources/product.py b/stripe/api_resources/product.py index d1c4c9fd4..1cf44dadd 100644 --- a/stripe/api_resources/product.py +++ b/stripe/api_resources/product.py @@ -123,31 +123,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - id, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/products/{id}".format(id=util.sanitize_id(id)), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/products/{id}".format(id=util.sanitize_id(self.get("id"))), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Product": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Product": diff --git a/stripe/api_resources/promotion_code.py b/stripe/api_resources/promotion_code.py index c027aff42..6a5df4514 100644 --- a/stripe/api_resources/promotion_code.py +++ b/stripe/api_resources/promotion_code.py @@ -2,7 +2,6 @@ # File generated from our OpenAPI spec from __future__ import absolute_import, division, print_function -from stripe import util from stripe.api_resources.abstract import ( CreateableAPIResource, ListableAPIResource, @@ -13,6 +12,7 @@ from stripe.stripe_object import StripeObject from typing import Any, Dict, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -89,35 +89,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - promotion_code, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/promotion_codes/{promotion_code}".format( - promotion_code=util.sanitize_id(promotion_code) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/promotion_codes/{promotion_code}".format( - promotion_code=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "PromotionCode": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "PromotionCode": diff --git a/stripe/api_resources/quote.py b/stripe/api_resources/quote.py index 948dd9600..08e1ff590 100644 --- a/stripe/api_resources/quote.py +++ b/stripe/api_resources/quote.py @@ -270,33 +270,9 @@ def list_line_items(self, idempotency_key=None, **params): ) @classmethod - def _cls_modify( - cls, - quote, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/quotes/{quote}".format(quote=util.sanitize_id(quote)), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/quotes/{quote}".format( - quote=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Quote": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Quote": diff --git a/stripe/api_resources/radar/value_list.py b/stripe/api_resources/radar/value_list.py index a72a1fa0e..f35d5ac06 100644 --- a/stripe/api_resources/radar/value_list.py +++ b/stripe/api_resources/radar/value_list.py @@ -104,35 +104,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - value_list, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/radar/value_lists/{value_list}".format( - value_list=util.sanitize_id(value_list) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/radar/value_lists/{value_list}".format( - value_list=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "ValueList": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "ValueList": diff --git a/stripe/api_resources/refund.py b/stripe/api_resources/refund.py index e054d55ff..2b0900899 100644 --- a/stripe/api_resources/refund.py +++ b/stripe/api_resources/refund.py @@ -14,6 +14,7 @@ from stripe.stripe_object import StripeObject from typing import Dict, Optional, cast from typing_extensions import Literal, Type +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -133,33 +134,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - refund, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/refunds/{refund}".format(refund=util.sanitize_id(refund)), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/refunds/{refund}".format( - refund=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Refund": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Refund": diff --git a/stripe/api_resources/setup_intent.py b/stripe/api_resources/setup_intent.py index 74a43cc81..252dd174a 100644 --- a/stripe/api_resources/setup_intent.py +++ b/stripe/api_resources/setup_intent.py @@ -13,6 +13,7 @@ from stripe.stripe_object import StripeObject from typing import Any, Dict, List, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -186,35 +187,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - intent, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/setup_intents/{intent}".format( - intent=util.sanitize_id(intent) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/setup_intents/{intent}".format( - intent=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "SetupIntent": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "SetupIntent": diff --git a/stripe/api_resources/shipping_rate.py b/stripe/api_resources/shipping_rate.py index a7c7af3c3..5190e6487 100644 --- a/stripe/api_resources/shipping_rate.py +++ b/stripe/api_resources/shipping_rate.py @@ -2,7 +2,6 @@ # File generated from our OpenAPI spec from __future__ import absolute_import, division, print_function -from stripe import util from stripe.api_resources.abstract import ( CreateableAPIResource, ListableAPIResource, @@ -13,6 +12,7 @@ from stripe.stripe_object import StripeObject from typing import Dict, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -88,35 +88,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - shipping_rate_token, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/shipping_rates/{shipping_rate_token}".format( - shipping_rate_token=util.sanitize_id(shipping_rate_token) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/shipping_rates/{shipping_rate_token}".format( - shipping_rate_token=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "ShippingRate": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "ShippingRate": diff --git a/stripe/api_resources/source.py b/stripe/api_resources/source.py index fbe8e8b48..a0b387ae9 100644 --- a/stripe/api_resources/source.py +++ b/stripe/api_resources/source.py @@ -122,33 +122,9 @@ def list_source_transactions(self, idempotency_key=None, **params): ) @classmethod - def _cls_modify( - cls, - source, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/sources/{source}".format(source=util.sanitize_id(source)), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/sources/{source}".format( - source=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Source": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Source": diff --git a/stripe/api_resources/subscription.py b/stripe/api_resources/subscription.py index 34ce5ad40..d4687a970 100644 --- a/stripe/api_resources/subscription.py +++ b/stripe/api_resources/subscription.py @@ -15,6 +15,7 @@ from stripe.stripe_object import StripeObject from typing import Any, Dict, List, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -198,37 +199,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - subscription_exposed_id, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/subscriptions/{subscription_exposed_id}".format( - subscription_exposed_id=util.sanitize_id( - subscription_exposed_id - ) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/subscriptions/{subscription_exposed_id}".format( - subscription_exposed_id=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Subscription": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def _cls_resume( diff --git a/stripe/api_resources/subscription_item.py b/stripe/api_resources/subscription_item.py index 2e07a0a56..946aad834 100644 --- a/stripe/api_resources/subscription_item.py +++ b/stripe/api_resources/subscription_item.py @@ -116,35 +116,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - item, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/subscription_items/{item}".format( - item=util.sanitize_id(item) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/subscription_items/{item}".format( - item=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "SubscriptionItem": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "SubscriptionItem": diff --git a/stripe/api_resources/subscription_schedule.py b/stripe/api_resources/subscription_schedule.py index 0a71f4af0..d69dc560f 100644 --- a/stripe/api_resources/subscription_schedule.py +++ b/stripe/api_resources/subscription_schedule.py @@ -13,6 +13,7 @@ from stripe.stripe_object import StripeObject from typing import Any, Dict, List, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -127,35 +128,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - schedule, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/subscription_schedules/{schedule}".format( - schedule=util.sanitize_id(schedule) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/subscription_schedules/{schedule}".format( - schedule=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "SubscriptionSchedule": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def _cls_release( diff --git a/stripe/api_resources/tax/settings.py b/stripe/api_resources/tax/settings.py index 33d8dab14..75296be62 100644 --- a/stripe/api_resources/tax/settings.py +++ b/stripe/api_resources/tax/settings.py @@ -9,6 +9,7 @@ from stripe.stripe_object import StripeObject from typing import Optional from typing_extensions import Literal +from urllib.parse import quote_plus class Settings( @@ -30,17 +31,9 @@ class Settings( status_details: StripeObject @classmethod - def modify( - cls, api_key=None, stripe_version=None, stripe_account=None, **params - ): - return cls._static_request( - "post", - "/v1/tax/settings", - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) + def modify(cls, id, **params) -> "Settings": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, **params) -> "Settings": diff --git a/stripe/api_resources/tax_rate.py b/stripe/api_resources/tax_rate.py index 4311ba223..31ea852b7 100644 --- a/stripe/api_resources/tax_rate.py +++ b/stripe/api_resources/tax_rate.py @@ -2,7 +2,6 @@ # File generated from our OpenAPI spec from __future__ import absolute_import, division, print_function -from stripe import util from stripe.api_resources.abstract import ( CreateableAPIResource, ListableAPIResource, @@ -11,6 +10,7 @@ from stripe.api_resources.list_object import ListObject from typing import Dict, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus class TaxRate( @@ -85,35 +85,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - tax_rate, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/tax_rates/{tax_rate}".format( - tax_rate=util.sanitize_id(tax_rate) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/tax_rates/{tax_rate}".format( - tax_rate=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "TaxRate": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "TaxRate": diff --git a/stripe/api_resources/terminal/configuration.py b/stripe/api_resources/terminal/configuration.py index b0a8d8a7a..256fda63e 100644 --- a/stripe/api_resources/terminal/configuration.py +++ b/stripe/api_resources/terminal/configuration.py @@ -95,35 +95,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - configuration, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/terminal/configurations/{configuration}".format( - configuration=util.sanitize_id(configuration) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/terminal/configurations/{configuration}".format( - configuration=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> Any: + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> Any: diff --git a/stripe/api_resources/terminal/location.py b/stripe/api_resources/terminal/location.py index 143fe94b8..1755c8378 100644 --- a/stripe/api_resources/terminal/location.py +++ b/stripe/api_resources/terminal/location.py @@ -97,35 +97,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - location, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/terminal/locations/{location}".format( - location=util.sanitize_id(location) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/terminal/locations/{location}".format( - location=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> Any: + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> Any: diff --git a/stripe/api_resources/terminal/reader.py b/stripe/api_resources/terminal/reader.py index 3835c160b..f98dc0099 100644 --- a/stripe/api_resources/terminal/reader.py +++ b/stripe/api_resources/terminal/reader.py @@ -140,35 +140,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - reader, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/terminal/readers/{reader}".format( - reader=util.sanitize_id(reader) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/terminal/readers/{reader}".format( - reader=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> Any: + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def _cls_process_payment_intent( diff --git a/stripe/api_resources/topup.py b/stripe/api_resources/topup.py index 61f56d4d7..fcd1b8a3f 100644 --- a/stripe/api_resources/topup.py +++ b/stripe/api_resources/topup.py @@ -12,6 +12,7 @@ from stripe.api_resources.list_object import ListObject from typing import Dict, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -124,33 +125,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - topup, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/topups/{topup}".format(topup=util.sanitize_id(topup)), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/topups/{topup}".format( - topup=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Topup": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Topup": diff --git a/stripe/api_resources/transfer.py b/stripe/api_resources/transfer.py index 482d39d4d..64f1af6d2 100644 --- a/stripe/api_resources/transfer.py +++ b/stripe/api_resources/transfer.py @@ -2,7 +2,6 @@ # File generated from our OpenAPI spec from __future__ import absolute_import, division, print_function -from stripe import util from stripe.api_resources.abstract import ( CreateableAPIResource, ListableAPIResource, @@ -13,6 +12,7 @@ from stripe.api_resources.list_object import ListObject from typing import Dict, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -108,35 +108,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - transfer, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/transfers/{transfer}".format( - transfer=util.sanitize_id(transfer) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/transfers/{transfer}".format( - transfer=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "Transfer": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "Transfer": diff --git a/stripe/api_resources/treasury/financial_account.py b/stripe/api_resources/treasury/financial_account.py index 071889628..c4747b6f6 100644 --- a/stripe/api_resources/treasury/financial_account.py +++ b/stripe/api_resources/treasury/financial_account.py @@ -12,6 +12,7 @@ from stripe.stripe_object import StripeObject from typing import Dict, List, Optional, cast from typing_extensions import Literal +from urllib.parse import quote_plus from typing_extensions import TYPE_CHECKING @@ -93,35 +94,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - financial_account, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/treasury/financial_accounts/{financial_account}".format( - financial_account=util.sanitize_id(financial_account) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/treasury/financial_accounts/{financial_account}".format( - financial_account=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "FinancialAccount": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "FinancialAccount": diff --git a/stripe/api_resources/webhook_endpoint.py b/stripe/api_resources/webhook_endpoint.py index 9b5e5ab10..f79dd9468 100644 --- a/stripe/api_resources/webhook_endpoint.py +++ b/stripe/api_resources/webhook_endpoint.py @@ -105,35 +105,9 @@ def list( return result @classmethod - def _cls_modify( - cls, - webhook_endpoint, - api_key=None, - stripe_version=None, - stripe_account=None, - **params - ): - return cls._static_request( - "post", - "/v1/webhook_endpoints/{webhook_endpoint}".format( - webhook_endpoint=util.sanitize_id(webhook_endpoint) - ), - api_key=api_key, - stripe_version=stripe_version, - stripe_account=stripe_account, - params=params, - ) - - @util.class_method_variant("_cls_modify") - def modify(self, idempotency_key=None, **params): - return self._request( - "post", - "/v1/webhook_endpoints/{webhook_endpoint}".format( - webhook_endpoint=util.sanitize_id(self.get("id")) - ), - idempotency_key=idempotency_key, - params=params, - ) + def modify(cls, id, **params) -> "WebhookEndpoint": + url = "%s/%s" % (cls.class_url(), quote_plus(id)) + return cls._static_request("post", url, params=params) @classmethod def retrieve(cls, id, api_key=None, **params) -> "WebhookEndpoint":