Class: AfTalk::Response
- Inherits:
-
Object
- Object
- AfTalk::Response
- Defined in:
- lib/aftalk/response.rb
Direct Known Subclasses
Constant Summary collapse
- SUCCESS_STATUSES =
[200, 201].freeze
- JSON_CONTENT =
/\bjson$/
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#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 13 14 15 16 17 18 |
# File 'lib/aftalk/response.rb', line 8 def initialize(response) @status = response.status body = response.body if success? @body = body else @error_message = body @body = { error: body } end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/aftalk/response.rb', line 6 def body @body end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
6 7 8 |
# File 'lib/aftalk/response.rb', line 6 def @error_message end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/aftalk/response.rb', line 6 def status @status end |