Skip to content

Commit

Permalink
API Updates
Browse files Browse the repository at this point in the history
bhch committed Nov 21, 2022
1 parent f73f528 commit e179bf9
Showing 23 changed files with 53 additions and 149 deletions.
1 change: 1 addition & 0 deletions async_stripe/api_resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from async_stripe.api_resources.abstract import *

from async_stripe.api_resources import list_object
Original file line number Diff line number Diff line change
@@ -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:
1 change: 1 addition & 0 deletions async_stripe/api_resources/account.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import stripe
from stripe import oauth, six
from stripe import util
1 change: 1 addition & 0 deletions async_stripe/api_resources/application_fee.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import stripe
from stripe import util
from stripe.api_resources.abstract import ListableAPIResource
1 change: 1 addition & 0 deletions async_stripe/api_resources/application_fee_refund.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import stripe


13 changes: 9 additions & 4 deletions async_stripe/api_resources/bank_account.py
Original file line number Diff line number Diff line change
@@ -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)."
)


1 change: 1 addition & 0 deletions async_stripe/api_resources/capability.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import stripe


17 changes: 11 additions & 6 deletions async_stripe/api_resources/card.py
Original file line number Diff line number Diff line change
@@ -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)."
)


1 change: 1 addition & 0 deletions async_stripe/api_resources/charge.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import stripe
from stripe import util

1 change: 1 addition & 0 deletions async_stripe/api_resources/customer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import stripe
from async_stripe.api_resources.abstract import patch_nested_resources
from stripe import util
1 change: 1 addition & 0 deletions async_stripe/api_resources/ephermal_key.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import stripe
from stripe import api_requestor
from stripe import util
1 change: 1 addition & 0 deletions async_stripe/api_resources/file.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function

import stripe
1 change: 1 addition & 0 deletions async_stripe/api_resources/list_object.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import stripe
from stripe import six, util
from stripe.stripe_object import StripeObject
11 changes: 7 additions & 4 deletions async_stripe/api_resources/person.py
Original file line number Diff line number Diff line change
@@ -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)."
)


1 change: 1 addition & 0 deletions async_stripe/api_resources/quote.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import stripe
from stripe import util
from stripe import api_requestor
11 changes: 7 additions & 4 deletions async_stripe/api_resources/reversal.py
Original file line number Diff line number Diff line change
@@ -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)."
)


1 change: 1 addition & 0 deletions async_stripe/api_resources/search_result_object.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import stripe


1 change: 1 addition & 0 deletions async_stripe/api_resources/source.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import stripe
from stripe import error
from stripe import util
1 change: 1 addition & 0 deletions async_stripe/api_resources/transfer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import stripe
from stripe import util
from async_stripe.api_resources.abstract import patch_nested_resources
1 change: 1 addition & 0 deletions async_stripe/api_resources/usage_record.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import stripe
from stripe import api_requestor, util

44 changes: 0 additions & 44 deletions tests/api_resources/test_order.py

This file was deleted.

61 changes: 0 additions & 61 deletions tests/api_resources/test_sku.py

This file was deleted.

26 changes: 0 additions & 26 deletions tests/test_generated_examples.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit e179bf9

Please sign in to comment.