Class: SlackBot::ApiResponse
- Inherits:
-
Object
- Object
- SlackBot::ApiResponse
- Defined in:
- lib/slack_bot/api_client.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #data ⇒ Object
- #error ⇒ Object
-
#initialize(&block) ⇒ ApiResponse
constructor
A new instance of ApiResponse.
- #ok? ⇒ Boolean
Constructor Details
#initialize(&block) ⇒ ApiResponse
Returns a new instance of ApiResponse.
6 7 8 9 |
# File 'lib/slack_bot/api_client.rb', line 6 def initialize(&block) @response = block.call SlackBot::DevConsole.log_output "#{self.class.name}: #{response.body}" end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/slack_bot/api_client.rb', line 5 def response @response end |
Instance Method Details
#data ⇒ Object
19 20 21 |
# File 'lib/slack_bot/api_client.rb', line 19 def data JSON.parse(response.body) end |
#error ⇒ Object
15 16 17 |
# File 'lib/slack_bot/api_client.rb', line 15 def error data["error"] end |
#ok? ⇒ Boolean
11 12 13 |
# File 'lib/slack_bot/api_client.rb', line 11 def ok? response.status == 200 && data["ok"] end |