Class: Fassbinder::OfferBuilder
- Inherits:
-
Object
- Object
- Fassbinder::OfferBuilder
- Defined in:
- lib/fassbinder/offer_builder.rb
Instance Attribute Summary collapse
-
#offer ⇒ Object
readonly
Returns the value of attribute offer.
Instance Method Summary collapse
- #add_item(hash) ⇒ Object
- #add_seller(hash) ⇒ Object
- #add_shipping(hash) ⇒ Object
- #id=(id) ⇒ Object
-
#initialize ⇒ OfferBuilder
constructor
A new instance of OfferBuilder.
- #venue=(venue) ⇒ Object
Constructor Details
#initialize ⇒ OfferBuilder
Returns a new instance of OfferBuilder.
9 10 11 |
# File 'lib/fassbinder/offer_builder.rb', line 9 def initialize @offer = Kosher::Offer.new end |
Instance Attribute Details
#offer ⇒ Object (readonly)
Returns the value of attribute offer.
7 8 9 |
# File 'lib/fassbinder/offer_builder.rb', line 7 def offer @offer end |
Instance Method Details
#add_item(hash) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/fassbinder/offer_builder.rb', line 13 def add_item(hash) builder = ItemBuilder.new builder.price = hash['OfferListing']['Price'] builder.quantity = hash['OfferListing']['Quantity'] builder.add_condition(hash['OfferAttributes']['SubCondition']) builder.add_description(hash['OfferAttributes']['ConditionNote']) @offer.item = builder.item end |
#add_seller(hash) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/fassbinder/offer_builder.rb', line 22 def add_seller(hash) builder = SellerBuilder.new builder.id = hash['MerchantId'] builder.name = hash['Name'] builder. = hash['AverageFeedbackRating'] builder.add_location(hash['Location']) if hash['Location'] @offer.seller = builder.seller end |
#add_shipping(hash) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/fassbinder/offer_builder.rb', line 31 def add_shipping(hash) builder = ShippingBuilder.new builder.add_availability(hash['OfferListing']['AvailabilityAttributes']['MaximumHours']) is_free = (hash['OfferListing']['IsEligibleForSuperSaverShipping'] == '1') builder.calculate_price(is_free, @offer.venue, hash['OfferListing']['Price']['CurrencyCode']) @offer.shipping = builder.shipping end |
#id=(id) ⇒ Object
39 40 41 |
# File 'lib/fassbinder/offer_builder.rb', line 39 def id=(id) @offer.id = id end |
#venue=(venue) ⇒ Object
43 44 45 |
# File 'lib/fassbinder/offer_builder.rb', line 43 def venue=(venue) @offer.venue = venue end |