Class: Dhl::Intraship::ShipmentItem

Inherits:
Object
  • Object
show all
Defined in:
lib/dhl-intraship/shipment_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ShipmentItem

Returns a new instance of ShipmentItem.



11
12
13
14
15
16
17
18
# File 'lib/dhl-intraship/shipment_item.rb', line 11

def initialize(attributes = {})
  attributes.each do |key, value|
    setter = :"#{key.to_s}="
    if self.respond_to?(setter)
      self.send(setter, value)
    end
  end
end

Instance Attribute Details

#heightObject

Returns the value of attribute height.



5
6
7
# File 'lib/dhl-intraship/shipment_item.rb', line 5

def height
  @height
end

#lengthObject

Returns the value of attribute length.



5
6
7
# File 'lib/dhl-intraship/shipment_item.rb', line 5

def length
  @length
end

#package_typeObject



7
8
9
# File 'lib/dhl-intraship/shipment_item.rb', line 7

def package_type
  @package_type || 'PK'
end

#weightObject

Returns the value of attribute weight.



5
6
7
# File 'lib/dhl-intraship/shipment_item.rb', line 5

def weight
  @weight
end

#widthObject

Returns the value of attribute width.



5
6
7
# File 'lib/dhl-intraship/shipment_item.rb', line 5

def width
  @width
end

Instance Method Details

#append_to_xml(xml) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/dhl-intraship/shipment_item.rb', line 20

def append_to_xml(xml)
  xml.ShipmentItem do |xml|
    xml.WeightInKG(weight)
    xml.LengthInCM(length) unless length.nil?
    xml.WidthInCM(width) unless width.nil?
    xml.HeightInCM(height) unless height.nil?
    xml.PackageType(package_type)
  end
end