Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Updates #794

Merged
merged 3 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions stripe/api_resources/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@


@custom_method("delete_discount", http_verb="delete", http_path="discount")
@custom_method(
"create_funding_instructions",
http_verb="post",
http_path="funding_instructions",
)
@custom_method(
"list_payment_methods",
http_verb="get",
Expand All @@ -22,10 +27,6 @@
"balance_transaction",
operations=["create", "retrieve", "update", "list"],
)
@nested_resource_class_methods(
"funding_instruction",
operations=["create", "list"],
)
@nested_resource_class_methods(
"source",
operations=["create", "retrieve", "update", "delete", "list"],
Expand All @@ -43,6 +44,13 @@ class Customer(
):
OBJECT_NAME = "customer"

def create_funding_instructions(self, idempotency_key=None, **params):
url = self.instance_url() + "/funding_instructions"
headers = util.populate_headers(idempotency_key)
resp = self.request("post", url, params, headers)
stripe_object = util.convert_to_stripe_object(resp)
return stripe_object

def list_payment_methods(self, idempotency_key=None, **params):
url = self.instance_url() + "/payment_methods"
headers = util.populate_headers(idempotency_key)
Expand Down
17 changes: 2 additions & 15 deletions stripe/api_resources/funding_instructions.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
# File generated from our OpenAPI spec
from __future__ import absolute_import, division, print_function

from stripe.api_resources.abstract import CreateableAPIResource
from stripe.api_resources.abstract import ListableAPIResource
from stripe.stripe_object import StripeObject


class FundingInstructions(CreateableAPIResource, ListableAPIResource):
class FundingInstructions(StripeObject):
OBJECT_NAME = "funding_instructions"

@classmethod
def create(cls, id, api_key=None, **params):
raise NotImplementedError(
"Can't create a funding instruction without a customer ID. Use customer.create_funding_instruction(...)"
)

@classmethod
def list(cls, id, api_key=None, **params):
raise NotImplementedError(
"Can't list funding instructions without a customer ID. Use customer.create_funding_instruction(...)"
)
7 changes: 3 additions & 4 deletions stripe/api_resources/terminal/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class TestHelpers(APIResourceTestHelpers):
def present_payment_method(self, idempotency_key=None, **params):
url = self.instance_url() + "/present_payment_method"
headers = util.populate_headers(idempotency_key)
self.resource.refresh_from(
self.resource.request("post", url, params, headers)
)
return self.resource
resp = self.resource.request("post", url, params, headers)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a breaking change, we are not refreshing the original resource anymore..

stripe_object = util.convert_to_stripe_object(resp)
return stripe_object
16 changes: 6 additions & 10 deletions tests/test_generated_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -1666,8 +1666,8 @@ def test_test_helpers_testclock_advance(self, request_mock):
"/v1/test_helpers/test_clocks/clock_xyz/advance",
)

def test_customer_fundinginstructions_create(self, request_mock):
stripe.Customer.create_funding_instruction(
def test_customer_create_funding_instructions(self, request_mock):
stripe.Customer.create_funding_instructions(
"cus_123",
bank_transfer={
"requested_address_types": ["zengin"],
Expand All @@ -1681,13 +1681,6 @@ def test_customer_fundinginstructions_create(self, request_mock):
"/v1/customers/cus_123/funding_instructions",
)

def test_customer_fundinginstructions_list(self, request_mock):
stripe.Customer.list_funding_instructions("cus_123")
request_mock.assert_requested(
"get",
"/v1/customers/cus_123/funding_instructions",
)

def test_terminal_configuration_list(self, request_mock):
stripe.terminal.Configuration.list()
request_mock.assert_requested("get", "/v1/terminal/configurations")
Expand All @@ -1703,7 +1696,10 @@ def test_terminal_configuration_create(self, request_mock):
request_mock.assert_requested("post", "/v1/terminal/configurations")

def test_terminal_configuration_update(self, request_mock):
stripe.terminal.Configuration.modify("uc_123")
stripe.terminal.Configuration.modify(
"uc_123",
tipping={"usd": {"fixed_amounts": [10]}},
)
request_mock.assert_requested(
"post", "/v1/terminal/configurations/uc_123"
)
Expand Down