Class: Linkshare::Product

Inherits:
Base
  • Object
show all
Defined in:
lib/linkshare/product.rb

Constant Summary collapse

PARAMS =

cat = Category, mid = Advertister

%w[token cat max maxResults pagenumber mid keyword exact one none sort sorttype]
BASE_URL =
'http://productsearch.linksynergy.com/productsearch'

Instance Attribute Summary

Attributes inherited from Base

#page_number, #total_matches, #total_pages

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

base_url, credentials, first, get_service, #pass=, raise_if_invalid_response, #user_id=

Constructor Details

#initialize(product) ⇒ Product

Returns a new instance of Product.



26
27
28
# File 'lib/linkshare/product.rb', line 26

def initialize(product)
  super(product)
end

Class Method Details

.find(params = {}) ⇒ Object



14
15
16
17
18
# File 'lib/linkshare/product.rb', line 14

def find(params = {})
  validate_params!(params)
  result = get_service(service_url, params)
  Array.wrap(result['result']['item']).collect{ |product| self.new(product) }
end

.service_urlObject



10
11
12
# File 'lib/linkshare/product.rb', line 10

def service_url
  BASE_URL
end

.validate_params!(params) ⇒ Object



20
21
22
23
# File 'lib/linkshare/product.rb', line 20

def validate_params!(params)
  params.merge!('token' => credentials['token'])
  super(params, PARAMS)
end