Class: Zinc::Product

Inherits:
Resource show all
Defined in:
lib/zinc/product.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#to_hash

Constructor Details

#initialize(hash) ⇒ Product

Returns a new instance of Product.



34
35
36
37
# File 'lib/zinc/product.rb', line 34

def initialize(hash)
  super(hash, exclude: %w(seller_selection_criteria))
  @seller_selection_criteria = SellerSelectionCriteria.new(hash['seller_selection_criteria']) if hash['seller_selection_criteria']
end

Instance Attribute Details

#all_variantsObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def all_variants
  @all_variants
end

#asinObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def asin
  @asin
end

#authorsObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def authors
  @authors
end

#brandObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def brand
  @brand
end

#categoriesObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def categories
  @categories
end

#epidsObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def epids
  @epids
end

#epids_mapObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def epids_map
  @epids_map
end

#feature_bulletsObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def feature_bullets
  @feature_bullets
end

#imagesObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def images
  @images
end

#item_locationObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def item_location
  @item_location
end

#item_numberObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def item_number
  @item_number
end

#main_imageObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def main_image
  @main_image
end

#original_retail_priceObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def original_retail_price
  @original_retail_price
end

#package_dimensionsObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def package_dimensions
  @package_dimensions
end

#priceObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def price
  @price
end

#product_descriptionObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def product_description
  @product_description
end

#product_detailsObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def product_details
  @product_details
end

#product_idObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def product_id
  @product_id
end

#quantityObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def quantity
  @quantity
end

#question_countObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def question_count
  @question_count
end

#retailerObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def retailer
  @retailer
end

#review_countObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def review_count
  @review_count
end

#seller_selection_criteriaObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def seller_selection_criteria
  @seller_selection_criteria
end

#starsObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def stars
  @stars
end

#statusObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def status
  @status
end

#timestampObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def timestamp
  @timestamp
end

#titleObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def title
  @title
end

#variant_specificsObject



5
6
7
# File 'lib/zinc/product.rb', line 5

def variant_specifics
  @variant_specifics
end

Class Method Details

.find(id, retailer:, async: false, max_age: nil, newer_than: nil) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/zinc/product.rb', line 40

def find(id, retailer:, async: false, max_age: nil, newer_than: nil)
  unless Zinc::RETAILERS.include?(retailer)
    raise StandardError, "#{retailer} is not supported - the supported retailers are #{Zinc::RETAILERS.to_sentence}"
  end

  params               = {}
  params['retailer']   = retailer
  params['async']      = true if async
  params['max_age']    = max_age if max_age
  params['newer_than'] = newer_than if newer_than

  get(path: "products/#{id}?#{URI.encode_www_form(params)}")
end