class Bricklink::Client

Constants

AUTH_PARAMS
BASE_URL

Public Instance Methods

get_price_guide(item_number, options = {}) click to toggle source
# File lib/bricklink/client.rb, line 14
def get_price_guide item_number, options = {}
  default_params = { 
    'guide type' => 'stock',
    'new_or_used' => 'N',
    'country_code' => 'US',
    'currency_code' => 'USD',
    'region' => 'north_america'
  }
  call_api "/items/SET/#{item_number}/price", default_params.merge(options)
end

Protected Instance Methods

access_token() click to toggle source
# File lib/bricklink/client.rb, line 37
def access_token
  consumer = OAuth::Consumer.new(consumer_key, consumer_secret, { site: BASE_URL })
  access_token = OAuth::AccessToken.new(consumer, token, token_secret)
end
call_api(path, params = {}) click to toggle source
# File lib/bricklink/client.rb, line 27
def call_api path, params = {}
  response = access_token.get([path, URI.encode_www_form(params)].join("?"))

  if response.is_a? Net::HTTPOK
    JSON.parse(response.body)
  else
    raise response.body
  end
end