From 97f0ea15f5d64031e7d20010b49175734b40ab39 Mon Sep 17 00:00:00 2001 From: Yejia Chen Date: Mon, 15 Nov 2021 17:37:24 -0500 Subject: [PATCH 1/3] Codegen for openapi b428029 --- stripe/api_resources/__init__.py | 1 + stripe/api_resources/shipping_rate.py | 14 ++++++++++++++ stripe/object_classes.py | 1 + tests/test_generated_examples.py | 7 ------- 4 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 stripe/api_resources/shipping_rate.py diff --git a/stripe/api_resources/__init__.py b/stripe/api_resources/__init__.py index 233134df1..451867400 100644 --- a/stripe/api_resources/__init__.py +++ b/stripe/api_resources/__init__.py @@ -69,6 +69,7 @@ from stripe.api_resources.review import Review from stripe.api_resources.setup_attempt import SetupAttempt from stripe.api_resources.setup_intent import SetupIntent +from stripe.api_resources.shipping_rate import ShippingRate from stripe.api_resources.sku import SKU from stripe.api_resources.source import Source from stripe.api_resources.source_transaction import SourceTransaction diff --git a/stripe/api_resources/shipping_rate.py b/stripe/api_resources/shipping_rate.py new file mode 100644 index 000000000..eb701c7e3 --- /dev/null +++ b/stripe/api_resources/shipping_rate.py @@ -0,0 +1,14 @@ +# 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.api_resources.abstract import UpdateableAPIResource + + +class ShippingRate( + CreateableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +): + OBJECT_NAME = "shipping_rate" diff --git a/stripe/object_classes.py b/stripe/object_classes.py index 5812158dc..517556c21 100644 --- a/stripe/object_classes.py +++ b/stripe/object_classes.py @@ -76,6 +76,7 @@ api_resources.Review.OBJECT_NAME: api_resources.Review, api_resources.SetupAttempt.OBJECT_NAME: api_resources.SetupAttempt, api_resources.SetupIntent.OBJECT_NAME: api_resources.SetupIntent, + api_resources.ShippingRate.OBJECT_NAME: api_resources.ShippingRate, api_resources.sigma.ScheduledQueryRun.OBJECT_NAME: api_resources.sigma.ScheduledQueryRun, api_resources.SKU.OBJECT_NAME: api_resources.SKU, api_resources.Source.OBJECT_NAME: api_resources.Source, diff --git a/tests/test_generated_examples.py b/tests/test_generated_examples.py index 2e0c99923..2422fdbaa 100644 --- a/tests/test_generated_examples.py +++ b/tests/test_generated_examples.py @@ -1562,10 +1562,3 @@ def test_customer_list_payment_methods(self, request_mock): "get", "/v1/customers/cus_xyz/payment_methods", ) - - def test_checkout_session_expire(self, request_mock): - stripe.checkout.Session.expire("sess_xyz") - request_mock.assert_requested( - "post", - "/v1/checkout/sessions/sess_xyz/expire", - ) From 62e8acafcfdf66feb23fd049a9616b73e1e05080 Mon Sep 17 00:00:00 2001 From: Yejia Chen Date: Mon, 15 Nov 2021 17:40:44 -0500 Subject: [PATCH 2/3] Revert test deletion --- tests/test_generated_examples.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_generated_examples.py b/tests/test_generated_examples.py index 2422fdbaa..2e0c99923 100644 --- a/tests/test_generated_examples.py +++ b/tests/test_generated_examples.py @@ -1562,3 +1562,10 @@ def test_customer_list_payment_methods(self, request_mock): "get", "/v1/customers/cus_xyz/payment_methods", ) + + def test_checkout_session_expire(self, request_mock): + stripe.checkout.Session.expire("sess_xyz") + request_mock.assert_requested( + "post", + "/v1/checkout/sessions/sess_xyz/expire", + ) From 3357d325beee56f027246165a70e28551aafa1d3 Mon Sep 17 00:00:00 2001 From: Dominic Charley-Roy Date: Mon, 15 Nov 2021 23:54:26 -0500 Subject: [PATCH 3/3] Add generated tests. --- tests/test_generated_examples.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/test_generated_examples.py b/tests/test_generated_examples.py index 2e0c99923..fa7804770 100644 --- a/tests/test_generated_examples.py +++ b/tests/test_generated_examples.py @@ -1569,3 +1569,35 @@ def test_checkout_session_expire(self, request_mock): "post", "/v1/checkout/sessions/sess_xyz/expire", ) + + def test_shippingrate_create(self, request_mock): + stripe.ShippingRate.create( + display_name="Sample Shipper", + fixed_amount={"currency": "usd", "amount": 400}, + type="fixed_amount", + ) + request_mock.assert_requested("post", "/v1/shipping_rates") + + def test_shippingrate_list(self, request_mock): + stripe.ShippingRate.list() + request_mock.assert_requested("get", "/v1/shipping_rates") + + def test_checkout_session_create2(self, request_mock): + stripe.checkout.Session.create( + success_url="https://example.com/success", + cancel_url="https://example.com/cancel", + mode="payment", + shipping_options=[ + {"shipping_rate": "shr_standard"}, + { + "shipping_rate_data": { + "display_name": "Standard", + "delivery_estimate": { + "minimum": {"unit": "day", "value": 5}, + "maximum": {"unit": "day", "value": 7}, + }, + }, + }, + ], + ) + request_mock.assert_requested("post", "/v1/checkout/sessions")