Method: Blazer::SlackNotifier.post

Defined in:
lib/blazer/slack_notifier.rb

.post(payload) ⇒ Object

TODO use return value



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/blazer/slack_notifier.rb', line 71

def self.post(payload)
  if Blazer.slack_webhook_url.present?
    response = post_api(Blazer.slack_webhook_url, payload, {})
    response.is_a?(Net::HTTPSuccess) && response.body == "ok"
  else
    headers = {
      "Authorization" => "Bearer #{Blazer.slack_oauth_token}",
      "Content-type" => "application/json"
    }
    response = post_api("https://slack.com/api/chat.postMessage", payload, headers)
    response.is_a?(Net::HTTPSuccess) && (JSON.parse(response.body)["ok"] rescue false)
  end
end