module Agris::Api::Inventory::Orders

Public Instance Methods

create_order(order) click to toggle source
# File lib/agris/api/inventory/orders.rb, line 6
def create_order(order)
  response = @request.process_message(
    Gyoku.xml(xml: context_hash),
    82_320,
    create_post_payload_xml(convert_order_to_details(order))
  )

  PostResult.new(response)
end
order(order_location, order_number, order_type = 'S') click to toggle source
# File lib/agris/api/inventory/orders.rb, line 16
def order(order_location, order_number, order_type = 'S')
  extract = SpecificOrderExtract.new(
    order_location, order_number, order_type
  )

  orders([extract])
end
orders(order_extracts) click to toggle source
# File lib/agris/api/inventory/orders.rb, line 24
def orders(order_extracts)
  extract_documents(
    Messages::QueryOrderDocuments.new(order_extracts),
    Agris::Api::Order
  )
end
orders_changed_since(datetime, detail = false) click to toggle source
# File lib/agris/api/inventory/orders.rb, line 31
def orders_changed_since(datetime, detail = false)
  extract_documents(
    Messages::QueryChangedOrders.new(datetime, detail),
    Agris::Api::Order
  )
end

Protected Instance Methods

convert_order_to_details(order) click to toggle source

NB: We should probably refactor this into a class and write tests

to verify conversion of a sales model to an expected payload.
# File lib/agris/api/inventory/orders.rb, line 42
def convert_order_to_details(order)
  details = []
  details << order.to_xml_hash
  details << order.remarks.map(&:to_xml_hash)
  details
end