Class: Agris::Api::Inventory::DeliveryTicket

Inherits:
Object
  • Object
show all
Includes:
XmlModel
Defined in:
lib/agris/api/inventory/delivery_ticket.rb

Constant Summary collapse

ATTRIBUTE_NAMES =
%w(
  ticket_status
  ticket_status_description
  ticket_location
  ticket_location_description
  ticket_number
  pickup_delivery
  shipment_date
  void_date
  bill_to_id
  bill_to_description
  state_county
  state_county_description
  user_order_field_1
  user_order_field_2
  external_order_number
  ship_to_id
  ship_to_description
  shipper_id
  shipper_description
  broker_id
  broker_description
  invoice_terms
  terms_description
  entry_date
  delete
  last_change_date_time
  last_change_user_id
  last_change_user_name
  unique_id
).freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from XmlModel

included

Constructor Details

#initialize(hash = {}) ⇒ DeliveryTicket

Returns a new instance of DeliveryTicket.



74
75
76
77
78
79
80
# File 'lib/agris/api/inventory/delivery_ticket.rb', line 74

def initialize(hash = {})
  super

  @line_items = []
  @remarks = []
  @tran_codes = []
end

Class Method Details

.from_xml_hash(hash) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/agris/api/inventory/delivery_ticket.rb', line 42

def self.from_xml_hash(hash)
  super.tap do |delivery_ticket|
    if hash['lineitems']
      delivery_ticket.line_items.concat(
        [hash['lineitems']['lineitem']]
        .flatten
        .map do |lineitem|
          DeliveryTicketLineItem.from_xml_hash(lineitem)
        end
      )
    end
    if hash['remarks']
      delivery_ticket.remarks.concat(
        [hash['remarks']['remark']]
        .flatten
        .map do |remark|
          Agris::Api::Remark.from_xml_hash(remark)
        end
      )
    end
    if hash['trancodes']
      delivery_ticket.tran_codes.concat(
        [hash['trancodes']['trancode']]
        .flatten
        .map do |trancode|
          Agris::Api::TranCode.from_xml_hash(trancode)
        end
      )
    end
  end
end