Class: OpenSRS::Response
- Inherits:
-
Object
- Object
- OpenSRS::Response
- Defined in:
- lib/opensrs/response.rb
Instance Attribute Summary collapse
-
#request_xml ⇒ Object
readonly
Returns the value of attribute request_xml.
-
#response ⇒ Object
Returns the value of attribute response.
-
#response_xml ⇒ Object
readonly
Returns the value of attribute response_xml.
-
#success ⇒ Object
Returns the value of attribute success.
Instance Method Summary collapse
-
#errors ⇒ Object
We need to return the error message unless the response is successful.
-
#initialize(parsed_response, request_xml, response_xml) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Constructor Details
#initialize(parsed_response, request_xml, response_xml) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 11 |
# 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 |
Instance Attribute Details
#request_xml ⇒ Object (readonly)
Returns the value of attribute request_xml.
3 4 5 |
# File 'lib/opensrs/response.rb', line 3 def request_xml @request_xml end |
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/opensrs/response.rb', line 4 def response @response end |
#response_xml ⇒ Object (readonly)
Returns the value of attribute response_xml.
3 4 5 |
# File 'lib/opensrs/response.rb', line 3 def response_xml @response_xml end |
#success ⇒ Object
Returns the value of attribute success.
4 5 6 |
# File 'lib/opensrs/response.rb', line 4 def success @success end |
Instance Method Details
#errors ⇒ Object
We need to return the error message unless the response is successful.
15 16 17 18 19 20 21 22 23 |
# 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? ⇒ Boolean
25 26 27 |
# File 'lib/opensrs/response.rb', line 25 def success? response["is_success"] ? response["is_success"].to_s == "1" : true end |