class Agris::Api::Order

NB: This is the model for returning orders

Constants

ATTRIBUTE_NAMES

Public Class Methods

from_xml_hash(hash) click to toggle source
Calls superclass method
# File lib/agris/api/order.rb, line 32
def self.from_xml_hash(hash)
  super.tap do |order|
    if hash['lineitems']
      order.line_items.concat(
        [hash['lineitems']['lineitem']]
          .flatten
          .map do |lineitem|
            OrderLine.from_xml_hash(lineitem)
          end
      )
    end
    if hash['trancodes']
      order.tran_codes.concat(
        [hash['trancodes']['trancode']]
        .flatten
        .map do |trancode|
          Agris::Api::TranCode.from_xml_hash(trancode)
        end
      )
    end
  end
end
new(hash = {}) click to toggle source
Calls superclass method
# File lib/agris/api/order.rb, line 55
def initialize(hash = {})
  super

  @line_items = []
  @tran_codes = []
end