Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
helenye-stripe committed Jan 13, 2025
1 parent 72c0856 commit 6c2f861
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.
38 changes: 19 additions & 19 deletions lib/stripe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,25 @@ module Stripe
DEFAULT_METER_EVENTS_BASE = "https://meter-events.stripe.com"

# Options that can be configured globally by users
USER_CONFIGURABLE_GLOBAL_OPTIONS = Set.new([
: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
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
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/stripe_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class StripeClient

# For internal use only. Does not provide a stable API and may be broken
# with future non-major changes.
CLIENT_OPTIONS = Set.new([:api_key, :stripe_account, :stripe_context, :api_version, :api_base, :uploads_base, :connect_base, :meter_events_base, :client_id])
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, # rubocop:todo Metrics/ParameterLists
Expand Down
7 changes: 3 additions & 4 deletions lib/stripe/stripe_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def self.client_init(config_opts)
imported_options = USER_CONFIGURABLE_GLOBAL_OPTIONS - StripeClient::CLIENT_OPTIONS
client_config = StripeConfiguration.setup do |instance|
imported_options.each do |key|
if global_config.respond_to?(key)
instance.public_send("#{key}=", global_config.public_send(key))
end
instance.public_send("#{key}=", global_config.public_send(key)) if global_config.respond_to?(key)
end
end
client_config.reverse_duplicate_merge(config_opts)
Expand Down Expand Up @@ -84,7 +82,8 @@ def initialize
@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, meter_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)
Expand Down
6 changes: 3 additions & 3 deletions test/stripe/stripe_configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,20 @@ class StripeConfigurationTest < Test::Unit::TestCase
Stripe.api_key = "global_test_123"
Stripe.stripe_account = "global_acct_123"
Stripe.enable_telemetry = false
Stripe.open_timeout = 30000
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_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(30000, client_config.open_timeout) # global timeout
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
Expand Down

0 comments on commit 6c2f861

Please sign in to comment.