From 33c94cadf5ed9b5e054455b42e927dcdf8669dc3 Mon Sep 17 00:00:00 2001 From: "stripe-openapi[bot]" <105521251+stripe-openapi[bot]@users.noreply.github.com> Date: Thu, 20 Jul 2023 08:27:27 -0700 Subject: [PATCH 1/2] Update generated code (#1247) * Update generated code for v423 * Update generated code for v424 * Update generated code for v425 --------- Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com> --- OPENAPI_VERSION | 2 +- lib/stripe/resources/quote.rb | 52 ++++------ lib/stripe/resources/shipping_rate.rb | 5 +- test/stripe/generated_examples_test.rb | 130 ++++++++++++++++++++----- 4 files changed, 127 insertions(+), 62 deletions(-) diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 0b391be30..ae2bb1461 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v413 \ No newline at end of file +v425 \ No newline at end of file diff --git a/lib/stripe/resources/quote.rb b/lib/stripe/resources/quote.rb index 001840987..93fd0b652 100644 --- a/lib/stripe/resources/quote.rb +++ b/lib/stripe/resources/quote.rb @@ -56,6 +56,18 @@ def list_line_items(params = {}, opts = {}) ) end + def pdf(params = {}, opts = {}, &read_body_chunk_block) + config = opts[:client]&.config || Stripe.config + opts = { api_base: config.uploads_base }.merge(opts) + request_stream( + method: :get, + path: format("/v1/quotes/%s/pdf", { quote: CGI.escape(self["id"]) }), + params: params, + opts: opts, + &read_body_chunk_block + ) + end + def self.accept(quote, params = {}, opts = {}) request_stripe_object( method: :post, @@ -101,46 +113,16 @@ def self.list_line_items(quote, params = {}, opts = {}) ) end - def pdf(params = {}, opts = {}, &read_body_chunk_block) - unless block_given? - raise ArgumentError, "A read_body_chunk_block block parameter is required when calling the pdf method." - end - + def self.pdf(quote, params = {}, opts = {}, &read_body_chunk_block) config = opts[:client]&.config || Stripe.config - - request_stream( - method: :get, - path: resource_url + "/pdf", - params: params, - opts: { - api_base: config.uploads_base, - }.merge(opts), - &read_body_chunk_block - ) - end - - def self.pdf(id, params = {}, opts = {}, &read_body_chunk_block) - unless id.is_a?(String) - raise ArgumentError, - "id should be a string representing the ID of an API resource" - end - - unless block_given? - raise ArgumentError, "A read_body_chunk_block block parameter is required when calling the pdf method." - end - - config = opts[:client]&.config || Stripe.config - - resp = execute_resource_request_stream( + opts = { api_base: config.uploads_base }.merge(opts) + execute_resource_request_stream( :get, - "#{resource_url}/#{CGI.escape(id)}/pdf", + format("/v1/quotes/%s/pdf", { quote: CGI.escape(quote) }), params, - { - api_base: config.uploads_base, - }.merge(opts), + opts, &read_body_chunk_block ) - resp end end end diff --git a/lib/stripe/resources/shipping_rate.rb b/lib/stripe/resources/shipping_rate.rb index 1d749f5cb..ed3c6d42a 100644 --- a/lib/stripe/resources/shipping_rate.rb +++ b/lib/stripe/resources/shipping_rate.rb @@ -2,9 +2,8 @@ # frozen_string_literal: true module Stripe - # Shipping rates describe the price of shipping presented to your customers and can be - # applied to [Checkout Sessions](https://stripe.com/docs/payments/checkout/shipping) - # and [Orders](https://stripe.com/docs/orders/shipping) to collect shipping costs. + # Shipping rates describe the price of shipping presented to your customers and + # applied to a purchase. For more information, see [Charge for shipping](https://stripe.com/docs/payments/during-payment/charge-shipping). class ShippingRate < APIResource extend Stripe::APIOperations::Create extend Stripe::APIOperations::List diff --git a/test/stripe/generated_examples_test.rb b/test/stripe/generated_examples_test.rb index f5bb8b820..451b03c66 100644 --- a/test/stripe/generated_examples_test.rb +++ b/test/stripe/generated_examples_test.rb @@ -30,6 +30,12 @@ class CodegennedExampleTest < Test::Unit::TestCase assert_requested :get, "#{Stripe.api_base}/v1/accounts?limit=3" end end + context "Account.persons" do + should "support requests with args: limit, parent_id" do + Stripe::Account.persons("acct_xxxxxxxxxxxxx", { limit: 3 }) + assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_xxxxxxxxxxxxx/persons?limit=3" + end + end context "Account.reject" do should "support requests with args: reason, id" do Stripe::Account.reject("acct_xxxxxxxxxxxxx", { reason: "fraud" }) @@ -605,6 +611,62 @@ class CodegennedExampleTest < Test::Unit::TestCase assert_requested :get, "#{Stripe.api_base}/v1/events/evt_xxxxxxxxxxxxx?" end end + context "ExternalAccount.create" do + should "support requests with args: external_account, parent_id" do + Stripe::Account.create_external_account( + "acct_xxxxxxxxxxxxx", + { external_account: "btok_xxxxxxxxxxxxx" } + ) + assert_requested :post, "#{Stripe.api_base}/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts" + end + should "support requests with args: external_account, parent_id2" do + Stripe::Account.create_external_account( + "acct_xxxxxxxxxxxxx", + { external_account: "tok_xxxx_debit" } + ) + assert_requested :post, "#{Stripe.api_base}/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts" + end + end + context "ExternalAccount.delete" do + should "support requests with args: parent_id, id" do + Stripe::Account.delete_external_account( + "acct_xxxxxxxxxxxxx", + "ba_xxxxxxxxxxxxx" + ) + assert_requested :delete, "#{Stripe.api_base}/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts/ba_xxxxxxxxxxxxx?" + end + should "support requests with args: parent_id, id2" do + Stripe::Account.delete_external_account( + "acct_xxxxxxxxxxxxx", + "card_xxxxxxxxxxxxx" + ) + assert_requested :delete, "#{Stripe.api_base}/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts/card_xxxxxxxxxxxxx?" + end + end + context "ExternalAccount.list" do + should "support requests with args: limit, parent_id" do + Stripe::Account.list_external_accounts("acct_xxxxxxxxxxxxx", { limit: 3 }) + assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts?limit=3" + end + end + context "ExternalAccount.update" do + should "support requests with args: metadata, parent_id, id" do + Stripe::Account.update_external_account( + "acct_xxxxxxxxxxxxx", + "ba_xxxxxxxxxxxxx", + { metadata: { order_id: "6735" } } + ) + assert_requested :post, "#{Stripe.api_base}/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts/ba_xxxxxxxxxxxxx" + end + should "support requests with args: metadata, parent_id, id2" do + Stripe::Account.update_external_account( + "acct_xxxxxxxxxxxxx", + "card_xxxxxxxxxxxxx", + { metadata: { order_id: "6735" } } + ) + assert_requested :post, "#{Stripe.api_base}/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts/card_xxxxxxxxxxxxx" + end + end context "File.list" do should "support requests with args: limit" do Stripe::File.list({ limit: 3 }) @@ -1306,30 +1368,58 @@ class CodegennedExampleTest < Test::Unit::TestCase assert_requested :post, "#{Stripe.api_base}/v1/payment_methods/pm_xxxxxxxxxxxxx" end end - context "PaymentSource.update" do - should "support requests with args: customer, card, account_holder_name" do - Stripe::Customer.update_source( - "cus_123", - "card_123", - { account_holder_name: "Kamil" } + context "PaymentSource.create" do + should "support requests with args: source, parent_id" do + Stripe::Customer.create_source( + "cus_xxxxxxxxxxxxx", + { source: "btok_xxxxxxxxxxxxx" } ) - assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_123/sources/card_123" + assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/sources" end - should "support requests with args: metadata, parent_id, id" do - Stripe::Customer.update_source( + should "support requests with args: source, parent_id2" do + Stripe::Customer.create_source( "cus_xxxxxxxxxxxxx", - "ba_xxxxxxxxxxxxx", - { metadata: { order_id: "6735" } } + { source: "tok_xxxx" } ) - assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/sources/ba_xxxxxxxxxxxxx" + assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/sources" end - should "support requests with args: name, parent_id, id" do - Stripe::Customer.update_source( + end + context "PaymentSource.list" do + should "support requests with args: object, limit, parent_id" do + Stripe::Customer.list_sources( "cus_xxxxxxxxxxxxx", - "card_xxxxxxxxxxxxx", - { name: "Jenny Rosen" } + { + object: "bank_account", + limit: 3, + } ) - assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/sources/card_xxxxxxxxxxxxx" + assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/sources?object=bank_account&limit=3" + end + should "support requests with args: object, limit, parent_id2" do + Stripe::Customer.list_sources( + "cus_xxxxxxxxxxxxx", + { + object: "card", + limit: 3, + } + ) + assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/sources?object=card&limit=3" + end + end + context "PaymentSource.retrieve" do + should "support requests with args: parent_id, id" do + Stripe::Customer.retrieve_source( + "cus_xxxxxxxxxxxxx", + "ba_xxxxxxxxxxxxx" + ) + assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/sources/ba_xxxxxxxxxxxxx?" + end + should "support requests with args: parent_id, id2" do + Stripe::Customer.retrieve_source( + "cus_xxxxxxxxxxxxx", + "card_xxxxxxxxxxxxx" + ) + assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/sources/card_xxxxxxxxxxxxx?" end end context "Payout.cancel" do @@ -1374,12 +1464,6 @@ class CodegennedExampleTest < Test::Unit::TestCase assert_requested :post, "#{Stripe.api_base}/v1/payouts/po_xxxxxxxxxxxxx" end end - context "Person.list" do - should "support requests with args: limit, parent_id" do - Stripe::Account.list_persons("acct_xxxxxxxxxxxxx", { limit: 3 }) - assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_xxxxxxxxxxxxx/persons?limit=3" - end - end context "Person.retrieve" do should "support requests with args: parent_id, id" do Stripe::Account.retrieve_person( From 62fb31d578974d4e3ce2805fadd0179bcecc2382 Mon Sep 17 00:00:00 2001 From: pakrym-stripe <99349468+pakrym-stripe@users.noreply.github.com> Date: Fri, 21 Jul 2023 09:47:49 -0700 Subject: [PATCH 2/2] Suppor testing methods that hit files endpoint (#1250) --- test/test_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index 5e6141f9e..a4fd2f162 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -65,6 +65,7 @@ class TestCase setup do Stripe.api_key = "sk_test_123" Stripe.api_base = "http://localhost:#{MOCK_PORT}" + Stripe.uploads_base = "http://localhost:#{MOCK_PORT}" stub_connect end