lib/stripe/util.rb in stripe-10.2.0.pre.beta.1 vs lib/stripe/util.rb in stripe-10.2.0
- old
+ new
@@ -5,11 +5,10 @@
module Stripe
module Util
# Options that a user is allowed to specify.
OPTS_USER_SPECIFIED = Set[
:api_key,
- :authenticator,
:idempotency_key,
:stripe_account,
:stripe_version
].freeze
@@ -78,12 +77,12 @@
unless id.is_a?(String)
raise ArgumentError,
"id should be a string representing the ID of an API resource"
end
- url = "#{target.resource_url}/"\
- "#{CGI.escape(id)}/"\
+ url = "#{target.resource_url}/" \
+ "#{CGI.escape(id)}/" \
"#{CGI.escape(http_path)}"
resp, opts = resource.execute_resource_request(
http_verb,
url,
@@ -138,13 +137,11 @@
obj = object_classes.fetch(object_name, StripeObject)
.construct_from(data, opts)
# set filters so that we can fetch the same limit, expansions, and
# predicates when accessing the next and previous pages
- if obj && (obj.is_a?(SearchResultObject) || obj.is_a?(ListObject))
- obj.filters = params.dup
- end
+ obj.filters = params.dup if obj && (obj.is_a?(SearchResultObject) || obj.is_a?(ListObject))
obj
else
data
end
@@ -152,31 +149,31 @@
def self.log_error(message, data = {})
config = data.delete(:config) || Stripe.config
logger = config.logger || Stripe.logger
if !logger.nil? ||
- !config.log_level.nil? && config.log_level <= Stripe::LEVEL_ERROR
+ (!config.log_level.nil? && config.log_level <= Stripe::LEVEL_ERROR)
log_internal(message, data, color: :cyan, level: Stripe::LEVEL_ERROR,
logger: Stripe.logger, out: $stderr)
end
end
def self.log_info(message, data = {})
config = data.delete(:config) || Stripe.config
logger = config.logger || Stripe.logger
if !logger.nil? ||
- !config.log_level.nil? && config.log_level <= Stripe::LEVEL_INFO
+ (!config.log_level.nil? && config.log_level <= Stripe::LEVEL_INFO)
log_internal(message, data, color: :cyan, level: Stripe::LEVEL_INFO,
logger: Stripe.logger, out: $stdout)
end
end
def self.log_debug(message, data = {})
config = data.delete(:config) || Stripe.config
logger = config.logger || Stripe.logger
if !logger.nil? ||
- !config.log_level.nil? && config.log_level <= Stripe::LEVEL_DEBUG
+ (!config.log_level.nil? && config.log_level <= Stripe::LEVEL_DEBUG)
log_internal(message, data, color: :blue, level: Stripe::LEVEL_DEBUG,
logger: Stripe.logger, out: $stdout)
end
end
@@ -184,14 +181,14 @@
case object
when Hash
new_hash = {}
object.each do |key, value|
key = (begin
- key.to_sym
- rescue StandardError
- key
- end) || key
+ key.to_sym
+ rescue StandardError
+ key
+ end) || key
new_hash[key] = symbolize_names(value)
end
new_hash
when Array
object.map { |value| symbolize_names(value) }
@@ -280,16 +277,10 @@
def self.normalize_opts(opts)
case opts
when String
{ api_key: opts }
when Hash
- # If the user is using request signing for authentication,
- # no need to check the api_key per request.
- if !(opts.key?(:client) &&
- opts.fetch(:client).config.authenticator) &&
- opts.key?(:api_key)
- check_api_key!(opts.fetch(:api_key))
- end
+ check_api_key!(opts.fetch(:api_key)) if opts.key?(:api_key)
# Explicitly use dup here instead of clone to avoid preserving freeze
# state on input params.
opts.dup
else
raise TypeError, "normalize_opts expects a string or a hash"