Class: Stellae::Order

Inherits:
Request show all
Defined in:
lib/stellae/order.rb

Constant Summary

Constants inherited from Request

Request::SCHEMA

Instance Method Summary collapse

Methods inherited from Request

#build_header, #build_user, #construct_xml, #initialize

Constructor Details

This class inherits a constructor from Stellae::Request

Instance Method Details

#build_order_request(order) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/stellae/order.rb', line 4

def build_order_request(order)
  construct_xml "new_order_entry" do |xml|

    xml.ohn :"xmlns:b" => SCHEMA[:datacontract], :"xmlns:i" => SCHEMA[:instance] do
      xml.b :CARRIER,            order[:carrier]
      xml.b :CURRENCY,           order[:currency]
      build_address(xml, "CUSTOMER", order[:billing_address])
      xml.b :CUSTOMER_CODE
      xml.b :CUSTOMER_PO, :"i:nil" => "true"
      build_address xml, "DELIVERY", order[:shipping_address]
      xml.b :DELIVERY_DC_EDI,   :"i:nil" => "true"
      xml.b :DELIVERY_DOOR_EDI, :"i:nil" => "true"
      xml.b :DELIVERY_FROM,     :"i:nil" => "true"
      xml.b :DELIVERY_ID,       :"i:nil" => "true"
      xml.b :DELIVERY_MESSAGE do
        xml.cdata!(order[:gift_message])
      end
      xml.b :DELIVERY_TO,     :"i:nil" => "true"
      xml.b :DISCOUNT,           order[:item_discount] || 0
      xml.b :EMAIL,              order[:email]
      xml.b :FREIGHT_ACCOUNT, :"i:nil" => "true"
      xml.b :MISC1, 0
      xml.b :MISC1_REASON,    :"i:nil" => "true"
      xml.b :MISC2, 0
      xml.b :MISC2_REASON,    :"i:nil" => "true"
      xml.b :ORDER_ID,           order[:number]
      xml.b :ORDER_TYPE,         order[:type] || 'OO'
      build_line_items xml, order
      xml.b :SERVICE,            order[:shipping_code]
      xml.b :SHIPPING_FEES,      shipping_fees(order)
      xml.b :TAXES,              order[:tax] || 0
      xml.b :TOTAL_AMOUNT,       order[:total_amount] || 0
      xml.b :USER1 do
        xml.cdata!(order[:invoice_url])
      end
      xml.b :USER2,     :"i:nil" => "true"
      xml.b :USER3,     :"i:nil" => "true"
      xml.b :USER4,     :"i:nil" => "true"
      xml.b :USER5,     :"i:nil" => "true"
      xml.b :WAREHOUSE, :"i:nil" => "true"
    end

  end
end