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 
- CARRIER_CALCULATED =
- "CARRIER_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).
| 665 666 667 | # File 'lib/google4r/checkout/notifications.rb', line 665 def cost @cost end | 
#name ⇒ Object
The name of the shipping adjustment.
| 662 663 664 | # File 'lib/google4r/checkout/notifications.rb', line 662 def name @name end | 
#type ⇒ Object
The type of the shipping adjustment, one of MERCHANT_CALCULATED, FLAT_RATE PICKUP.
| 659 660 661 | # File 'lib/google4r/checkout/notifications.rb', line 659 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.
| 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 | # File 'lib/google4r/checkout/notifications.rb', line 670 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 when 'carrier-calculated-shipping-adjustment' then CARRIER_CALCULATED else raise "Unexpected shipping adjustment '#{element.name}'" end result.name = element.elements['shipping-name'].text amount = (BigDecimal.new(element.elements['shipping-cost'].text)*100).to_i currency = element.elements['shipping-cost'].attributes['currency'] result.cost = Money.new(amount, currency) return result end |