Class: Tosuto::API::Response
- Inherits:
-
Object
- Object
- Tosuto::API::Response
- Extended by:
- Forwardable
- Defined in:
- lib/tosuto/api.rb
Instance Attribute Summary collapse
-
#original ⇒ Object
readonly
Returns the value of attribute original.
Instance Method Summary collapse
- #error ⇒ Object
-
#initialize(obj) ⇒ Response
constructor
A new instance of Response.
- #json_body ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(obj) ⇒ Response
Returns a new instance of Response.
28 29 30 |
# File 'lib/tosuto/api.rb', line 28 def initialize(obj) @original = obj end |
Instance Attribute Details
#original ⇒ Object (readonly)
Returns the value of attribute original.
25 26 27 |
# File 'lib/tosuto/api.rb', line 25 def original @original end |
Instance Method Details
#error ⇒ Object
40 41 42 |
# File 'lib/tosuto/api.rb', line 40 def error API::Error.new(response: self) unless success? end |
#json_body ⇒ Object
32 33 34 |
# File 'lib/tosuto/api.rb', line 32 def json_body @json_body ||= JSON.parse(body) end |
#success? ⇒ Boolean
36 37 38 |
# File 'lib/tosuto/api.rb', line 36 def success? original.is_a?(Net::HTTPSuccess) end |