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

Update generated code #1247

Merged
merged 3 commits into from
Jul 20, 2023
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
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v413
v425
52 changes: 17 additions & 35 deletions lib/stripe/resources/quote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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/%<quote>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,
Expand Down Expand Up @@ -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/%<quote>s/pdf", { quote: CGI.escape(quote) }),
params,
{
api_base: config.uploads_base,
}.merge(opts),
opts,
&read_body_chunk_block
)
resp
end
end
end
5 changes: 2 additions & 3 deletions lib/stripe/resources/shipping_rate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
130 changes: 107 additions & 23 deletions test/stripe/generated_examples_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" })
Expand Down Expand Up @@ -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 })
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down