Class: Google4R::Checkout::ShippingAdjustment
- Inherits:
-
Object
- Object
- Google4R::Checkout::ShippingAdjustment
- Defined in:
- lib/google4r/checkout/notifications.rb
Overview
ShippingAdjustments represent the chosen shipping method.
Constant Summary collapse
- MERCHANT_CALCULATED =
"MERCHANT_CALCULATED".freeze
- FLAT_RATE =
"FLAT_RATE".freeze
- PICKUP =
"PICKUP".freeze
Instance Attribute Summary collapse
-
#cost ⇒ Object
The cost of the selected shipping (Money).
-
#name ⇒ Object
The name of the shipping adjustment.
-
#type ⇒ Object
The type of the shipping adjustment, one of MERCHANT_CALCULATED, FLAT_RATE PICKUP.
Class Method Summary collapse
-
.create_from_element(element) ⇒ Object
Creates a new ShippingAdjustment object from a REXML::Element object.
Instance Attribute Details
#cost ⇒ Object
The cost of the selected shipping (Money).
593 594 595 |
# File 'lib/google4r/checkout/notifications.rb', line 593 def cost @cost end |
#name ⇒ Object
The name of the shipping adjustment.
590 591 592 |
# File 'lib/google4r/checkout/notifications.rb', line 590 def name @name end |
#type ⇒ Object
The type of the shipping adjustment, one of MERCHANT_CALCULATED, FLAT_RATE PICKUP.
587 588 589 |
# File 'lib/google4r/checkout/notifications.rb', line 587 def type @type end |
Class Method Details
.create_from_element(element) ⇒ Object
Creates a new ShippingAdjustment object from a REXML::Element object.
Can raise a RuntimeException if the given Element is invalid.
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 |
# File 'lib/google4r/checkout/notifications.rb', line 598 def self.create_from_element(element) result = ShippingAdjustment.new result.type = case element.name when 'flat-rate-shipping-adjustment' then FLAT_RATE when 'pickup-shipping-adjustment' then PICKUP when 'merchant-calculated-shipping-adjustment' then MERCHANT_CALCULATED else raise "Unexpected shipping adjustment '#{element.name}'" end result.name = element.elements['shipping-name'].text amount = (element.elements['shipping-cost'].text.to_f*100).to_i currency = element.elements['shipping-cost'].attributes['currency'] result.cost = Money.new(amount, currency) return result end |