class BestBuy::Client

A BestBuy::Client allows queries to be constructed to the BestBuy API

Public Class Methods

new(api_key: nil, affiliate_tracking_id: nil) click to toggle source

@param api_key The API Key for making requests to the BestBuy API. Get one at remix.mashery.com/member/register

# File lib/bestbuy/client.rb, line 5
def initialize(api_key: nil, affiliate_tracking_id: nil)
  raise ArgumentError, "API Key not set" unless api_key
  @api_key = api_key
  @affiliate_tracking_id = affiliate_tracking_id
end

Public Instance Methods

products(**params) click to toggle source

Issues a request for products held in the BestBuy API

@param params Parameters passed to the products API call which filter the result set. Parameters are combined by logical OR @return Array<Hash> Products that were found in the BestBuy API

# File lib/bestbuy/client.rb, line 15
def products(**params)
  filters = params.map {|key, value| "#{key}=#{value}"}
  BestBuy::Request.new(api_key: @api_key,
                       affiliate_tracking_id: @affiliate_tracking_id,
                       endpoint: 'products',
                       filters: filters)
end