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/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 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")