Class: Stellae::Order

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

Constant Summary

Constants included from State

State::STATE_MAP

Constants inherited from Request

Request::SCHEMA

Instance Method Summary collapse

Methods included from State

#state_abbr

Methods inherited from Request

#build_header, #build_user, #construct_xml, #initialize, #soap_field, #soap_value

Constructor Details

This class inherits a constructor from Stellae::Request

Instance Method Details

#build_order_request(order) ⇒ Object



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
48
49
50
51
52
53
# File 'lib/stellae/order.rb', line 6

def build_order_request(order)

  construct_xml "new_order_entry" do |xml|

    xml.ohn :"xmlns:a" => SCHEMA[:datacontract], :"xmlns:i" => SCHEMA[:instance] do

      soap_field       xml, :CARRIER,          order[:carrier].upcase
      soap_field       xml, :CURRENCY,         order[:currency].upcase
      build_address    xml, "CUSTOMER",        order[:billing_address]
      soap_field       xml, :CUSTOMER_CODE
      build_name       xml, "CUSTOMER",        order[:billing_address]
      soap_field       xml, :CUSTOMER_PO
      build_telephone  xml, "CUSTOMER",        order[:billing_address]
      build_address    xml, "DELIVERY",        order[:shipping_address]
      soap_field       xml, :DELIVERY_DC_EDI
      soap_field       xml, :DELIVERY_DOOR_EDI
      soap_field       xml, :DELIVERY_FROM
      soap_field       xml, :DELIVERY_ID
      soap_field       xml, :DELIVERY_MESSAGE, order[:gift_message]
      build_name       xml, "DELIVERY",        order[:shipping_address]
      build_telephone  xml, "DELIVERY",        order[:shipping_address]
      soap_field       xml, :DELIVERY_TO
      soap_field       xml, :DISCOUNT,         order[:item_discount] || 0
      soap_field       xml, :EMAIL,            order[:email]
      soap_field       xml, :FREIGHT_ACCOUNT
      soap_field       xml, :MISC1,            0
      soap_field       xml, :MISC1_REASON
      soap_field       xml, :MISC2,            0
      soap_field       xml, :MISC2_REASON
      soap_field       xml, :ORDER_ID,         order[:number]
      soap_field       xml, :ORDER_TYPE,       order[:type] || 'OO'
      build_line_items xml,                    order
      soap_field       xml, :SERVICE,          order[:shipping_method]
      soap_field       xml, :SHIPPING_FEES,    shipping_fees(order)
      soap_field       xml, :TAXES,            order[:tax] || 0
      soap_field       xml, :TOTAL_AMOUNT,     order[:total_amount] || 0
      soap_field       xml, :USER1,            order[:invoice_url]
      soap_field       xml, :USER2
      soap_field       xml, :USER3
      soap_field       xml, :USER4
      soap_field       xml, :USER5
      soap_field       xml, :WAREHOUSE

    end

  end

end