Class: Cargowise::Order

Inherits:
AbstractResult show all
Defined in:
lib/cargowise/order.rb

Overview

A purchase order that is being shipped to from a supplier to you via a logistics company.

Typcially you will setup an arrangement with your account manager where they are sent copies of POs so they can be entered into the database and tracked.

All order objects are read-only, see the object attributes to see what information is available.

Use class find methods to retrieve order info from your logistics company.

Order.find_by_order_number(...)
Order.find_incomplete(...)
etc

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractResult

endpoint, #inspect, register, via

Constructor Details

#initialize(node) ⇒ Order

Returns a new instance of Order.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/cargowise/order.rb', line 34

def initialize(node)
  @node = node

  @order_number = text_value("./OrderIdentifier/OrderNumber")
  @invoice_number = text_value("./OrderDetail/InvoiceNumber")
  @order_status = text_value("./OrderDetail/OrderStatus")
  @description  = text_value("./OrderDetail/Description")
  @datetime     = time_value("./OrderDetail/OrderDateTime")
  @order_total  = decimal_value("./OrderDetail/OrderTotal")
  @transport_mode = text_value("./OrderDetail/TransportMode")
  @container_mode = text_value("./OrderDetail/ContainerMode")

  @buyer_name   = text_value("./OrderDetail/Buyer/OrganisationDetails/Name")

  @supplier_name = text_value("./OrderDetail/Supplier/OrganisationDetails/Name")

  @shipments = node_array("./Shipment").map { |node|
    Shipment.new(node)
  }
end

Instance Attribute Details

#buyer_nameObject (readonly)

Returns the value of attribute buyer_name.



28
29
30
# File 'lib/cargowise/order.rb', line 28

def buyer_name
  @buyer_name
end

#container_modeObject (readonly)

Returns the value of attribute container_mode.



25
26
27
# File 'lib/cargowise/order.rb', line 25

def container_mode
  @container_mode
end

#datetimeObject (readonly)

Returns the value of attribute datetime.



24
25
26
# File 'lib/cargowise/order.rb', line 24

def datetime
  @datetime
end

#descriptionObject (readonly)

Returns the value of attribute description.



24
25
26
# File 'lib/cargowise/order.rb', line 24

def description
  @description
end

#invoice_numberObject (readonly)

Returns the value of attribute invoice_number.



26
27
28
# File 'lib/cargowise/order.rb', line 26

def invoice_number
  @invoice_number
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



24
25
26
# File 'lib/cargowise/order.rb', line 24

def order_number
  @order_number
end

#order_statusObject (readonly)

Returns the value of attribute order_status.



24
25
26
# File 'lib/cargowise/order.rb', line 24

def order_status
  @order_status
end

#order_totalObject (readonly)

Returns the value of attribute order_total.



25
26
27
# File 'lib/cargowise/order.rb', line 25

def order_total
  @order_total
end

#shipmentsObject (readonly)

Returns the value of attribute shipments.



32
33
34
# File 'lib/cargowise/order.rb', line 32

def shipments
  @shipments
end

#supplier_nameObject (readonly)

Returns the value of attribute supplier_name.



30
31
32
# File 'lib/cargowise/order.rb', line 30

def supplier_name
  @supplier_name
end

#transport_modeObject (readonly)

Returns the value of attribute transport_mode.



25
26
27
# File 'lib/cargowise/order.rb', line 25

def transport_mode
  @transport_mode
end

Instance Method Details

#to_xmlObject



55
56
57
# File 'lib/cargowise/order.rb', line 55

def to_xml
  @node.to_xml
end