Class: BestBuy::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/bestbuy/client.rb

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil, affiliate_tracking_id: nil) ⇒ Client

Returns a new instance of Client

Parameters:

Raises:

  • (ArgumentError)

5
6
7
8
9
# 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

Instance Method Details

#products(**params) ⇒ Object

Issues a request for products held in the BestBuy API

Parameters:

  • params (Hash)

    Parameters passed to the products API call which filter the result set. Parameters are combined by logical OR


15
16
17
18
19
20
21
# 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