Class: ShopsavvyDataApi::ProductWithOffers
- Inherits:
-
ProductDetails
- Object
- ProductDetails
- ShopsavvyDataApi::ProductWithOffers
- Defined in:
- lib/shopsavvy_data_api/models.rb
Overview
Product with nested offers (returned by offers endpoint)
Instance Attribute Summary collapse
-
#offers ⇒ Object
readonly
Returns the value of attribute offers.
Attributes inherited from ProductDetails
#amazon, #attributes, #barcode, #brand, #categories, #category, #color, #description, #identifiers, #images, #keywords, #model, #mpn, #rating, #score, #shopsavvy, #slug, #title, #title_short
Instance Method Summary collapse
-
#initialize(data) ⇒ ProductWithOffers
constructor
A new instance of ProductWithOffers.
- #to_h ⇒ Object
Methods inherited from ProductDetails
#asin, #image_url, #name, #product_id
Constructor Details
#initialize(data) ⇒ ProductWithOffers
Returns a new instance of ProductWithOffers.
115 116 117 118 |
# File 'lib/shopsavvy_data_api/models.rb', line 115 def initialize(data) super(data) @offers = (data["offers"] || []).map { |offer| Offer.new(offer) } end |
Instance Attribute Details
#offers ⇒ Object (readonly)
Returns the value of attribute offers.
113 114 115 |
# File 'lib/shopsavvy_data_api/models.rb', line 113 def offers @offers end |
Instance Method Details
#to_h ⇒ Object
120 121 122 |
# File 'lib/shopsavvy_data_api/models.rb', line 120 def to_h super.merge(offers: offers.map(&:to_h)) end |