Class: Myxy::Response
- Inherits:
-
Object
- Object
- Myxy::Response
- Defined in:
- lib/myxy/response.rb
Constant Summary collapse
- ERROR_CODES =
[400, 500].freeze
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#response ⇒ Object
Returns the value of attribute response.
-
#status_code ⇒ Object
Returns the value of attribute status_code.
Instance Method Summary collapse
- #all ⇒ Object
- #data ⇒ Object
- #error? ⇒ Boolean
- #error_message ⇒ Object
- #first ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #meta ⇒ Object
- #parsed_body ⇒ Object
Constructor Details
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
4 5 6 |
# File 'lib/myxy/response.rb', line 4 def body @body end |
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/myxy/response.rb', line 4 def response @response end |
#status_code ⇒ Object
Returns the value of attribute status_code.
4 5 6 |
# File 'lib/myxy/response.rb', line 4 def status_code @status_code end |
Instance Method Details
#all ⇒ Object
41 42 43 |
# File 'lib/myxy/response.rb', line 41 def all data end |
#data ⇒ Object
25 26 27 |
# File 'lib/myxy/response.rb', line 25 def data parsed_body['data'] end |
#error? ⇒ Boolean
33 34 35 |
# File 'lib/myxy/response.rb', line 33 def error? ERROR_CODES.include? status_code end |
#error_message ⇒ Object
29 30 31 |
# File 'lib/myxy/response.rb', line 29 def parsed_body['error']['message'] end |
#first ⇒ Object
37 38 39 |
# File 'lib/myxy/response.rb', line 37 def first data[0] end |
#meta ⇒ Object
17 18 19 |
# File 'lib/myxy/response.rb', line 17 def parsed_body['meta_data'] end |
#parsed_body ⇒ Object
21 22 23 |
# File 'lib/myxy/response.rb', line 21 def parsed_body @parsed_body ||= JSON.parse(response.body) end |