Class: Agris::Api::PostResult

Inherits:
Struct
  • Object
show all
Defined in:
lib/agris/api/post_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#responseObject

Returns the value of attribute response

Returns:

  • (Object)

    the current value of response



4
5
6
# File 'lib/agris/api/post_result.rb', line 4

def response
  @response
end

Instance Method Details

#document_numberObject



5
6
7
# File 'lib/agris/api/post_result.rb', line 5

def document_number
  results['result']['document']
end

#reject_reasonsObject



9
10
11
12
13
# File 'lib/agris/api/post_result.rb', line 9

def reject_reasons
  results['result']['rejects']['reject']
    .compact
    .map { |rejection| rejection['reason'] }
end

#resultsObject



15
16
17
# File 'lib/agris/api/post_result.rb', line 15

def results
  response.output_hash['results']
end

#statusObject



19
20
21
# File 'lib/agris/api/post_result.rb', line 19

def status
  results.fetch('result', 'status' => 'No Result').fetch('status')
end