Class: Upkey::Chatterly::Urls::Response
- Inherits:
-
Object
- Object
- Upkey::Chatterly::Urls::Response
- Defined in:
- lib/upkey/chatterly/urls/response.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(chatterly_response) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(chatterly_response) ⇒ Response
Returns a new instance of Response.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/upkey/chatterly/urls/response.rb', line 7 def initialize(chatterly_response) @status = chatterly_response.status case status when 200 @contents = JSON.parse(chatterly_response.body) when 404 @contents = { message: 'Requested URL not found.' } when 422 @contents = { message: JSON.parse(chatterly_response.body) } when 401 @contents = { message: 'You are unauthorized to access this. Please check your access credentials and try again.' } else raise ChatterlyError end end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
5 6 7 |
# File 'lib/upkey/chatterly/urls/response.rb', line 5 def contents @contents end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/upkey/chatterly/urls/response.rb', line 5 def status @status end |