class Epages::Product

Constants

KEYS

Public Class Methods

new(data) click to toggle source
# File lib/epages/product.rb, line 17
def initialize(data)
  parse_attribute_as_array_of(:images, data.delete(:images), Epages::Image)
  parse_attribute_as_array_of(:links, data.delete(:links), Epages::Link)
  parse_attribute_as(:price_info, data.delete(:priceInfo), Epages::PriceInfo)
  parse_attributes(data)
end

Public Instance Methods

==(other) click to toggle source

compare the product with another product. 2 products are considered equals if both has the same id, the same name and the same product_number

# File lib/epages/product.rb, line 26
def ==(other)
  return false unless other.is_a? Epages::Product
  product_id == other.product_id && name == other.name && product_number == other.product_number
end
add_slideshow_image(image) click to toggle source

add an image to the slideshow

@param image [String]

# File lib/epages/product.rb, line 59
def add_slideshow_image(image)
  product_add_slideshow_image(self, image)
end
categories() click to toggle source

returns the categories of the product

# File lib/epages/product.rb, line 93
def categories
  product_categories(self) if link?('categories')
end
custom_attributes() click to toggle source

returns the list of custom_attributes of the product

# File lib/epages/product.rb, line 88
def custom_attributes
  product_custom_attributes(self) if link?('custom-attributes')
end
delete_slideshow_image(image) click to toggle source

remove the image passed from the slideshow and return the new slideshow

@param image [String]

# File lib/epages/product.rb, line 66
def delete_slideshow_image(image)
  product_delete_slideshow_image(self, image)
end
host() click to toggle source

returns the host of the shop that belongs to the product

# File lib/epages/product.rb, line 37
def host
  URI.parse(sf_url).host
end
lowest_price() click to toggle source

returns the lowest price of all the variations of the product

# File lib/epages/product.rb, line 98
def lowest_price
  product_lowest_price(self) if link?('lowest-price')
end
shop_name() click to toggle source

returns the name of the shop that belongs the product

# File lib/epages/product.rb, line 32
def shop_name
  sf_url[%r{epages\/(\w+)}, 1]
end
slideshow() click to toggle source

returns the list of slides of the product

# File lib/epages/product.rb, line 52
def slideshow
  product_slideshow(self) if link?('slideshow')
end
slideshow_sequence() click to toggle source

returns an array containing the slideshow sequence

# File lib/epages/product.rb, line 71
def slideshow_sequence
  product_slideshow_sequence(self)
end
to_line_item(quantity = 1) click to toggle source

return a hash with productId and quantity. This format is used for the line_items of Cart

# File lib/epages/product.rb, line 103
def to_line_item(quantity = 1)
  {productId: product_id, quantity: quantity}
end
update_slideshow_sequence(data) click to toggle source

updates the order of the sequence with the data passed as parameter

@param data [Array]

# File lib/epages/product.rb, line 78
def update_slideshow_sequence(data)
  product_update_slideshow_sequence(self, data)
end
variations() click to toggle source

returns the list of variations of the product

# File lib/epages/product.rb, line 83
def variations
  product_variations(self) if link?('variations')
end