Module: Agris::Api::Support
- Included in:
- Client
- Defined in:
- lib/agris/api/support.rb
Instance Method Summary collapse
-
#build_response(output_hash, type) ⇒ Object
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.
-
#context_hash ⇒ Object
NB: We could refactor these into builder classes so that we can use Gyoku to convert to XML.
- #create_post_payload_xml(details) ⇒ Object
- #extract_documents(message, type) ⇒ Object
- #import(model) ⇒ Object
- #post_input_hash ⇒ Object
Instance Method Details
#build_response(output_hash, type) ⇒ Object
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.
7 8 9 |
# File 'lib/agris/api/support.rb', line 7 def build_response(output_hash, type) DocumentQueryResponse.new(output_hash, type) end |
#context_hash ⇒ Object
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?
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# 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) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# 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) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/agris/api/support.rb', line 11 def extract_documents(, type) response = @request.( Gyoku.xml(xml: context_hash), ., .to_xml ) build_response(response.output_hash, type) end |
#import(model) ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/agris/api/support.rb', line 64 def import(model) = Messages::Import.new(model) response = @request.( Gyoku.xml(xml: context_hash), ., .to_xml ) PostResult.new(response) end |
#post_input_hash ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/agris/api/support.rb', line 42 def post_input_hash { input: { :@endofprocessoption => 1, :@altnameidonfile => 'N', :@usecurdate4outofrange => 'N', :@reportoption => 1, :@usefile => false } } end |