Merge upstream and update generated code for v1442

This commit is contained in:
Stripe OpenAPI 2025-01-14 08:46:18 +00:00
commit 7daac5c78b
11 changed files with 214 additions and 10 deletions

View File

@ -12,6 +12,14 @@
* Add method parameter classes for all resources and service methods.
* These changes are NOT breaking and are purely additive. The method parameter classes are not required, we still accept hashes as well as the new `RequestParams` classes. Any additional gated parameters are still available to pass via hash. Resource fields define publicly documented fields and other deserialized fields are still accessible.
## 13.3.1 - 2025-01-13
* [#1512](https://github.com/stripe/stripe-ruby/pull/1512) Import global configuration for options not available on StripeClient options
* Fixes bug where `StripeClient` was not falling back to global options for options that are not available to be set per-client
* [#1516](https://github.com/stripe/stripe-ruby/pull/1516) ThinEvent reason and livemode
- Add `livemode` and optional `reason` fields to ThinEvent
* [#1518](https://github.com/stripe/stripe-ruby/pull/1518) Pin ubuntu version in Test action
* [#1508](https://github.com/stripe/stripe-ruby/pull/1508) Added pull request template
## 13.3.0 - 2024-12-18
* [#1500](https://github.com/stripe/stripe-ruby/pull/1500) This release changes the pinned API version to `2024-12-18.acacia`.

View File

@ -1 +1 @@
v1441
v1442

View File

@ -77,6 +77,28 @@ module Stripe
DEFAULT_UPLOAD_BASE = "https://files.stripe.com"
DEFAULT_METER_EVENTS_BASE = "https://meter-events.stripe.com"
# Options that can be configured globally by users
USER_CONFIGURABLE_GLOBAL_OPTIONS = Set.new(%i[
api_key
api_version
stripe_account
api_base
uploads_base
connect_base
meter_events_base
open_timeout
read_timeout
write_timeout
proxy
verify_ssl_certs
ca_bundle_path
log_level
logger
max_network_retries
enable_telemetry
client_id
])
@app_info = nil
@config = Stripe::StripeConfiguration.setup

View File

@ -835,6 +835,20 @@ module Stripe
@features = features
end
end
class TaxThresholdMonitoring < Stripe::RequestParams
class Features < Stripe::RequestParams
end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
# Configuration for the account management embedded component.
attr_accessor :account_management
# Configuration for the account onboarding embedded component.
@ -883,6 +897,8 @@ module Stripe
attr_accessor :tax_registrations
# Configuration for the tax settings embedded component.
attr_accessor :tax_settings
# Configuration for the tax threshold monitoring embedded component.
attr_accessor :tax_threshold_monitoring
def initialize(
account_management: nil,
@ -908,7 +924,8 @@ module Stripe
recipients: nil,
reporting_chart: nil,
tax_registrations: nil,
tax_settings: nil
tax_settings: nil,
tax_threshold_monitoring: nil
)
@account_management = account_management
@account_onboarding = account_onboarding
@ -934,6 +951,7 @@ module Stripe
@reporting_chart = reporting_chart
@tax_registrations = tax_registrations
@tax_settings = tax_settings
@tax_threshold_monitoring = tax_threshold_monitoring
end
end
# The identifier of the account to create an Account Session for.

View File

@ -552,6 +552,20 @@ module Stripe
@features = features
end
end
class TaxThresholdMonitoring < Stripe::RequestParams
class Features < Stripe::RequestParams
end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
# Configuration for the account management embedded component.
attr_accessor :account_management
# Configuration for the account onboarding embedded component.
@ -600,6 +614,8 @@ module Stripe
attr_accessor :tax_registrations
# Configuration for the tax settings embedded component.
attr_accessor :tax_settings
# Configuration for the tax threshold monitoring embedded component.
attr_accessor :tax_threshold_monitoring
def initialize(
account_management: nil,
@ -625,7 +641,8 @@ module Stripe
recipients: nil,
reporting_chart: nil,
tax_registrations: nil,
tax_settings: nil
tax_settings: nil,
tax_threshold_monitoring: nil
)
@account_management = account_management
@account_onboarding = account_onboarding
@ -651,6 +668,7 @@ module Stripe
@reporting_chart = reporting_chart
@tax_registrations = tax_registrations
@tax_settings = tax_settings
@tax_threshold_monitoring = tax_threshold_monitoring
end
end
# The identifier of the account to create an Account Session for.

View File

@ -10,6 +10,10 @@ module Stripe
# attr_readers: The end of the section generated from our OpenAPI spec
# For internal use only. Does not provide a stable API and may be broken
# with future non-major changes.
CLIENT_OPTIONS = Set.new(%i[api_key stripe_account stripe_context api_version api_base uploads_base connect_base meter_events_base client_id])
# Initializes a new StripeClient
def initialize(api_key,
stripe_account: nil,
@ -40,7 +44,8 @@ module Stripe
client_id: client_id,
}.reject { |_k, v| v.nil? }
@requestor = APIRequestor.new(config_opts)
config = StripeConfiguration.client_init(config_opts)
@requestor = APIRequestor.new(config)
# top-level services: The beginning of the section generated from our OpenAPI spec
@v1 = Stripe::V1Services.new(@requestor)

View File

@ -38,6 +38,25 @@ module Stripe
end
end
# Set options to the StripeClient configured options, if valid as a client option and provided
# Otherwise, for user configurable global options, set them to the global configuration
# For all other options, set them to the StripeConfiguration default value
def self.client_init(config_opts)
global_config = Stripe.config
imported_options = USER_CONFIGURABLE_GLOBAL_OPTIONS - StripeClient::CLIENT_OPTIONS
client_config = StripeConfiguration.setup do |instance|
imported_options.each do |key|
begin
instance.public_send("#{key}=", global_config.public_send(key)) if global_config.respond_to?(key)
rescue NotImplementedError => e
# In Ruby <= 2.5, we can't set write_timeout on Net::HTTP, log an error and continue
Util.log_error("Failed to set #{key} on client configuration: #{e}")
end
end
end
client_config.reverse_duplicate_merge(config_opts)
end
# Create a new config based off an existing one. This is useful when the
# caller wants to override the global configuration
def reverse_duplicate_merge(hash)
@ -70,7 +89,8 @@ module Stripe
@connect_base = DEFAULT_CONNECT_BASE
@uploads_base = DEFAULT_UPLOAD_BASE
@meter_events_base = DEFAULT_METER_EVENTS_BASE
@base_addresses = { api: @api_base, connect: @connect_base, files: @uploads_base, events: @meter_events_base }
@base_addresses = { api: @api_base, connect: @connect_base, files: @uploads_base,
meter_events: @meter_events_base, }
end
def log_level=(val)

View File

@ -970,6 +970,23 @@ module Stripe
}
def initialize(enabled: nil, features: nil); end
end
class TaxThresholdMonitoring < Stripe::RequestParams
class Features < Stripe::RequestParams
end
# Whether the embedded component is enabled.
sig { returns(T::Boolean) }
attr_accessor :enabled
# The list of features enabled in the embedded component.
sig {
returns(::Stripe::AccountSession::CreateParams::Components::TaxThresholdMonitoring::Features)
}
attr_accessor :features
sig {
params(enabled: T::Boolean, features: ::Stripe::AccountSession::CreateParams::Components::TaxThresholdMonitoring::Features).void
}
def initialize(enabled: nil, features: nil); end
end
# Configuration for the account management embedded component.
sig { returns(::Stripe::AccountSession::CreateParams::Components::AccountManagement) }
attr_accessor :account_management
@ -1048,8 +1065,11 @@ module Stripe
# Configuration for the tax settings embedded component.
sig { returns(::Stripe::AccountSession::CreateParams::Components::TaxSettings) }
attr_accessor :tax_settings
# Configuration for the tax threshold monitoring embedded component.
sig { returns(::Stripe::AccountSession::CreateParams::Components::TaxThresholdMonitoring) }
attr_accessor :tax_threshold_monitoring
sig {
params(account_management: ::Stripe::AccountSession::CreateParams::Components::AccountManagement, account_onboarding: ::Stripe::AccountSession::CreateParams::Components::AccountOnboarding, app_install: ::Stripe::AccountSession::CreateParams::Components::AppInstall, app_viewport: ::Stripe::AccountSession::CreateParams::Components::AppViewport, balances: ::Stripe::AccountSession::CreateParams::Components::Balances, capital_financing: ::Stripe::AccountSession::CreateParams::Components::CapitalFinancing, capital_financing_application: ::Stripe::AccountSession::CreateParams::Components::CapitalFinancingApplication, capital_financing_promotion: ::Stripe::AccountSession::CreateParams::Components::CapitalFinancingPromotion, capital_overview: ::Stripe::AccountSession::CreateParams::Components::CapitalOverview, documents: ::Stripe::AccountSession::CreateParams::Components::Documents, financial_account: ::Stripe::AccountSession::CreateParams::Components::FinancialAccount, financial_account_transactions: ::Stripe::AccountSession::CreateParams::Components::FinancialAccountTransactions, issuing_card: ::Stripe::AccountSession::CreateParams::Components::IssuingCard, issuing_cards_list: ::Stripe::AccountSession::CreateParams::Components::IssuingCardsList, notification_banner: ::Stripe::AccountSession::CreateParams::Components::NotificationBanner, payment_details: ::Stripe::AccountSession::CreateParams::Components::PaymentDetails, payment_method_settings: ::Stripe::AccountSession::CreateParams::Components::PaymentMethodSettings, payments: ::Stripe::AccountSession::CreateParams::Components::Payments, payouts: ::Stripe::AccountSession::CreateParams::Components::Payouts, payouts_list: ::Stripe::AccountSession::CreateParams::Components::PayoutsList, recipients: ::Stripe::AccountSession::CreateParams::Components::Recipients, reporting_chart: ::Stripe::AccountSession::CreateParams::Components::ReportingChart, tax_registrations: ::Stripe::AccountSession::CreateParams::Components::TaxRegistrations, tax_settings: ::Stripe::AccountSession::CreateParams::Components::TaxSettings).void
params(account_management: ::Stripe::AccountSession::CreateParams::Components::AccountManagement, account_onboarding: ::Stripe::AccountSession::CreateParams::Components::AccountOnboarding, app_install: ::Stripe::AccountSession::CreateParams::Components::AppInstall, app_viewport: ::Stripe::AccountSession::CreateParams::Components::AppViewport, balances: ::Stripe::AccountSession::CreateParams::Components::Balances, capital_financing: ::Stripe::AccountSession::CreateParams::Components::CapitalFinancing, capital_financing_application: ::Stripe::AccountSession::CreateParams::Components::CapitalFinancingApplication, capital_financing_promotion: ::Stripe::AccountSession::CreateParams::Components::CapitalFinancingPromotion, capital_overview: ::Stripe::AccountSession::CreateParams::Components::CapitalOverview, documents: ::Stripe::AccountSession::CreateParams::Components::Documents, financial_account: ::Stripe::AccountSession::CreateParams::Components::FinancialAccount, financial_account_transactions: ::Stripe::AccountSession::CreateParams::Components::FinancialAccountTransactions, issuing_card: ::Stripe::AccountSession::CreateParams::Components::IssuingCard, issuing_cards_list: ::Stripe::AccountSession::CreateParams::Components::IssuingCardsList, notification_banner: ::Stripe::AccountSession::CreateParams::Components::NotificationBanner, payment_details: ::Stripe::AccountSession::CreateParams::Components::PaymentDetails, payment_method_settings: ::Stripe::AccountSession::CreateParams::Components::PaymentMethodSettings, payments: ::Stripe::AccountSession::CreateParams::Components::Payments, payouts: ::Stripe::AccountSession::CreateParams::Components::Payouts, payouts_list: ::Stripe::AccountSession::CreateParams::Components::PayoutsList, recipients: ::Stripe::AccountSession::CreateParams::Components::Recipients, reporting_chart: ::Stripe::AccountSession::CreateParams::Components::ReportingChart, tax_registrations: ::Stripe::AccountSession::CreateParams::Components::TaxRegistrations, tax_settings: ::Stripe::AccountSession::CreateParams::Components::TaxSettings, tax_threshold_monitoring: ::Stripe::AccountSession::CreateParams::Components::TaxThresholdMonitoring).void
}
def initialize(
account_management: nil,
@ -1075,7 +1095,8 @@ module Stripe
recipients: nil,
reporting_chart: nil,
tax_registrations: nil,
tax_settings: nil
tax_settings: nil,
tax_threshold_monitoring: nil
); end
end
# The identifier of the account to create an Account Session for.

View File

@ -618,6 +618,23 @@ module Stripe
}
def initialize(enabled: nil, features: nil); end
end
class TaxThresholdMonitoring < Stripe::RequestParams
class Features < Stripe::RequestParams
end
# Whether the embedded component is enabled.
sig { returns(T::Boolean) }
attr_accessor :enabled
# The list of features enabled in the embedded component.
sig {
returns(::Stripe::AccountSessionService::CreateParams::Components::TaxThresholdMonitoring::Features)
}
attr_accessor :features
sig {
params(enabled: T::Boolean, features: ::Stripe::AccountSessionService::CreateParams::Components::TaxThresholdMonitoring::Features).void
}
def initialize(enabled: nil, features: nil); end
end
# Configuration for the account management embedded component.
sig {
returns(::Stripe::AccountSessionService::CreateParams::Components::AccountManagement)
@ -704,8 +721,13 @@ module Stripe
# Configuration for the tax settings embedded component.
sig { returns(::Stripe::AccountSessionService::CreateParams::Components::TaxSettings) }
attr_accessor :tax_settings
# Configuration for the tax threshold monitoring embedded component.
sig {
params(account_management: ::Stripe::AccountSessionService::CreateParams::Components::AccountManagement, account_onboarding: ::Stripe::AccountSessionService::CreateParams::Components::AccountOnboarding, app_install: ::Stripe::AccountSessionService::CreateParams::Components::AppInstall, app_viewport: ::Stripe::AccountSessionService::CreateParams::Components::AppViewport, balances: ::Stripe::AccountSessionService::CreateParams::Components::Balances, capital_financing: ::Stripe::AccountSessionService::CreateParams::Components::CapitalFinancing, capital_financing_application: ::Stripe::AccountSessionService::CreateParams::Components::CapitalFinancingApplication, capital_financing_promotion: ::Stripe::AccountSessionService::CreateParams::Components::CapitalFinancingPromotion, capital_overview: ::Stripe::AccountSessionService::CreateParams::Components::CapitalOverview, documents: ::Stripe::AccountSessionService::CreateParams::Components::Documents, financial_account: ::Stripe::AccountSessionService::CreateParams::Components::FinancialAccount, financial_account_transactions: ::Stripe::AccountSessionService::CreateParams::Components::FinancialAccountTransactions, issuing_card: ::Stripe::AccountSessionService::CreateParams::Components::IssuingCard, issuing_cards_list: ::Stripe::AccountSessionService::CreateParams::Components::IssuingCardsList, notification_banner: ::Stripe::AccountSessionService::CreateParams::Components::NotificationBanner, payment_details: ::Stripe::AccountSessionService::CreateParams::Components::PaymentDetails, payment_method_settings: ::Stripe::AccountSessionService::CreateParams::Components::PaymentMethodSettings, payments: ::Stripe::AccountSessionService::CreateParams::Components::Payments, payouts: ::Stripe::AccountSessionService::CreateParams::Components::Payouts, payouts_list: ::Stripe::AccountSessionService::CreateParams::Components::PayoutsList, recipients: ::Stripe::AccountSessionService::CreateParams::Components::Recipients, reporting_chart: ::Stripe::AccountSessionService::CreateParams::Components::ReportingChart, tax_registrations: ::Stripe::AccountSessionService::CreateParams::Components::TaxRegistrations, tax_settings: ::Stripe::AccountSessionService::CreateParams::Components::TaxSettings).void
returns(::Stripe::AccountSessionService::CreateParams::Components::TaxThresholdMonitoring)
}
attr_accessor :tax_threshold_monitoring
sig {
params(account_management: ::Stripe::AccountSessionService::CreateParams::Components::AccountManagement, account_onboarding: ::Stripe::AccountSessionService::CreateParams::Components::AccountOnboarding, app_install: ::Stripe::AccountSessionService::CreateParams::Components::AppInstall, app_viewport: ::Stripe::AccountSessionService::CreateParams::Components::AppViewport, balances: ::Stripe::AccountSessionService::CreateParams::Components::Balances, capital_financing: ::Stripe::AccountSessionService::CreateParams::Components::CapitalFinancing, capital_financing_application: ::Stripe::AccountSessionService::CreateParams::Components::CapitalFinancingApplication, capital_financing_promotion: ::Stripe::AccountSessionService::CreateParams::Components::CapitalFinancingPromotion, capital_overview: ::Stripe::AccountSessionService::CreateParams::Components::CapitalOverview, documents: ::Stripe::AccountSessionService::CreateParams::Components::Documents, financial_account: ::Stripe::AccountSessionService::CreateParams::Components::FinancialAccount, financial_account_transactions: ::Stripe::AccountSessionService::CreateParams::Components::FinancialAccountTransactions, issuing_card: ::Stripe::AccountSessionService::CreateParams::Components::IssuingCard, issuing_cards_list: ::Stripe::AccountSessionService::CreateParams::Components::IssuingCardsList, notification_banner: ::Stripe::AccountSessionService::CreateParams::Components::NotificationBanner, payment_details: ::Stripe::AccountSessionService::CreateParams::Components::PaymentDetails, payment_method_settings: ::Stripe::AccountSessionService::CreateParams::Components::PaymentMethodSettings, payments: ::Stripe::AccountSessionService::CreateParams::Components::Payments, payouts: ::Stripe::AccountSessionService::CreateParams::Components::Payouts, payouts_list: ::Stripe::AccountSessionService::CreateParams::Components::PayoutsList, recipients: ::Stripe::AccountSessionService::CreateParams::Components::Recipients, reporting_chart: ::Stripe::AccountSessionService::CreateParams::Components::ReportingChart, tax_registrations: ::Stripe::AccountSessionService::CreateParams::Components::TaxRegistrations, tax_settings: ::Stripe::AccountSessionService::CreateParams::Components::TaxSettings, tax_threshold_monitoring: ::Stripe::AccountSessionService::CreateParams::Components::TaxThresholdMonitoring).void
}
def initialize(
account_management: nil,
@ -731,7 +753,8 @@ module Stripe
recipients: nil,
reporting_chart: nil,
tax_registrations: nil,
tax_settings: nil
tax_settings: nil,
tax_threshold_monitoring: nil
); end
end
# The identifier of the account to create an Account Session for.

View File

@ -20,6 +20,7 @@ module Stripe
@orig_api_key = Stripe.api_key
@orig_stripe_account = Stripe.stripe_account
@orig_open_timeout = Stripe.open_timeout
@orig_api_version = Stripe.api_version
Stripe.api_key = "DONT_USE_THIS_KEY"
Stripe.stripe_account = "DONT_USE_THIS_ACCOUNT"
@ -30,6 +31,7 @@ module Stripe
Stripe.api_key = @orig_api_key
Stripe.stripe_account = @orig_stripe_account
Stripe.open_timeout = @orig_open_timeout
Stripe.api_version = @orig_api_version
end
should "use default config options" do
@ -45,7 +47,6 @@ module Stripe
client = StripeClient.new("test_123")
assert_equal "test_123", client.instance_variable_get(:@requestor).config.api_key
assert_nil client.instance_variable_get(:@requestor).config.stripe_account
assert_equal 30, client.instance_variable_get(:@requestor).config.open_timeout
end
should "use client config options" do
@ -67,6 +68,30 @@ module Stripe
assert_equal "2022-11-15", req.headers["Stripe-Version"]
end
should "use global config options for options unavailable in client" do
Stripe.api_key = "NOT_THIS_KEY"
Stripe.stripe_account = "NOT_THIS_ACCOUNT"
Stripe.api_version = "2022-11-15"
client = StripeClient.new("test_123", stripe_account: "acct_123")
# Imported from global options
assert_equal 30_000, client.instance_variable_get(:@requestor).config.open_timeout
# Not set in client options, not imported from global
assert_equal client.instance_variable_get(:@requestor).config.api_base, Stripe::DEFAULT_API_BASE
assert_equal client.instance_variable_get(:@requestor).config.api_version, Stripe::ApiVersion::CURRENT
req = nil
stub_request(:get, "#{Stripe::DEFAULT_API_BASE}/v1/customers/cus_123")
.with { |request| req = request }
.to_return(body: JSON.generate(object: "customer"))
client.v1.customers.retrieve("cus_123")
# Set in client options
assert_equal "Bearer test_123", req.headers["Authorization"]
assert_equal "acct_123", req.headers["Stripe-Account"]
assert_requested(:get, "#{Stripe::DEFAULT_API_BASE}/v1/customers/cus_123")
end
should "request options overrides client config options" do
client = StripeClient.new("test_123", stripe_version: "2022-11-15", stripe_account: "acct_123")

View File

@ -97,6 +97,50 @@ module Stripe
end
end
context "client_init" do
setup do
@client_opts = Hash[StripeClient::CLIENT_OPTIONS.map { |k| [k, nil] }] # rubocop:todo Style/HashConversion - necessary for Ruby <= 2.5
@old_api_key = Stripe.api_key
@old_stripe_account = Stripe.stripe_account
@old_enable_telemetry = Stripe.instance_variable_get(:@enable_telemetry)
@old_open_timeout = Stripe.open_timeout
@old_uploads_base = Stripe.uploads_base
end
teardown do
Stripe.api_key = @old_api_key
Stripe.stripe_account = @old_stripe_account
Stripe.enable_telemetry = @old_enable_telemetry
Stripe.open_timeout = @old_open_timeout
Stripe.uploads_base = @old_uploads_base
end
should "correctly set options for the client" do
# mix of default, global, client options
Stripe.api_key = "global_test_123"
Stripe.stripe_account = "global_acct_123"
Stripe.enable_telemetry = false
Stripe.open_timeout = 30_000
Stripe.uploads_base = "global_uploads_base.stripe.com"
@client_opts[:api_key] = "client_test_123"
@client_opts[:stripe_account] = "client_acct_123"
@client_opts[:uploads_base] = "client_uploads_base.stripe.com"
@client_opts.reject! { |_k, v| v.nil? }
client_config = Stripe::StripeConfiguration.client_init(@client_opts)
assert_equal("client_test_123", client_config.api_key) # client api key
assert_equal("client_acct_123", client_config.stripe_account) # client stripe account
assert_equal(false, client_config.enable_telemetry) # global telemetry
assert_equal(30_000, client_config.open_timeout) # global timeout
assert_equal("client_uploads_base.stripe.com", client_config.base_addresses[:files]) # client uploads base
assert_equal(Stripe::DEFAULT_API_BASE, client_config.base_addresses[:api]) # default api base
assert_equal(ApiVersion::CURRENT, client_config.api_version) # default api version
assert_equal(Stripe::DEFAULT_CA_BUNDLE_PATH, client_config.ca_bundle_path) # default ca bundle path
end
end
context "#max_network_retries=" do
should "coerce the option into an integer" do
config = Stripe::StripeConfiguration.setup