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

Codegen for openapi a8928d0 #1047

Merged
merged 2 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
12 changes: 10 additions & 2 deletions lib/stripe/resources/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 1 addition & 5 deletions lib/stripe/resources/funding_instructions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@

module Stripe
class FundingInstructions < APIResource
extend Stripe::APIOperations::Create
extend Stripe::APIOperations::List

OBJECT_NAME = "funding_instructions"

def resource_url
if !respond_to?(:customer) || customer.nil?
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
47 changes: 22 additions & 25 deletions test/stripe/generated_examples_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down