Skip to content

Commit

Permalink
Codegen for openapi v225
Browse files Browse the repository at this point in the history
  • Loading branch information
anniel-stripe committed Feb 16, 2023
1 parent 8be00fe commit 9325d1f
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 47 deletions.
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v223
v225
10 changes: 6 additions & 4 deletions lib/stripe/resources/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

module Stripe
# This is an object representing a Stripe account. You can retrieve it to see
# properties on the account like its current e-mail address or if the account is
# enabled yet to make live charges.
# properties on the account like its current requirements or if the account is
# enabled to make live charges or receive payouts.
#
# Some properties, marked below, are available only to platforms that want to
# [create and manage Express or Custom accounts](https://stripe.com/docs/connect/accounts).
# For Custom accounts, the properties below are always returned. For other accounts, some properties are returned until that
# account has started to go through Connect Onboarding. Once you create an [Account Link](https://stripe.com/docs/api/account_links)
# for a Standard or Express account, some parameters are no longer returned. These are marked as **Custom Only** or **Custom and Express**
# below. Learn about the differences [between accounts](https://stripe.com/docs/connect/accounts).
class Account < APIResource
extend Gem::Deprecate
extend Stripe::APIOperations::Create
Expand Down
4 changes: 2 additions & 2 deletions lib/stripe/resources/checkout/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module Checkout
# [PaymentIntent](https://stripe.com/docs/api/payment_intents) or an active
# [Subscription](https://stripe.com/docs/api/subscriptions).
#
# You can create a Checkout Session on your server and pass its ID to the
# client to begin Checkout.
# You can create a Checkout Session on your server and redirect to its URL
# to begin Checkout.
#
# Related guide: [Checkout Quickstart](https://stripe.com/docs/checkout/quickstart).
class Session < APIResource
Expand Down
16 changes: 10 additions & 6 deletions lib/stripe/resources/invoice_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
# frozen_string_literal: true

module Stripe
# Sometimes you want to add a charge or credit to a customer, but actually
# charge or credit the customer's card only at the end of a regular billing
# cycle. This is useful for combining several charges (to minimize
# per-transaction fees), or for having Stripe tabulate your usage-based billing
# totals.
# Invoice Items represent the component lines of an [invoice](https://stripe.com/docs/api/invoices). An invoice item is added to an
# invoice by creating or updating it with an `invoice` field, at which point it will be included as
# [an invoice line item](https://stripe.com/docs/api/invoices/line_item) within
# [invoice.lines](https://stripe.com/docs/api/invoices/object#invoice_object-lines).
#
# Related guide: [Subscription Invoices](https://stripe.com/docs/billing/invoices/subscription#adding-upcoming-invoice-items).
# Invoice Items can be created before you are ready to actually send the invoice. This can be particularly useful when combined
# with a [subscription](https://stripe.com/docs/api/subscriptions). Sometimes you want to add a charge or credit to a customer, but actually charge
# or credit the customer's card only at the end of a regular billing cycle. This is useful for combining several charges
# (to minimize per-transaction fees), or for having Stripe tabulate your usage-based billing totals.
#
# Related guides: [Integrate with the Invoicing API](https://stripe.com/docs/invoicing/integration), [Subscription Invoices](https://stripe.com/docs/billing/invoices/subscription#adding-upcoming-invoice-items).
class InvoiceItem < APIResource
extend Stripe::APIOperations::Create
include Stripe::APIOperations::Delete
Expand Down
18 changes: 18 additions & 0 deletions lib/stripe/resources/terminal/reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ def process_setup_intent(params = {}, opts = {})
)
end

def refund_payment(params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/terminal/readers/%<reader>s/refund_payment", { reader: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end

def set_reader_display(params = {}, opts = {})
request_stripe_object(
method: :post,
Expand Down Expand Up @@ -77,6 +86,15 @@ def self.process_setup_intent(reader, params = {}, opts = {})
)
end

def self.refund_payment(reader, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/terminal/readers/%<reader>s/refund_payment", { reader: CGI.escape(reader) }),
params: params,
opts: opts
)
end

def self.set_reader_display(reader, params = {}, opts = {})
request_stripe_object(
method: :post,
Expand Down
90 changes: 56 additions & 34 deletions test/stripe/generated_examples_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ class CodegennedExampleTest < Test::Unit::TestCase
Stripe::Apps::Secret.list({ scope: { type: "account" }, limit: 2 })
assert_requested :get, "#{Stripe.api_base}/v1/apps/secrets?scope[type]=account&limit=2"
end
should "support requests with args: scope, limit2" do
Stripe::Apps::Secret.list({ scope: { type: "account" }, limit: 2 })
assert_requested :get, "#{Stripe.api_base}/v1/apps/secrets?scope[type]=account&limit=2"
end
end
context "BalanceTransaction.list" do
should "support requests with args: limit" do
Expand Down Expand Up @@ -273,7 +277,7 @@ class CodegennedExampleTest < Test::Unit::TestCase
amount: 2000,
currency: "usd",
source: "tok_xxxx",
description: "My First Test Charge (created for API docs)",
description: "My First Test Charge (created for API docs at https://www.stripe.com/docs/api)",
}
)
assert_requested :post, "#{Stripe.api_base}/v1/charges"
Expand Down Expand Up @@ -331,11 +335,10 @@ class CodegennedExampleTest < Test::Unit::TestCase
)
assert_requested :post, "#{Stripe.api_base}/v1/checkout/sessions"
end
should "support requests with args: success_url, cancel_url, line_items, mode" do
should "support requests with args: success_url, line_items, mode" do
Stripe::Checkout::Session.create(
{
success_url: "https://example.com/success",
cancel_url: "https://example.com/cancel",
line_items: [{ price: "price_xxxxxxxxxxxxx", quantity: 2 }],
mode: "payment",
}
Expand Down Expand Up @@ -447,7 +450,9 @@ class CodegennedExampleTest < Test::Unit::TestCase
context "Customer.create" do
should "support requests with args: description" do
Stripe::Customer.create(
{ description: "My First Test Customer (created for API docs)" }
{
description: "My First Test Customer (created for API docs at https://www.stripe.com/docs/api)",
}
)
assert_requested :post, "#{Stripe.api_base}/v1/customers"
end
Expand Down Expand Up @@ -646,6 +651,10 @@ class CodegennedExampleTest < Test::Unit::TestCase
Stripe::FinancialConnections::Account.disconnect("fca_xyz")
assert_requested :post, "#{Stripe.api_base}/v1/financial_connections/accounts/fca_xyz/disconnect?"
end
should "support requests with args: id" do
Stripe::FinancialConnections::Account.disconnect("fca_xxxxxxxxxxxxx")
assert_requested :post, "#{Stripe.api_base}/v1/financial_connections/accounts/fca_xxxxxxxxxxxxx/disconnect?"
end
end
context "FinancialConnections.Account.list" do
should "work" do
Expand Down Expand Up @@ -1114,9 +1123,13 @@ class CodegennedExampleTest < Test::Unit::TestCase
)
assert_requested :post, "#{Stripe.api_base}/v1/payment_intents"
end
should "support requests with args: amount, currency, payment_method_types" do
should "support requests with args: amount, currency, automatic_payment_methods2" do
Stripe::PaymentIntent.create(
{ amount: 2000, currency: "usd", payment_method_types: ["card"] }
{
amount: 2000,
currency: "usd",
automatic_payment_methods: { enabled: true },
}
)
assert_requested :post, "#{Stripe.api_base}/v1/payment_intents"
end
Expand Down Expand Up @@ -1164,6 +1177,13 @@ class CodegennedExampleTest < Test::Unit::TestCase
Stripe::PaymentIntent.verify_microdeposits("pi_xxxxxxxxxxxxx")
assert_requested :post, "#{Stripe.api_base}/v1/payment_intents/pi_xxxxxxxxxxxxx/verify_microdeposits?"
end
should "support requests with args: amounts, id" do
Stripe::PaymentIntent.verify_microdeposits(
"pi_xxxxxxxxxxxxx",
{ amounts: [32, 45] }
)
assert_requested :post, "#{Stripe.api_base}/v1/payment_intents/pi_xxxxxxxxxxxxx/verify_microdeposits"
end
end
context "PaymentLink.create" do
should "support requests with args: line_items" do
Expand Down Expand Up @@ -1223,8 +1243,8 @@ class CodegennedExampleTest < Test::Unit::TestCase
type: "card",
card: {
number: "4242424242424242",
exp_month: 5,
exp_year: 2023,
exp_month: 8,
exp_year: 2024,
cvc: "314",
},
}
Expand Down Expand Up @@ -1780,6 +1800,13 @@ class CodegennedExampleTest < Test::Unit::TestCase
Stripe::SetupIntent.verify_microdeposits("seti_xxxxxxxxxxxxx")
assert_requested :post, "#{Stripe.api_base}/v1/setup_intents/seti_xxxxxxxxxxxxx/verify_microdeposits?"
end
should "support requests with args: amounts, id" do
Stripe::SetupIntent.verify_microdeposits(
"seti_xxxxxxxxxxxxx",
{ amounts: [32, 45] }
)
assert_requested :post, "#{Stripe.api_base}/v1/setup_intents/seti_xxxxxxxxxxxxx/verify_microdeposits"
end
end
context "ShippingRate.create" do
should "support requests with args: display_name, fixed_amount, type" do
Expand Down Expand Up @@ -1876,15 +1903,6 @@ class CodegennedExampleTest < Test::Unit::TestCase
assert_requested :get, "#{Stripe.api_base}/v1/subscriptions?limit=3"
end
end
context "Subscription.resume" do
should "support requests with args: id, proration_date, proration_behavior" do
Stripe::Subscription.resume(
"sub_xxxxxxxxxxxxx",
{ proration_date: 1_675_400_000, proration_behavior: "always_invoice" }
)
assert_requested :post, "#{Stripe.api_base}/v1/subscriptions/sub_xxxxxxxxxxxxx/resume"
end
end
context "Subscription.retrieve" do
should "support requests with args: id" do
Stripe::Subscription.retrieve("sub_xxxxxxxxxxxxx")
Expand Down Expand Up @@ -1958,7 +1976,7 @@ class CodegennedExampleTest < Test::Unit::TestCase
Stripe::SubscriptionSchedule.create(
{
customer: "cus_xxxxxxxxxxxxx",
start_date: 1_652_909_005,
start_date: 1_676_070_661,
end_behavior: "release",
phases: [
{
Expand Down Expand Up @@ -2135,8 +2153,9 @@ class CodegennedExampleTest < Test::Unit::TestCase
address: {
line1: "1234 Main Street",
city: "San Francisco",
country: "US",
postal_code: "94111",
state: "CA",
country: "US",
},
}
)
Expand Down Expand Up @@ -2209,6 +2228,18 @@ class CodegennedExampleTest < Test::Unit::TestCase
assert_requested :post, "#{Stripe.api_base}/v1/terminal/readers/tmr_xxxxxxxxxxxxx/process_payment_intent"
end
end
context "Terminal.Reader.process_setup_intent" do
should "support requests with args: setup_intent, customer_consent_collected, id" do
Stripe::Terminal::Reader.process_setup_intent(
"tmr_xxxxxxxxxxxxx",
{
setup_intent: "seti_xxxxxxxxxxxxx",
customer_consent_collected: true,
}
)
assert_requested :post, "#{Stripe.api_base}/v1/terminal/readers/tmr_xxxxxxxxxxxxx/process_setup_intent"
end
end
context "Terminal.Reader.retrieve" do
should "support requests with args: id" do
Stripe::Terminal::Reader.retrieve("tmr_xxxxxxxxxxxxx")
Expand All @@ -2232,7 +2263,7 @@ class CodegennedExampleTest < Test::Unit::TestCase
should "support requests with args: frozen_time, id" do
Stripe::TestHelpers::TestClock.advance(
"clock_xxxxxxxxxxxxx",
{ frozen_time: 1_652_390_605 }
{ frozen_time: 1_675_552_261 }
)
assert_requested :post, "#{Stripe.api_base}/v1/test_helpers/test_clocks/clock_xxxxxxxxxxxxx/advance"
end
Expand Down Expand Up @@ -2496,15 +2527,6 @@ class CodegennedExampleTest < Test::Unit::TestCase
assert_requested :post, "#{Stripe.api_base}/v1/treasury/financial_accounts/fa_xxxxxxxxxxxxx"
end
end
context "Treasury.FinancialAccount.update_features" do
should "support requests with args: card_issuing, parent_id" do
Stripe::Treasury::FinancialAccount.update_features(
"fa_xxxxxxxxxxxxx",
{ card_issuing: { requested: false } }
)
assert_requested :post, "#{Stripe.api_base}/v1/treasury/financial_accounts/fa_xxxxxxxxxxxxx/features"
end
end
context "Treasury.InboundTransfer.cancel" do
should "support requests with args: id" do
Stripe::Treasury::InboundTransfer.cancel("ibt_xxxxxxxxxxxxx")
Expand Down Expand Up @@ -2564,8 +2586,8 @@ class CodegennedExampleTest < Test::Unit::TestCase
end
context "Treasury.OutboundPayment.cancel" do
should "support requests with args: id" do
Stripe::Treasury::OutboundPayment.cancel("obp_xxxxxxxxxxxxx")
assert_requested :post, "#{Stripe.api_base}/v1/treasury/outbound_payments/obp_xxxxxxxxxxxxx/cancel?"
Stripe::Treasury::OutboundPayment.cancel("bot_xxxxxxxxxxxxx")
assert_requested :post, "#{Stripe.api_base}/v1/treasury/outbound_payments/bot_xxxxxxxxxxxxx/cancel?"
end
end
context "Treasury.OutboundPayment.create" do
Expand All @@ -2575,7 +2597,7 @@ class CodegennedExampleTest < Test::Unit::TestCase
financial_account: "fa_xxxxxxxxxxxxx",
amount: 10_000,
currency: "usd",
customer: "cu_xxxxxxxxxxxxx",
customer: "cus_xxxxxxxxxxxxx",
destination_payment_method: "pm_xxxxxxxxxxxxx",
description: "OutboundPayment to a 3rd party",
}
Expand All @@ -2593,8 +2615,8 @@ class CodegennedExampleTest < Test::Unit::TestCase
end
context "Treasury.OutboundPayment.retrieve" do
should "support requests with args: id" do
Stripe::Treasury::OutboundPayment.retrieve("obp_xxxxxxxxxxxxx")
assert_requested :get, "#{Stripe.api_base}/v1/treasury/outbound_payments/obp_xxxxxxxxxxxxx?"
Stripe::Treasury::OutboundPayment.retrieve("bot_xxxxxxxxxxxxx")
assert_requested :get, "#{Stripe.api_base}/v1/treasury/outbound_payments/bot_xxxxxxxxxxxxx?"
end
end
context "Treasury.OutboundTransfer.cancel" do
Expand Down

0 comments on commit 9325d1f

Please sign in to comment.