lib/stripe/util.rb in stripe-1.18.0 vs lib/stripe/util.rb in stripe-1.19.0
- old
+ new
@@ -19,10 +19,11 @@
@object_classes ||= {
# data structures
'list' => ListObject,
# business objects
+ 'account' => Account,
'application_fee' => ApplicationFee,
'balance' => Balance,
'balance_transaction' => BalanceTransaction,
'card' => Card,
'charge' => Charge,
@@ -36,22 +37,23 @@
'recipient' => Recipient,
'refund' => Refund,
'subscription' => Subscription,
'file_upload' => FileUpload,
'transfer' => Transfer,
+ 'transfer_reversal' => Reversal,
'bitcoin_receiver' => BitcoinReceiver,
'bitcoin_transaction' => BitcoinTransaction
}
end
- def self.convert_to_stripe_object(resp, api_key)
+ def self.convert_to_stripe_object(resp, opts)
case resp
when Array
- resp.map { |i| convert_to_stripe_object(i, api_key) }
+ resp.map { |i| convert_to_stripe_object(i, opts) }
when Hash
# Try converting to a known object class. If none available, fall back to generic StripeObject
- object_classes.fetch(resp[:object], StripeObject).construct_from(resp, api_key)
+ object_classes.fetch(resp[:object], StripeObject).construct_from(resp, opts)
else
resp
end
end
@@ -117,26 +119,19 @@
result
end
# The secondary opts argument can either be a string or hash
# Turn this value into an api_key and a set of headers
- def self.parse_opts(opts)
+ def self.normalize_opts(opts)
case opts
when NilClass
- return nil, {}
+ {}
when String
- return opts, {}
+ {:api_key => opts}
when Hash
- headers = {}
- if opts[:idempotency_key]
- headers[:idempotency_key] = opts[:idempotency_key]
- end
- if opts[:stripe_account]
- headers[:stripe_account] = opts[:stripe_account]
- end
- return opts[:api_key], headers
+ opts.clone
else
- raise TypeError.new("parse_opts expects a string or a hash")
+ raise TypeError.new('normalize_opts expects a string or a hash')
end
end
end
end