Class: UriService::Client::Response
- Inherits:
-
Object
- Object
- UriService::Client::Response
- Defined in:
- lib/uri_service/client/response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#errors? ⇒ Boolean
Checks if errors are present in the response.
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
8 9 10 11 12 |
# File 'lib/uri_service/client/response.rb', line 8 def initialize(response) @status = response.status @raw = response.body @data = raw.nil? || raw.empty? ? nil : JSON.parse(raw) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/uri_service/client/response.rb', line 6 def data @data end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
6 7 8 |
# File 'lib/uri_service/client/response.rb', line 6 def raw @raw end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/uri_service/client/response.rb', line 6 def status @status end |
Instance Method Details
#errors? ⇒ Boolean
Checks if errors are present in the response
15 16 17 |
# File 'lib/uri_service/client/response.rb', line 15 def errors? data.key?('errors') # and check status end |