mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-05-28 00:02:13 -04:00
33 lines
927 B
Ruby
33 lines
927 B
Ruby
module Stripe
|
|
module APIOperations
|
|
module Request
|
|
module ClassMethods
|
|
@@opts_to_persist = Set.new([:api_key, :api_base, :stripe_account, :stripe_version])
|
|
|
|
def request(method, url, params={}, opts={})
|
|
opts = Util.normalize_opts(opts)
|
|
|
|
headers = opts.clone
|
|
api_key = headers.delete(:api_key)
|
|
api_base = headers.delete(:api_base)
|
|
# Assume all remaining opts must be headers
|
|
|
|
response, opts[:api_key] = Stripe.request(method, url, api_key, params, headers, api_base)
|
|
[response, opts.select {|k, _| @@opts_to_persist.include?(k)}]
|
|
end
|
|
end
|
|
|
|
def self.included(base)
|
|
base.extend(ClassMethods)
|
|
end
|
|
|
|
protected
|
|
|
|
def request(method, url, params={}, opts={})
|
|
opts = @opts.merge(Util.normalize_opts(opts))
|
|
self.class.request(method, url, params, opts)
|
|
end
|
|
end
|
|
end
|
|
end
|