From e179bf9949fbc5aa76ebc1965c12f9941168938e Mon Sep 17 00:00:00 2001 From: Bharat Chauhan Date: Mon, 21 Nov 2022 16:42:36 +0530 Subject: [PATCH] API Updates --- async_stripe/api_resources/__init__.py | 1 + .../abstract/updateable_api_resource.py | 4 ++ async_stripe/api_resources/account.py | 1 + async_stripe/api_resources/application_fee.py | 1 + .../api_resources/application_fee_refund.py | 1 + async_stripe/api_resources/bank_account.py | 13 ++-- async_stripe/api_resources/capability.py | 1 + async_stripe/api_resources/card.py | 17 ++++-- async_stripe/api_resources/charge.py | 1 + async_stripe/api_resources/customer.py | 1 + async_stripe/api_resources/ephermal_key.py | 1 + async_stripe/api_resources/file.py | 1 + async_stripe/api_resources/list_object.py | 1 + async_stripe/api_resources/person.py | 11 ++-- async_stripe/api_resources/quote.py | 1 + async_stripe/api_resources/reversal.py | 11 ++-- .../api_resources/search_result_object.py | 1 + async_stripe/api_resources/source.py | 1 + async_stripe/api_resources/transfer.py | 1 + async_stripe/api_resources/usage_record.py | 1 + tests/api_resources/test_order.py | 44 ------------- tests/api_resources/test_sku.py | 61 ------------------- tests/test_generated_examples.py | 26 -------- 23 files changed, 53 insertions(+), 149 deletions(-) delete mode 100644 tests/api_resources/test_order.py delete mode 100644 tests/api_resources/test_sku.py diff --git a/async_stripe/api_resources/__init__.py b/async_stripe/api_resources/__init__.py index 78b08bb..70faafa 100644 --- a/async_stripe/api_resources/__init__.py +++ b/async_stripe/api_resources/__init__.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from async_stripe.api_resources.abstract import * from async_stripe.api_resources import list_object diff --git a/async_stripe/api_resources/abstract/updateable_api_resource.py b/async_stripe/api_resources/abstract/updateable_api_resource.py index 3a226b7..d25f0fb 100644 --- a/async_stripe/api_resources/abstract/updateable_api_resource.py +++ b/async_stripe/api_resources/abstract/updateable_api_resource.py @@ -6,6 +6,10 @@ async def save_patch(self, idempotency_key=None): + """ + The `save` method is deprecated and will be removed in a future major version of the library. + Use the class method `modify` on the resource instead. + """ updated_params = self.serialize(None) if updated_params: diff --git a/async_stripe/api_resources/account.py b/async_stripe/api_resources/account.py index 92425a1..88869b1 100644 --- a/async_stripe/api_resources/account.py +++ b/async_stripe/api_resources/account.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import stripe from stripe import oauth, six from stripe import util diff --git a/async_stripe/api_resources/application_fee.py b/async_stripe/api_resources/application_fee.py index d7957c7..79f50c9 100644 --- a/async_stripe/api_resources/application_fee.py +++ b/async_stripe/api_resources/application_fee.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import stripe from stripe import util from stripe.api_resources.abstract import ListableAPIResource diff --git a/async_stripe/api_resources/application_fee_refund.py b/async_stripe/api_resources/application_fee_refund.py index 040f6b5..a36e931 100644 --- a/async_stripe/api_resources/application_fee_refund.py +++ b/async_stripe/api_resources/application_fee_refund.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import stripe diff --git a/async_stripe/api_resources/bank_account.py b/async_stripe/api_resources/bank_account.py index e3414e3..60c858b 100644 --- a/async_stripe/api_resources/bank_account.py +++ b/async_stripe/api_resources/bank_account.py @@ -1,11 +1,14 @@ +# -*- coding: utf-8 -*- import stripe async def modify_patch(cls, sid, **params): raise NotImplementedError( "Can't modify a bank account without a customer or account ID. " - "Call save on customer.sources.retrieve('bank_account_id') or " - "account.external_accounts.retrieve('bank_account_id') instead." + "Use stripe.Customer.modify_source('customer_id', 'bank_account_id', ...) " + "(see https://stripe.com/docs/api/customer_bank_accounts/update) or " + "stripe.Account.modify_external_account('customer_id', 'bank_account_id', ...) " + "(see https://stripe.com/docs/api/external_account_bank_accounts/update)." ) @@ -19,8 +22,10 @@ async def retrieve_patch( ): raise NotImplementedError( "Can't retrieve a bank account without a customer or account ID. " - "Use customer.sources.retrieve('bank_account_id') or " - "account.external_accounts.retrieve('bank_account_id') instead." + "Use stripe.customer.retrieve_source('customer_id', 'bank_account_id') " + "(see https://stripe.com/docs/api/customer_bank_accounts/retrieve) or " + "stripe.Account.retrieve_external_account('account_id', 'bank_account_id') " + "(see https://stripe.com/docs/api/external_account_bank_accounts/retrieve)." ) diff --git a/async_stripe/api_resources/capability.py b/async_stripe/api_resources/capability.py index 9fc3b99..8f37abb 100644 --- a/async_stripe/api_resources/capability.py +++ b/async_stripe/api_resources/capability.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import stripe diff --git a/async_stripe/api_resources/card.py b/async_stripe/api_resources/card.py index 0744bfc..2715c2c 100644 --- a/async_stripe/api_resources/card.py +++ b/async_stripe/api_resources/card.py @@ -1,11 +1,14 @@ +# -*- coding: utf-8 -*- import stripe async def modify_patch(cls, sid, **params): raise NotImplementedError( - "Can't modify a card without a customer or account " - "ID. Call save on customer.sources.retrieve('card_id'), or " - "account.external_accounts.retrieve('card_id') instead." + "Can't modify a card without a customer or account ID. " + "Use stripe.Customer.modify_source('customer_id', 'card_id', ...) " + "(see https://stripe.com/docs/api/cards/update) or " + "stripe.Account.modify_external_account('account_id', 'card_id', ...) " + "(see https://stripe.com/docs/api/external_account_cards/update)." ) @@ -18,9 +21,11 @@ async def retrieve_patch( **params ): raise NotImplementedError( - "Can't retrieve a card without a customer, or account " - "ID. Use customer.sources.retrieve('card_id'), or" - "account.external_accounts.retrieve('card_id') instead." + "Can't retrieve a card without a customer or account ID. " + "Use stripe.Customer.retrieve_source('customer_id', 'card_id') " + "(see https://stripe.com/docs/api/cards/retrieve) or " + "stripe.Account.retrieve_external_account('account_id', 'card_id') " + "(see https://stripe.com/docs/api/external_account_cards/retrieve)." ) diff --git a/async_stripe/api_resources/charge.py b/async_stripe/api_resources/charge.py index 13ad878..cde15a4 100644 --- a/async_stripe/api_resources/charge.py +++ b/async_stripe/api_resources/charge.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import stripe from stripe import util diff --git a/async_stripe/api_resources/customer.py b/async_stripe/api_resources/customer.py index 3cb2ea7..c3a7da1 100644 --- a/async_stripe/api_resources/customer.py +++ b/async_stripe/api_resources/customer.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import stripe from async_stripe.api_resources.abstract import patch_nested_resources from stripe import util diff --git a/async_stripe/api_resources/ephermal_key.py b/async_stripe/api_resources/ephermal_key.py index de46e2b..c6c1dbf 100644 --- a/async_stripe/api_resources/ephermal_key.py +++ b/async_stripe/api_resources/ephermal_key.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import stripe from stripe import api_requestor from stripe import util diff --git a/async_stripe/api_resources/file.py b/async_stripe/api_resources/file.py index 8906c1d..93cb51e 100644 --- a/async_stripe/api_resources/file.py +++ b/async_stripe/api_resources/file.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function import stripe diff --git a/async_stripe/api_resources/list_object.py b/async_stripe/api_resources/list_object.py index a181b79..156bb30 100644 --- a/async_stripe/api_resources/list_object.py +++ b/async_stripe/api_resources/list_object.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import stripe from stripe import six, util from stripe.stripe_object import StripeObject diff --git a/async_stripe/api_resources/person.py b/async_stripe/api_resources/person.py index 940c487..f2aee9b 100644 --- a/async_stripe/api_resources/person.py +++ b/async_stripe/api_resources/person.py @@ -1,17 +1,20 @@ +# -*- coding: utf-8 -*- import stripe async def modify_patch(cls, sid, **params): raise NotImplementedError( - "Can't modify a person without an account" - "ID. Call save on account.persons.retrieve('person_id')" + "Can't modify a person without an account ID. " + "Use stripe.Account.modify_person('account_id', 'person_id', ...) " + "(see https://stripe.com/docs/api/persons/update)." ) async def retrieve_patch(cls, id, api_key=None, **params): raise NotImplementedError( - "Can't retrieve a person without an account" - "ID. Use account.persons.retrieve('person_id')" + "Can't retrieve a person without an account ID. " + "Use stripe.Account.retrieve_person('account_id', 'person_id') " + "(see https://stripe.com/docs/api/persons/retrieve)." ) diff --git a/async_stripe/api_resources/quote.py b/async_stripe/api_resources/quote.py index a6ebb4e..380a671 100644 --- a/async_stripe/api_resources/quote.py +++ b/async_stripe/api_resources/quote.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import stripe from stripe import util from stripe import api_requestor diff --git a/async_stripe/api_resources/reversal.py b/async_stripe/api_resources/reversal.py index 47623fb..7f24fd7 100644 --- a/async_stripe/api_resources/reversal.py +++ b/async_stripe/api_resources/reversal.py @@ -1,17 +1,20 @@ +# -*- coding: utf-8 -*- import stripe def modify_patch(cls, sid, **params): raise NotImplementedError( - "Can't modify a reversal without a transfer" - "ID. Call save on transfer.reversals.retrieve('reversal_id')" + "Can't modify a reversal without a transfer ID. " + "Use stripe.Transfer.modify_reversal('transfer_id', 'reversal_id', ...) " + "(see https://stripe.com/docs/api/transfer_reversals/update)." ) def retrieve_patch(cls, id, api_key=None, **params): raise NotImplementedError( - "Can't retrieve a reversal without a transfer" - "ID. Use transfer.reversals.retrieve('reversal_id')" + "Can't retrieve a reversal without a transfer ID. " + "Use stripe.Transfer.retrieve_reversal('transfer_id', 'reversal_id') " + "(see https://stripe.com/docs/api/transfer_reversals/retrieve)." ) diff --git a/async_stripe/api_resources/search_result_object.py b/async_stripe/api_resources/search_result_object.py index 8cb8244..9b05cf9 100644 --- a/async_stripe/api_resources/search_result_object.py +++ b/async_stripe/api_resources/search_result_object.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import stripe diff --git a/async_stripe/api_resources/source.py b/async_stripe/api_resources/source.py index b01f8a5..c147a70 100644 --- a/async_stripe/api_resources/source.py +++ b/async_stripe/api_resources/source.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import stripe from stripe import error from stripe import util diff --git a/async_stripe/api_resources/transfer.py b/async_stripe/api_resources/transfer.py index a08a21c..d3b443e 100644 --- a/async_stripe/api_resources/transfer.py +++ b/async_stripe/api_resources/transfer.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import stripe from stripe import util from async_stripe.api_resources.abstract import patch_nested_resources diff --git a/async_stripe/api_resources/usage_record.py b/async_stripe/api_resources/usage_record.py index caf03fa..a0fa076 100644 --- a/async_stripe/api_resources/usage_record.py +++ b/async_stripe/api_resources/usage_record.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import stripe from stripe import api_requestor, util diff --git a/tests/api_resources/test_order.py b/tests/api_resources/test_order.py deleted file mode 100644 index 1fbfa8f..0000000 --- a/tests/api_resources/test_order.py +++ /dev/null @@ -1,44 +0,0 @@ -from __future__ import absolute_import, division, print_function - -import stripe - -import pytest - - -pytestmark = pytest.mark.asyncio - -TEST_RESOURCE_ID = "or_123" - - -class TestOrder(object): - async def test_order_create(self, request_mock): - await stripe.Order.create( - description="description", - currency="usd", - line_items=[{"description": "my line item"}], - ) - request_mock.assert_requested("post", "/v1/orders") - - async def test_order_update(self, request_mock): - await stripe.Order.modify("order_xyz") - request_mock.assert_requested("post", "/v1/orders/order_xyz") - - async def test_order_list_line_items(self, request_mock): - await stripe.Order.list_line_items("order_xyz") - request_mock.assert_requested("get", "/v1/orders/order_xyz/line_items") - - async def test_order_cancel(self, request_mock): - await stripe.Order.cancel("order_xyz") - request_mock.assert_requested("post", "/v1/orders/order_xyz/cancel") - - async def test_order_reopen(self, request_mock): - await stripe.Order.reopen("order_xyz") - request_mock.assert_requested("post", "/v1/orders/order_xyz/reopen") - - async def test_order_submit(self, request_mock): - await stripe.Order.submit("order_xyz", expected_total=100) - request_mock.assert_requested("post", "/v1/orders/order_xyz/submit") - - async def test_order_update2(self, request_mock): - await stripe.Order.modify("order_xyz") - request_mock.assert_requested("post", "/v1/orders/order_xyz") diff --git a/tests/api_resources/test_sku.py b/tests/api_resources/test_sku.py deleted file mode 100644 index 71af373..0000000 --- a/tests/api_resources/test_sku.py +++ /dev/null @@ -1,61 +0,0 @@ -from __future__ import absolute_import, division, print_function - -import stripe - -import pytest - - -pytestmark = pytest.mark.asyncio - -TEST_RESOURCE_ID = "sku_123" - - -class TestSKU(object): - async def test_is_listable(self, request_mock): - resources = await stripe.SKU.list() - request_mock.assert_requested("get", "/v1/skus") - assert isinstance(resources.data, list) - assert isinstance(resources.data[0], stripe.SKU) - - async def test_is_retrievable(self, request_mock): - resource = await stripe.SKU.retrieve(TEST_RESOURCE_ID) - request_mock.assert_requested("get", "/v1/skus/%s" % TEST_RESOURCE_ID) - assert isinstance(resource, stripe.SKU) - - async def test_is_creatable(self, request_mock): - resource = await stripe.SKU.create( - currency="usd", - inventory=dict(type="finite", quantity=500), - price=100, - product="prod_123", - ) - request_mock.assert_requested("post", "/v1/skus") - assert isinstance(resource, stripe.SKU) - - async def test_is_saveable(self, request_mock): - resource = await stripe.SKU.retrieve(TEST_RESOURCE_ID) - resource.metadata["key"] = "value" - await resource.save() - request_mock.assert_requested("post", "/v1/skus/%s" % TEST_RESOURCE_ID) - - async def test_is_modifiable(self, request_mock): - resource = await stripe.SKU.modify( - TEST_RESOURCE_ID, metadata={"key": "value"} - ) - request_mock.assert_requested("post", "/v1/skus/%s" % TEST_RESOURCE_ID) - assert isinstance(resource, stripe.SKU) - - async def test_is_deletable(self, request_mock): - resource = await stripe.SKU.retrieve(TEST_RESOURCE_ID) - await resource.delete() - request_mock.assert_requested( - "delete", "/v1/skus/%s" % TEST_RESOURCE_ID - ) - assert resource.deleted is True - - async def test_can_delete(self, request_mock): - resource = await stripe.SKU.delete(TEST_RESOURCE_ID) - request_mock.assert_requested( - "delete", "/v1/skus/%s" % TEST_RESOURCE_ID - ) - assert resource.deleted is True diff --git a/tests/test_generated_examples.py b/tests/test_generated_examples.py index a7daa62..cd3c80e 100644 --- a/tests/test_generated_examples.py +++ b/tests/test_generated_examples.py @@ -1777,32 +1777,6 @@ async def test_sigma_scheduledqueryrun_retrieve(self, request_mock): "/v1/sigma/scheduled_query_runs/sqr_xxxxxxxxxxxxx", ) - async def test_sku_list(self, request_mock): - await stripe.SKU.list(limit=3) - request_mock.assert_requested("get", "/v1/skus") - - async def test_sku_create(self, request_mock): - await stripe.SKU.create( - attributes={"size": "Medium", "gender": "Unisex"}, - price=1500, - currency="usd", - inventory={"type": "finite", "quantity": 500}, - product="prod_xxxxxxxxxxxxx", - ) - request_mock.assert_requested("post", "/v1/skus") - - async def test_sku_delete(self, request_mock): - await stripe.SKU.delete("sku_xxxxxxxxxxxxx") - request_mock.assert_requested("delete", "/v1/skus/sku_xxxxxxxxxxxxx") - - async def test_sku_retrieve(self, request_mock): - await stripe.SKU.retrieve("sku_xxxxxxxxxxxxx") - request_mock.assert_requested("get", "/v1/skus/sku_xxxxxxxxxxxxx") - - async def test_sku_update(self, request_mock): - await stripe.SKU.modify("sku_xxxxxxxxxxxxx", metadata={"order_id": "6735"}) - request_mock.assert_requested("post", "/v1/skus/sku_xxxxxxxxxxxxx") - async def test_source_retrieve(self, request_mock): await stripe.Source.retrieve("src_xxxxxxxxxxxxx") request_mock.assert_requested("get", "/v1/sources/src_xxxxxxxxxxxxx")