Class: Google4R::Checkout::CarrierCalculatedShipping::ShippingPackage

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

Constant Summary collapse

RESIDENTIAL =

Constants for delivery address category

'RESIDENTIAL'
COMMERCIAL =
'COMMERCIAL'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(carrier_calculated_shipping) ⇒ ShippingPackage



1059
1060
1061
# File 'lib/google4r/checkout/shared.rb', line 1059

def initialize(carrier_calculated_shipping)
  @carrier_calculated_shipping = carrier_calculated_shipping
end

Instance Attribute Details

#carrier_calculated_shippingObject (readonly)

The CarrierCalculatedShipping instance that this package belongs to.



1036
1037
1038
# File 'lib/google4r/checkout/shared.rb', line 1036

def carrier_calculated_shipping
  @carrier_calculated_shipping
end

#delivery_address_categoryObject

This indicates whether the shipping method should be applied to a residential or a commercial address. Valid values for this tag are RESIDENTIAL and COMMERCIAL. (String, optional)



1045
1046
1047
# File 'lib/google4r/checkout/shared.rb', line 1045

def delivery_address_category
  @delivery_address_category
end

#heightObject

This contains information about the height of the package being shipped to the customer. (Google::Checktou::Dimension, optional)



1049
1050
1051
# File 'lib/google4r/checkout/shared.rb', line 1049

def height
  @height
end

#lengthObject

This contains information about the length of the package being shipped to the customer. (Google::Checktou::Dimension, optional)



1053
1054
1055
# File 'lib/google4r/checkout/shared.rb', line 1053

def length
  @length
end

#ship_fromObject

This contains information about the location from which an order will be shipped. (AnonymousAddress)



1040
1041
1042
# File 'lib/google4r/checkout/shared.rb', line 1040

def ship_from
  @ship_from
end

#widthObject

This contains information about the width of the package being shipped to the customer. (Google::Checktou::Dimension, optional)



1057
1058
1059
# File 'lib/google4r/checkout/shared.rb', line 1057

def width
  @width
end

Class Method Details

.create_from_element(this_shipping, element) ⇒ Object

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



1065
1066
1067
1068
1069
1070
1071
1072
1073
# File 'lib/google4r/checkout/shared.rb', line 1065

def self.create_from_element(this_shipping, element)
  result = ShippingPackage.new(this_shipping)
  result.ship_from = ShipFromAddress.create_from_element(element.elements['ship-from'])
  result.delivery_address_category = element.elements['delivery-address-category'].text rescue nil
  result.height = element.elements['height'].text rescue nil
  result.length = element.elements['length'].text rescue nil
  result.width = element.elements['width'].text rescue nil
  return result
end