Remove regexes

This commit is contained in:
Michael Broshi 2025-03-27 13:05:47 -04:00
parent fd98c84804
commit 8683ba7868
2 changed files with 6 additions and 34 deletions

View File

@ -160,16 +160,18 @@ module Stripe
end
def self.add_beta_version(beta_name, version)
unless version.match?(/\Av\d+\z/)
unless version.start_with?("v") && version[1..-1].to_i.to_s == version[1..-1]
raise ArgumentError, "Version must be in the format 'v' followed by a number (e.g., 'v3')"
end
if api_version.include?("; #{beta_name}=")
current_version = api_version.match(/; #{beta_name}=v(\d+)/)[1].to_i
if (index = api_version.index("; #{beta_name}="))
start_index = index + "; #{beta_name}=".length
end_index = api_version.index(";", start_index) || api_version.length
current_version = api_version[start_index...end_index][1..-1].to_i
new_version = version[1..-1].to_i
return if new_version <= current_version # Keep the higher version, no update needed
self.api_version = api_version.sub(/; #{beta_name}=v\d+/, "; #{beta_name}=#{version}")
self.api_version = api_version[0...index] + "; #{beta_name}=#{version}" + api_version[end_index..-1]
else
self.api_version = "#{api_version}; #{beta_name}=#{version}"
end

View File

@ -3851,20 +3851,6 @@ module Stripe
client.v1.quotes.update("qt_xxxxxxxxxxxxx", { metadata: { order_id: "6735" } })
assert_requested :post, "#{Stripe::DEFAULT_API_BASE}/v1/quotes/qt_xxxxxxxxxxxxx"
end
should "Test quotes preview invoices lines get" do
Stripe::Quote.list_preview_invoice_lines("qt_xyz", "in_xyz")
assert_requested :get, "#{Stripe.api_base}/v1/quotes/qt_xyz/preview_invoices/in_xyz/lines"
end
should "Test quotes preview invoices lines get (service)" do
stub_request(
:get,
"#{Stripe::DEFAULT_API_BASE}/v1/quotes/qt_xyz/preview_invoices/in_xyz/lines"
).to_return(body: "{}")
client = StripeClient.new("sk_test_123")
client.v1.quotes.list_preview_invoice_lines("qt_xyz", "in_xyz")
assert_requested :get, "#{Stripe::DEFAULT_API_BASE}/v1/quotes/qt_xyz/preview_invoices/in_xyz/lines"
end
should "Test radar early fraud warnings get" do
Stripe::Radar::EarlyFraudWarning.list({ limit: 3 })
assert_requested :get, "#{Stripe.api_base}/v1/radar/early_fraud_warnings?limit=3"
@ -4870,22 +4856,6 @@ module Stripe
client.v1.tax_codes.retrieve("txcd_xxxxxxxxxxxxx")
assert_requested :get, "#{Stripe::DEFAULT_API_BASE}/v1/tax_codes/txcd_xxxxxxxxxxxxx"
end
should "Test tax forms pdf get" do
block_handler = {}
Stripe::Tax::Form.pdf("form_xxxxxxxxxxxxx", &block_handler)
assert_requested :get, "#{Stripe.api_base}/v1/tax/forms/form_xxxxxxxxxxxxx/pdf"
end
should "Test tax forms pdf get (service)" do
block_handler = {}
stub_request(
:get,
"#{Stripe::DEFAULT_UPLOAD_BASE}/v1/tax/forms/form_xxxxxxxxxxxxx/pdf"
).to_return(body: "{}")
client = StripeClient.new("sk_test_123")
client.v1.tax.forms.pdf("form_xxxxxxxxxxxxx", &block_handler)
assert_requested :get, "#{Stripe::DEFAULT_UPLOAD_BASE}/v1/tax/forms/form_xxxxxxxxxxxxx/pdf"
end
should "Test tax ids delete" do
Stripe::TaxId.delete("taxid_123")
assert_requested :delete, "#{Stripe.api_base}/v1/tax_ids/taxid_123"