module Agris::Api::Support
Public Instance Methods
build_response(output_hash, type)
click to toggle source
NB: I feel like this module could be broken up into more appropriately
named files, but I'm not sure what those would be at present.
# File lib/agris/api/support.rb, line 7 def build_response(output_hash, type) DocumentQueryResponse.new(output_hash, type) end
context_hash()
click to toggle source
NB: We could refactor these into builder classes so that we can
use Gyoku to convert to XML. I imagine some kind of composite builder that wraps child builders with the xml container tags. Classes like SpecificOrderExtract and NewOrder would be possible candidates to become builders, include the builder module or have companion builder classes. AgrisInput, AgrisOutput?
# File lib/agris/api/support.rb, line 27 def context_hash { login: { :@dataset => @dataset || @context.default_dataset, :@databasetype => 'SQL', :@database => @context.database, :@userid => @context.userid, :@password => @context.password, :@datapath => @context.datapath, :@log => 'Y', :@loglevel => '9' } } end
create_post_payload_xml(details)
click to toggle source
# File lib/agris/api/support.rb, line 54 def create_post_payload_xml(details) details_xml = details.map do |detail| Gyoku.xml(detail: detail) end.join '<xml>' \ "#{Gyoku.xml(post_input_hash)}<details>#{details_xml}</details>" \ '</xml>' end
extract_documents(message, type)
click to toggle source
# File lib/agris/api/support.rb, line 11 def extract_documents(message, type) response = @request.process_message( Gyoku.xml(xml: context_hash), message.message_number, message.to_xml ) build_response(response.output_hash, type) end
import(model)
click to toggle source
# File lib/agris/api/support.rb, line 64 def import(model) import_message = Messages::Import.new(model) response = @request.process_message( Gyoku.xml(xml: context_hash), import_message.message_number, import_message.to_xml ) PostResult.new(response) end
post_input_hash()
click to toggle source
# File lib/agris/api/support.rb, line 42 def post_input_hash { input: { :@endofprocessoption => 1, :@altnameidonfile => 'N', :@usecurdate4outofrange => 'N', :@reportoption => 1, :@usefile => false } } end