lib/smart_todo/slack_client.rb
# Chech if the response to Slack was a 200 and the Slack API request was successful
#
# @param response [Net::HTTPResponse] a net Net::HTTPResponse subclass
#   (Net::HTTPOK, Net::HTTPNotFound ...)
# @return [Hash]
#
# @raise [Net::HTTPError] in case the request to Slack failed
# @raise [SlackClient::Error] in case Slack returns a { ok: false } in the body
Chech if the response to Slack was a 200 and the Slack API request was successful
Chech if the response to Slack was a 200 and the Slack API request was successful
def slack_response!(response)
      raise(Net::HTTPError.new("Request to slack failed", response)) unless response.code_type < Net::HTTPSuccess
      body = JSON.parse(response.body)
      if body["ok"]
        body
      else
        raise(Error, body)
      end
    end
def slack_response! ( response ) raise ( Net :: HTTPError . new ( "Request to slack failed" , response ) ) unless response . code_type < Net :: HTTPSuccess body = JSON . parse ( response . body ) if body [ "ok" ] body else raise ( Error , body ) end end
Chech if the response to Slack was a 200 and the Slack API request was successful
Chech if the response to Slack was a 200 and the Slack API request was successful
None
Hash
[Net::HTTPError] in case the request to Slack failed
[ Net :: HTTPError ] in case the request to Slack failed
[SlackClient::Error] in case Slack returns a { ok: false } in the body
[ SlackClient :: Error ] in case Slack returns a { ok : false } in the body
response
None