From e3d5feb68e65e9312fc305e73cadd6cb973904f5 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Mon, 18 Apr 2022 11:17:16 -0700 Subject: [PATCH 1/2] Codegen for openapi a8928d0 --- lib/stripe/object_types.rb | 1 - lib/stripe/resources.rb | 1 - lib/stripe/resources/customer.rb | 12 +++++-- test/stripe/generated_examples_test.rb | 47 ++++++++++++-------------- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/lib/stripe/object_types.rb b/lib/stripe/object_types.rb index e8f2795a0..093381bc2 100644 --- a/lib/stripe/object_types.rb +++ b/lib/stripe/object_types.rb @@ -43,7 +43,6 @@ def self.object_names_to_classes File::OBJECT_NAME => File, File::OBJECT_NAME_ALT => File, FileLink::OBJECT_NAME => FileLink, - FundingInstructions::OBJECT_NAME => FundingInstructions, Identity::VerificationReport::OBJECT_NAME => Identity::VerificationReport, Identity::VerificationSession::OBJECT_NAME => Identity::VerificationSession, Invoice::OBJECT_NAME => Invoice, diff --git a/lib/stripe/resources.rb b/lib/stripe/resources.rb index 51e260aea..8027940f0 100644 --- a/lib/stripe/resources.rb +++ b/lib/stripe/resources.rb @@ -31,7 +31,6 @@ require "stripe/resources/exchange_rate" require "stripe/resources/file" require "stripe/resources/file_link" -require "stripe/resources/funding_instructions" require "stripe/resources/identity/verification_report" require "stripe/resources/identity/verification_session" require "stripe/resources/invoice" diff --git a/lib/stripe/resources/customer.rb b/lib/stripe/resources/customer.rb index fd52660b7..f273abcdd 100644 --- a/lib/stripe/resources/customer.rb +++ b/lib/stripe/resources/customer.rb @@ -12,15 +12,23 @@ class Customer < APIResource OBJECT_NAME = "customer" + custom_method :create_funding_instructions, http_verb: :post, http_path: "funding_instructions" custom_method :list_payment_methods, http_verb: :get, http_path: "payment_methods" nested_resource_class_methods :balance_transaction, operations: %i[create retrieve update list] - nested_resource_class_methods :funding_instruction, - operations: %i[create list] nested_resource_class_methods :tax_id, operations: %i[create retrieve delete list] + def create_funding_instructions(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: resource_url + "/funding_instructions", + params: params, + opts: opts + ) + end + def list_payment_methods(params = {}, opts = {}) request_stripe_object( method: :get, diff --git a/test/stripe/generated_examples_test.rb b/test/stripe/generated_examples_test.rb index d70f236b9..6e0c41c18 100644 --- a/test/stripe/generated_examples_test.rb +++ b/test/stripe/generated_examples_test.rb @@ -314,9 +314,12 @@ class CodegennedExampleTest < Test::Unit::TestCase ) assert_requested :post, "#{Stripe.api_base}/v1/billing_portal/configurations/bpc_xxxxxxxxxxxxx" end - should "support requests with args: configuration" do - Stripe::Terminal::Configuration.update("uc_123") - assert_requested :post, "#{Stripe.api_base}/v1/terminal/configurations/uc_123?" + should "support requests with args: configuration, tipping" do + Stripe::Terminal::Configuration.update( + "uc_123", + { tipping: { usd: { fixed_amounts: [10] } } } + ) + assert_requested :post, "#{Stripe.api_base}/v1/terminal/configurations/uc_123" end end context "ConnectionToken.create" do @@ -424,6 +427,22 @@ class CodegennedExampleTest < Test::Unit::TestCase assert_requested :post, "#{Stripe.api_base}/v1/customers" end end + context "Customer.create_funding_instructions" do + should "support requests with args: customer, bank_transfer, currency, funding_type" do + Stripe::Customer.create_funding_instructions( + "cus_123", + { + bank_transfer: { + requested_address_types: ["zengin"], + type: "jp_bank_transfer", + }, + currency: "usd", + funding_type: "bank_transfer", + } + ) + assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_123/funding_instructions" + end + end context "Customer.delete" do should "support requests with args: id" do Stripe::Customer.delete("cus_xxxxxxxxxxxxx") @@ -647,28 +666,6 @@ class CodegennedExampleTest < Test::Unit::TestCase assert_requested :post, "#{Stripe.api_base}/v1/file_links/link_xxxxxxxxxxxxx" end end - context "FundingInstructions.create" do - should "support requests with args: customer, bank_transfer, currency, funding_type" do - Stripe::Customer.create_funding_instruction( - "cus_123", - { - bank_transfer: { - requested_address_types: ["zengin"], - type: "jp_bank_transfer", - }, - currency: "usd", - funding_type: "bank_transfer", - } - ) - assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_123/funding_instructions" - end - end - context "FundingInstructions.list" do - should "support requests with args: customer" do - Stripe::Customer.list_funding_instructions("cus_123") - assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_123/funding_instructions?" - end - end context "Invoice.create" do should "support requests with args: customer" do Stripe::Invoice.create(customer: "cus_xxxxxxxxxxxxx") From 29241bb2d25907170e8e2a258ca3f29f4954d717 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Mon, 18 Apr 2022 13:13:28 -0700 Subject: [PATCH 2/2] Correct funding instructions --- lib/stripe/object_types.rb | 1 + lib/stripe/resources.rb | 1 + lib/stripe/resources/funding_instructions.rb | 6 +----- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/stripe/object_types.rb b/lib/stripe/object_types.rb index 093381bc2..e8f2795a0 100644 --- a/lib/stripe/object_types.rb +++ b/lib/stripe/object_types.rb @@ -43,6 +43,7 @@ def self.object_names_to_classes File::OBJECT_NAME => File, File::OBJECT_NAME_ALT => File, FileLink::OBJECT_NAME => FileLink, + FundingInstructions::OBJECT_NAME => FundingInstructions, Identity::VerificationReport::OBJECT_NAME => Identity::VerificationReport, Identity::VerificationSession::OBJECT_NAME => Identity::VerificationSession, Invoice::OBJECT_NAME => Invoice, diff --git a/lib/stripe/resources.rb b/lib/stripe/resources.rb index 8027940f0..51e260aea 100644 --- a/lib/stripe/resources.rb +++ b/lib/stripe/resources.rb @@ -31,6 +31,7 @@ require "stripe/resources/exchange_rate" require "stripe/resources/file" require "stripe/resources/file_link" +require "stripe/resources/funding_instructions" require "stripe/resources/identity/verification_report" require "stripe/resources/identity/verification_session" require "stripe/resources/invoice" diff --git a/lib/stripe/resources/funding_instructions.rb b/lib/stripe/resources/funding_instructions.rb index 50002e122..cb89f18d1 100644 --- a/lib/stripe/resources/funding_instructions.rb +++ b/lib/stripe/resources/funding_instructions.rb @@ -3,9 +3,6 @@ module Stripe class FundingInstructions < APIResource - extend Stripe::APIOperations::Create - extend Stripe::APIOperations::List - OBJECT_NAME = "funding_instructions" def resource_url @@ -13,8 +10,7 @@ def resource_url raise NotImplementedError, "FundingInstructions cannot be accessed without a customer ID." end - "#{Customer.resource_url}/#{CGI.escape(customer)}/funding_instructions" \ - "/#{CGI.escape(id)}" + "#{Customer.resource_url}/#{CGI.escape(customer)}/funding_instructions" "/#{CGI.escape(id)}" end end end