Class: A2z::Responses::Offer
Instance Attribute Summary collapse
-
#amount_saved ⇒ Object
Returns the value of attribute amount_saved.
-
#availability ⇒ Object
Returns the value of attribute availability.
-
#condition ⇒ Object
Returns the value of attribute condition.
-
#listing_id ⇒ Object
Returns the value of attribute listing_id.
-
#percentage_saved ⇒ Object
Returns the value of attribute percentage_saved.
-
#price ⇒ Object
Returns the value of attribute price.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Offer
constructor
A new instance of Offer.
- #super_saver_shipping_eligible=(value) ⇒ Object
- #super_saver_shipping_eligible? ⇒ Boolean
Constructor Details
#initialize ⇒ Offer
Returns a new instance of Offer.
9 10 11 12 13 14 |
# File 'lib/a2z/responses/offer.rb', line 9 def initialize @price = Money.new(0, 'USD') @amount_saved = Money.new(0, 'USD') @percentage_saved = 0 @super_saver_shipping_eligible = false end |
Instance Attribute Details
#amount_saved ⇒ Object
Returns the value of attribute amount_saved.
6 7 8 |
# File 'lib/a2z/responses/offer.rb', line 6 def amount_saved @amount_saved end |
#availability ⇒ Object
Returns the value of attribute availability.
6 7 8 |
# File 'lib/a2z/responses/offer.rb', line 6 def availability @availability end |
#condition ⇒ Object
Returns the value of attribute condition.
6 7 8 |
# File 'lib/a2z/responses/offer.rb', line 6 def condition @condition end |
#listing_id ⇒ Object
Returns the value of attribute listing_id.
6 7 8 |
# File 'lib/a2z/responses/offer.rb', line 6 def listing_id @listing_id end |
#percentage_saved ⇒ Object
Returns the value of attribute percentage_saved.
6 7 8 |
# File 'lib/a2z/responses/offer.rb', line 6 def percentage_saved @percentage_saved end |
#price ⇒ Object
Returns the value of attribute price.
6 7 8 |
# File 'lib/a2z/responses/offer.rb', line 6 def price @price end |
Class Method Details
.from_response(data) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/a2z/responses/offer.rb', line 34 def self.from_response(data) new.tap do |offer| if (attributes = data['OfferAttributes']) offer.condition = attributes['Condition'] end if (listing = data['OfferListing']) offer.listing_id = listing['OfferListingId'] offer.price = Money.new(listing['Price']['Amount'].to_i, listing['Price']['CurrencyCode']) if listing['Price'] offer.amount_saved = Money.new(listing['AmountSaved']['Amount'].to_i, listing['AmountSaved']['CurrencyCode']) if listing['AmountSaved'] offer.percentage_saved = listing['PercentageSaved'].to_i offer.availability = listing['Availability'] offer.super_saver_shipping_eligible = listing['IsEligibleForSuperSaverShipping'] == '1' end offer.freeze end end |
Instance Method Details
#super_saver_shipping_eligible=(value) ⇒ Object
26 27 28 |
# File 'lib/a2z/responses/offer.rb', line 26 def super_saver_shipping_eligible=(value) @super_saver_shipping_eligible = !!value end |
#super_saver_shipping_eligible? ⇒ Boolean
30 31 32 |
# File 'lib/a2z/responses/offer.rb', line 30 def super_saver_shipping_eligible? @super_saver_shipping_eligible end |