Skip to content

Commit

Permalink
Update generated code for beta (#1246)
Browse files Browse the repository at this point in the history
* Update generated code for v417

* 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>
Co-authored-by: pakrym-stripe <[email protected]>
  • Loading branch information
stripe-openapi[bot] and pakrym-stripe authored Jul 20, 2023
1 parent 900ecf2 commit 7e2a036
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 70 deletions.
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v417
v425
2 changes: 1 addition & 1 deletion lib/stripe/api_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
module Stripe
module ApiVersion
CURRENT = "2022-11-15"
PREVIEW = "20230712T200515"
PREVIEW = "2023-07-13.preview-v2"
end
end
66 changes: 24 additions & 42 deletions lib/stripe/resources/quote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ def mark_stale_quote(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 preview_invoice_lines(preview_invoice, params = {}, opts = {})
request_stripe_object(
method: :get,
Expand Down Expand Up @@ -191,6 +203,18 @@ def self.mark_stale_quote(quote, params = {}, opts = {})
)
end

def self.pdf(quote, params = {}, opts = {}, &read_body_chunk_block)
config = opts[:client]&.config || Stripe.config
opts = { api_base: config.uploads_base }.merge(opts)
execute_resource_request_stream(
:get,
format("/v1/quotes/%<quote>s/pdf", { quote: CGI.escape(quote) }),
params,
opts,
&read_body_chunk_block
)
end

def self.preview_invoice_lines(
quote,
preview_invoice,
Expand Down Expand Up @@ -231,47 +255,5 @@ def self.reestimate(quote, params = {}, opts = {})
opts: 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

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(
:get,
"#{resource_url}/#{CGI.escape(id)}/pdf",
params,
{
api_base: config.uploads_base,
}.merge(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

0 comments on commit 7e2a036

Please sign in to comment.