Module: Slack
- Defined in:
- lib/slack/error.rb,
lib/slack/web.rb,
lib/slack/client.rb,
lib/slack/web/im.rb,
lib/slack/request.rb,
lib/slack/session.rb,
lib/slack/version.rb,
lib/slack/web/api.rb,
lib/slack/web/auth.rb,
lib/slack/web/chat.rb,
lib/slack/web/pins.rb,
lib/slack/web/team.rb,
lib/slack/web/emoji.rb,
lib/slack/web/files.rb,
lib/slack/web/stars.rb,
lib/slack/web/users.rb,
lib/slack/web/groups.rb,
lib/slack/web/search.rb,
lib/slack-api-wrapper.rb,
lib/slack/web/channels.rb,
lib/slack/web/reactions.rb
Overview
Copyright (c) 2015 Gustavo Bazan MIT License
Defined Under Namespace
Modules: Request, Web Classes: Client, Error, Session
Constant Summary collapse
- VERSION =
The current version of the wrapper.
'0.2.0'.freeze
- WEB_SERVER =
Slack url
'slack.com'
Class Method Summary collapse
-
.parse_response(response, raw = false) ⇒ Object
Parse response.
Class Method Details
.parse_response(response, raw = false) ⇒ Object
Parse response. You probably shouldn't be calling this directly. This takes responses from the server and parses them. It also checks for errors and raises exceptions with the appropriate messages.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/slack-api-wrapper.rb', line 30 def self.parse_response(response, raw = false) if response.is_a?(Net::HTTPServerError) fail Slack::Error.new("Slack Server Error: #{response} - #{response.body}", response) end return response.body if raw d = JSON.parse(response.body) fail Slack::Error.new(d['error'], response) if d['error'] return d rescue JSON::ParserError raise Slack::Error.new("Unable to parse JSON response: #{response.body}", response) end |