Class: BeeiqAPI::Response
- Inherits:
-
Object
- Object
- BeeiqAPI::Response
- Defined in:
- lib/beeiq_api/response.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #body ⇒ Object
- #code ⇒ Object
- #headers ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #raw_body ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
5 6 7 |
# File 'lib/beeiq_api/response.rb', line 5 def initialize(response) @response = response end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
3 4 5 |
# File 'lib/beeiq_api/response.rb', line 3 def response @response end |
Instance Method Details
#body ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/beeiq_api/response.rb', line 9 def body if success? { success: true } else format_hash(JSON.parse(response.body, :quirks_mode => true)) end end |
#code ⇒ Object
25 26 27 |
# File 'lib/beeiq_api/response.rb', line 25 def code response.code end |
#headers ⇒ Object
29 30 31 |
# File 'lib/beeiq_api/response.rb', line 29 def headers response.headers end |
#raw_body ⇒ Object
17 18 19 |
# File 'lib/beeiq_api/response.rb', line 17 def raw_body response.body end |
#success? ⇒ Boolean
21 22 23 |
# File 'lib/beeiq_api/response.rb', line 21 def success? [200, 204].include? response.code end |