Class: Ocs::Response
- Inherits:
-
Object
- Object
- Ocs::Response
- Defined in:
- lib/ocs/response.rb
Instance Attribute Summary collapse
-
#raw_body ⇒ Object
readonly
Returns the value of attribute raw_body.
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(faraday_response) ⇒ Response
constructor
A new instance of Response.
- #response_key ⇒ Object
- #status ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(faraday_response) ⇒ Response
Returns a new instance of Response.
5 6 7 8 9 |
# File 'lib/ocs/response.rb', line 5 def initialize(faraday_response) @raw_body = faraday_response.body.with_indifferent_access @raw_headers = faraday_response.headers @raw_status = faraday_response.status end |
Instance Attribute Details
#raw_body ⇒ Object (readonly)
Returns the value of attribute raw_body.
3 4 5 |
# File 'lib/ocs/response.rb', line 3 def raw_body @raw_body end |
Instance Method Details
#content ⇒ Object
11 12 13 |
# File 'lib/ocs/response.rb', line 11 def content @content ||= raw_body[response_key] end |
#response_key ⇒ Object
15 16 17 |
# File 'lib/ocs/response.rb', line 15 def response_key @response_key ||= raw_body.keys.first end |
#status ⇒ Object
19 20 21 |
# File 'lib/ocs/response.rb', line 19 def status @raw_status end |
#success? ⇒ Boolean
23 24 25 |
# File 'lib/ocs/response.rb', line 23 def success? !content.has_key?("errorcode") end |