class OpenSRS::Response
Attributes
request_xml[R]
response[RW]
response_xml[R]
success[RW]
Public Class Methods
new(parsed_response, request_xml, response_xml)
click to toggle source
# File lib/opensrs/response.rb, line 7 def initialize(parsed_response, request_xml, response_xml) @response = parsed_response @request_xml = request_xml @response_xml = response_xml @success = success? end
Public Instance Methods
errors()
click to toggle source
We need to return the error message unless the response is successful.
# File lib/opensrs/response.rb, line 16 def errors return if success? msg = @response['response_text'] code = @response['response_code'] msg && code ? "#{msg} (Code #{code})" : 'Unknown error' end
success?()
click to toggle source
If ‘is_success’ is returned, the API is letting us know that they will explicitly tell us whether something has succeeded or not.
Otherwise, just assume it failed.
# File lib/opensrs/response.rb, line 29 def success? return false unless @response['is_success'] @response['is_success'] == '1' end