Class: Iloxx::Shipping::OrderRequest

Inherits:
Request
  • Object
show all
Defined in:
lib/iloxx_shipping/order_request.rb

Constant Summary collapse

REQUEST_TYPE =
:ppvOrderRequest

Instance Method Summary collapse

Methods inherited from Request

#build!

Constructor Details

#initialize(attributes = {}) ⇒ OrderRequest

Returns a new instance of OrderRequest.



7
8
9
10
11
# File 'lib/iloxx_shipping/order_request.rb', line 7

def initialize(attributes = {})
  super(attributes)
  @shipping_date = attributes[:shipping_date]
  @parcels = attributes[:parcels]
end

Instance Method Details

#body(xml) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/iloxx_shipping/order_request.rb', line 13

def body(xml)
  xml.tns :OrderAction, "addOrder"
  xml.tns :ServiceSettings do |xml|
    xml.tns :ErrorLanguage, "German" # TODO: make configurable
    xml.tns :CountrySettings, "ISO3166"
    xml.tns :ZipCodeSetting, "ZipCodeAsSingleValue"
  end
  xml.tns :OrderLabel do |xml|
    xml.tns :LabelSize, "MultiLabel_A4" # TODO: make configurable
    xml.tns :LabelStartPosition, "UpperLeft"
  end
  xml.tns :ShipDate, @shipping_date.strftime("%d.%m.%Y")
  xml.tns :ppvOrderDataArray do |xml|
    @parcels.each do |parcel|
      parcel.append_to_xml(xml)
    end
  end
end