Class: Rubyflare::Response
- Inherits:
-
Object
- Object
- Rubyflare::Response
- Defined in:
- lib/rubyflare/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(method_name, endpoint, response) ⇒ Response
constructor
A new instance of Response.
- #messages ⇒ Object
- #result ⇒ Object
- #results ⇒ Object
- #successful? ⇒ Boolean
Constructor Details
#initialize(method_name, endpoint, response) ⇒ Response
Returns a new instance of Response.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/rubyflare/response.rb', line 5 def initialize(method_name, endpoint, response) @body = JSON.parse(response, symbolize_names: true) unless successful? = "Unable to #{method_name.to_s.upcase} to endpoint: " \ "#{endpoint}. Inspect Rubyflare::ConnectionError#response "\ "for further details" raise Rubyflare::ConnectionError.new(, self) end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/rubyflare/response.rb', line 3 def body @body end |
Instance Method Details
#errors ⇒ Object
28 29 30 |
# File 'lib/rubyflare/response.rb', line 28 def errors body[:errors] end |
#messages ⇒ Object
32 33 34 |
# File 'lib/rubyflare/response.rb', line 32 def body[:messages] end |
#result ⇒ Object
16 17 18 |
# File 'lib/rubyflare/response.rb', line 16 def result body[:result].first end |
#results ⇒ Object
20 21 22 |
# File 'lib/rubyflare/response.rb', line 20 def results body[:result] end |
#successful? ⇒ Boolean
24 25 26 |
# File 'lib/rubyflare/response.rb', line 24 def successful? body[:success] end |