Class: ShopsavvyDataApi::ProductDetails

Inherits:
Object
  • Object
show all
Defined in:
lib/shopsavvy_data_api/models.rb

Overview

Product details from ShopSavvy API

Direct Known Subclasses

ProductWithOffers

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ ProductDetails

Returns a new instance of ProductDetails.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/shopsavvy_data_api/models.rb', line 53

def initialize(data)
  @title = data["title"]
  @shopsavvy = data["shopsavvy"]
  @brand = data["brand"]
  @category = data["category"]
  @images = data["images"] || []
  @barcode = data["barcode"]
  @amazon = data["amazon"]
  @model = data["model"]
  @mpn = data["mpn"]
  @color = data["color"]
  @title_short = data["title_short"]
  @slug = data["slug"]
  @description = data["description"]
  @categories = data["categories"]
  @attributes = data["attributes"]
  @rating = data["rating"]
  @score = data["score"]
  @keywords = data["keywords"]
  @identifiers = data["identifiers"]
end

Instance Attribute Details

#amazonObject (readonly)

Returns the value of attribute amazon.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def amazon
  @amazon
end

#attributesObject (readonly)

Returns the value of attribute attributes.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def attributes
  @attributes
end

#barcodeObject (readonly)

Returns the value of attribute barcode.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def barcode
  @barcode
end

#brandObject (readonly)

Returns the value of attribute brand.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def brand
  @brand
end

#categoriesObject (readonly)

Returns the value of attribute categories.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def categories
  @categories
end

#categoryObject (readonly)

Returns the value of attribute category.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def category
  @category
end

#colorObject (readonly)

Returns the value of attribute color.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def color
  @color
end

#descriptionObject (readonly)

Returns the value of attribute description.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def description
  @description
end

#identifiersObject (readonly)

Returns the value of attribute identifiers.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def identifiers
  @identifiers
end

#imagesObject (readonly)

Returns the value of attribute images.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def images
  @images
end

#keywordsObject (readonly)

Returns the value of attribute keywords.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def keywords
  @keywords
end

#modelObject (readonly)

Returns the value of attribute model.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def model
  @model
end

#mpnObject (readonly)

Returns the value of attribute mpn.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def mpn
  @mpn
end

#ratingObject (readonly)

Returns the value of attribute rating.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def rating
  @rating
end

#scoreObject (readonly)

Returns the value of attribute score.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def score
  @score
end

#shopsavvyObject (readonly)

Returns the value of attribute shopsavvy.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def shopsavvy
  @shopsavvy
end

#slugObject (readonly)

Returns the value of attribute slug.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def slug
  @slug
end

#titleObject (readonly)

Returns the value of attribute title.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def title
  @title
end

#title_shortObject (readonly)

Returns the value of attribute title_short.



48
49
50
# File 'lib/shopsavvy_data_api/models.rb', line 48

def title_short
  @title_short
end

Instance Method Details

#asinObject

Deprecated.

Use ‘amazon` instead



86
87
88
# File 'lib/shopsavvy_data_api/models.rb', line 86

def asin
  amazon
end

#image_urlObject

Deprecated.

Use ‘images` instead



91
92
93
# File 'lib/shopsavvy_data_api/models.rb', line 91

def image_url
  images&.first
end

#nameObject

Deprecated.

Use ‘title` instead



76
77
78
# File 'lib/shopsavvy_data_api/models.rb', line 76

def name
  title
end

#product_idObject

Deprecated.

Use ‘shopsavvy` instead



81
82
83
# File 'lib/shopsavvy_data_api/models.rb', line 81

def product_id
  shopsavvy
end

#to_hObject



95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/shopsavvy_data_api/models.rb', line 95

def to_h
  {
    title: title,
    shopsavvy: shopsavvy,
    brand: brand,
    category: category,
    images: images,
    barcode: barcode,
    amazon: amazon,
    model: model,
    mpn: mpn,
    color: color
  }
end