From 0885737fa4160bc9d0415f7a9c794e4280d9befb Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Tue, 7 Jun 2022 17:04:26 -0700 Subject: [PATCH] Codegen for openapi v152 --- OPENAPI_VERSION | 2 +- stripe/api_resources/customer.py | 49 ++++++++++++++++++++++++++++---- tests/test_generated_examples.py | 15 ++++++++++ 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 19a48dddd..0b9a2a89f 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v146 \ No newline at end of file +v152 \ No newline at end of file diff --git a/stripe/api_resources/customer.py b/stripe/api_resources/customer.py index 4b78fcdca..6ca340e4c 100644 --- a/stripe/api_resources/customer.py +++ b/stripe/api_resources/customer.py @@ -23,11 +23,6 @@ http_verb="get", http_path="payment_methods", ) -@nested_resource_class_methods( - "cash_balance", - operations=["retrieve", "update"], - resource_plural="cash_balance", -) @nested_resource_class_methods( "balance_transaction", operations=["create", "retrieve", "update", "list"], @@ -120,3 +115,47 @@ def delete_discount(self, **params): url = self.instance_url() + "/discount" _, api_key = requestor.request("delete", url, params) self.refresh_from({"discount": None}, api_key, True) + + @classmethod + def retrieve_cash_balance( + cls, + customer, + nested_id=None, + api_key=None, + stripe_version=None, + stripe_account=None, + **params + ): + # The nested_id parameter is required for backwards compatibility purposes and is ignored. + requestor = api_requestor.APIRequestor( + api_key, api_version=stripe_version, account=stripe_account + ) + url = "/v1/customers/{customer}/cash_balance".format( + customer=util.sanitize_id(customer) + ) + response, api_key = requestor.request("get", url, params) + return util.convert_to_stripe_object( + response, api_key, stripe_version, stripe_account + ) + + @classmethod + def modify_cash_balance( + cls, + customer, + nested_id=None, + api_key=None, + stripe_version=None, + stripe_account=None, + **params + ): + # The nested_id parameter is required for backwards compatibility purposes and is ignored. + requestor = api_requestor.APIRequestor( + api_key, api_version=stripe_version, account=stripe_account + ) + url = "/v1/customers/{customer}/cash_balance".format( + customer=util.sanitize_id(customer) + ) + response, api_key = requestor.request("post", url, params) + return util.convert_to_stripe_object( + response, api_key, stripe_version, stripe_account + ) diff --git a/tests/test_generated_examples.py b/tests/test_generated_examples.py index a8d20239e..47739f613 100644 --- a/tests/test_generated_examples.py +++ b/tests/test_generated_examples.py @@ -352,6 +352,21 @@ def test_apps_secret_delete_where(self, request_mock): ) request_mock.assert_requested("post", "/v1/apps/secrets/delete") + def test_customer_cashbalance_retrieve(self, request_mock): + stripe.Customer.retrieve_cash_balance("cus_123") + request_mock.assert_requested( + "get", "/v1/customers/cus_123/cash_balance" + ) + + def test_customer_cashbalance_update(self, request_mock): + stripe.Customer.modify_cash_balance( + "cus_123", + settings={"reconciliation_mode": "manual"}, + ) + request_mock.assert_requested( + "post", "/v1/customers/cus_123/cash_balance" + ) + def test_customer_list(self, request_mock): stripe.Customer.list(limit=3) request_mock.assert_requested("get", "/v1/customers")