Class: Google4R::Checkout::CarrierCalculatedShipping::CarrierCalculatedShippingOption

Inherits:
DeliveryMethod
  • Object
show all
Defined in:
lib/google4r/checkout/shared.rb

Constant Summary collapse

FEDEX =

Constants for shipping company

'FedEx'
UPS =
'UPS'
USPS =
'USPS'
DROP_OFF =

Constants for carrier pickup

'DROP_OFF'
REGULAR_PICKUP =
'REGULAR_PICKUP'
SPECIAL_PICKUP =
'SPECIAL_PICKUP'

Instance Attribute Summary collapse

Attributes inherited from DeliveryMethod

#name, #price

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(carrier_calculated_shipping) ⇒ CarrierCalculatedShippingOption

Returns a new instance of CarrierCalculatedShippingOption.



1027
1028
1029
1030
# File 'lib/google4r/checkout/shared.rb', line 1027

def initialize(carrier_calculated_shipping)
  @carrier_calculated_shipping = carrier_calculated_shipping
  #@carrier_pickup = DROP_OFF
end

Instance Attribute Details

#additional_fixed_chargeObject

The fixed charge that will be added to the total cost of an order if the buyer selects the associated shipping option (Money, optional)



1020
1021
1022
# File 'lib/google4r/checkout/shared.rb', line 1020

def additional_fixed_charge
  @additional_fixed_charge
end

#additional_variable_charge_percentObject

The percentage amount by which a carrier-calculated shipping rate will be adjusted. The tag’s value may be positive or negative. (Float, optional)



1025
1026
1027
# File 'lib/google4r/checkout/shared.rb', line 1025

def additional_variable_charge_percent
  @additional_variable_charge_percent
end

#carrier_calculated_shippingObject (readonly)

The CarrierCalculatedShipping instance that this option belongs to.



1000
1001
1002
# File 'lib/google4r/checkout/shared.rb', line 1000

def carrier_calculated_shipping
  @carrier_calculated_shipping
end

#carrier_pickupObject

This specifies how the package will be transferred from the merchant to the shipper. Valid values for this tag are REGULAR_PICKUP, SPECIAL_PICKUP and DROP_OFF. The default value for this tag is DROP_OFF. (optional)



1015
1016
1017
# File 'lib/google4r/checkout/shared.rb', line 1015

def carrier_pickup
  @carrier_pickup
end

#shipping_typeObject

The shipping option that is being offered to the buyer



1009
1010
1011
# File 'lib/google4r/checkout/shared.rb', line 1009

def shipping_type
  @shipping_type
end

Class Method Details

.create_from_element(this_shipping, element) ⇒ Object

Creates a new CarrierCalculatedShippingOption from the given REXML::Element instance. For testing only.



1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
# File 'lib/google4r/checkout/shared.rb', line 1035

def self.create_from_element(this_shipping, element)
  result = CarrierCalculatedShippingOption.new(this_shipping)
  result.shipping_company = element.elements['shipping-company'].text
  price = (BigDecimal.new(element.elements['price'].text) * 100).to_i
  price_currency = element.elements['price'].attributes['currency']
  result.price = Money.new(price, price_currency)
  result.shipping_type = element.elements['shipping-type']
  result.carrier_pickup = element.elements['carrier-pickup'] rescue nil
  result.additional_fixed_charge = 
      element.elements['additional-fixed-charge'] rescue nil
  result.additional_variable_charge_percent =
      element.elements['additional-variable-charge-percent'] rescue nil
end