class Allegro::Client
Attributes
http_agent[R]
Public Class Methods
new(client_id, secret, _options = {})
click to toggle source
# File lib/allegro/client.rb, line 8 def initialize(client_id, secret, _options = {}) @http_agent = Http::Agent.new(_options) @authorized = false authorize(client_id, secret) end
Public Instance Methods
api_url(url)
click to toggle source
# File lib/allegro/client.rb, line 45 def api_url(url) [API_URI, url.to_s].join('/') end
auth_url(url)
click to toggle source
# File lib/allegro/client.rb, line 49 def auth_url(url) [AUTH_URI, url.to_s].join('/') end
default_headers()
click to toggle source
# File lib/allegro/client.rb, line 59 def default_headers { accept: 'application/vnd.allegro.public.v1+json', authorization: "#{@token_type} #{@access_token}" } end
default_params()
click to toggle source
# File lib/allegro/client.rb, line 53 def default_params { method: :get, headers: default_headers } end
get(resource, params)
click to toggle source
# File lib/allegro/client.rb, line 33 def get(resource, params) @http_agent.fetch( api_url(resource), default_params.merge(params) ) end
search(params)
click to toggle source
# File lib/allegro/client.rb, line 39 def search(params) @http_agent.fetch( api_url('offers/listing'), default_params.merge(params) ) end