Class: Patronage::API
- Inherits:
-
Object
- Object
- Patronage::API
- Defined in:
- lib/patronage/api.rb
Instance Method Summary collapse
- #get(url, headers = {}) ⇒ Object
-
#initialize(base_url, options = {}) ⇒ API
constructor
A new instance of API.
- #service(service_name, opts = {}) ⇒ Object
Constructor Details
#initialize(base_url, options = {}) ⇒ API
Returns a new instance of API.
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/patronage/api.rb', line 3 def initialize(base_url, = {}) @session = ::Patron::Session.new @session.base_url = base_url @default_params = .delete(:params) || {} .each do |key, value| if @session.public_methods.include?("#{key}=") send("#{key}=", value) end end end |
Instance Method Details
#get(url, headers = {}) ⇒ Object
15 16 17 18 19 |
# File 'lib/patronage/api.rb', line 15 def get(url, headers = {}) url = ::Addressable::URI.parse(url) url.query_values = url.query_values.merge(@default_params) @session.get(url.to_s, headers) end |