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 6
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 15
def errors
  if !success?
    if response["response_text"] and response["response_code"]
      "#{response["response_text"]} (Code #{response["response_code"]})"
    else
      "Unknown error"
    end
  end
end
success?() click to toggle source
# File lib/opensrs/response.rb, line 25
def success?
  response["is_success"] ? response["is_success"].to_s == "1" : true
end