Class: Agris::Api::Grain::Contract

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

Defined Under Namespace

Classes: Schedule

Constant Summary collapse

ATTRIBUTE_NAMES =
%w(
  contract_location
  contract_number
  date_written
  integration_guid
  purchase_sales
  purchase_sales_description
  contract_location_description
  contract_name_id
  contract_name_description
  contract_type
  unique_id
  contract_type_description
  status
  status_description
  signed
  commodity
  commodity_description
  class
  variety
  transport_mode
  transport_description
  external_contract_no
  delivery_terms
  advance_percent
  contract_loads
  applied_loads
  remaining_loads
  contract_quantity
  applied_quantity
  remaining_quantity
  ordered_quantity
  unordered_quantity
  uom
  uom_description
  dp_table
  dp_table_description
  invoice_terms
  invoice_terms_description
  quantity_base
  quantity_base_description
  weight_base
  weight_base_description
  grade_base
  grade_base_description
  ship_to_from_id
  ship_to_from_description
  misc_id
  misc_description
  agent_broker_id
  agent_broker_description
  qty_uom
  qty_uom_description
  last_change_datetime
  delete
  last_change_user_id
  last_change_username
).freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from XmlModel

included

Constructor Details

#initialize(hash = {}) ⇒ Contract

Returns a new instance of Contract.



83
84
85
86
87
# File 'lib/agris/api/grain/contract.rb', line 83

def initialize(hash = {})
  super

  @schedules = []
end

Class Method Details

.from_xml_hash(hash) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/agris/api/grain/contract.rb', line 69

def self.from_xml_hash(hash)
  super.tap do |document|
    if hash['schedules']
      document.schedules.concat(
        [hash['schedules']['schedule']]
          .flatten
          .map do |schedule|
            Schedule.from_xml_hash(schedule)
          end
      )
    end
  end
end