class Boppers::Notifier::Slack

Constants

COLORS

Attributes

api_token[R]
channel[R]
subscribe[R]

Public Class Methods

new(api_token:, channel:, subscribe: nil) click to toggle source
# File lib/boppers/notifier/slack.rb, line 13
def initialize(api_token:, channel:, subscribe: nil)
  @api_token = api_token
  @channel = channel
  @subscribe = subscribe
end

Public Instance Methods

call(subject, message, options) click to toggle source
# File lib/boppers/notifier/slack.rb, line 19
def call(subject, message, options)
  params = {
    token: api_token,
    text: "",
    channel: channel,
    attachments: JSON.dump(
      [
        {
          fallback: message,
          title: subject,
          text: message,
          color: COLORS.fetch(options[:color])
        }
      ]
    )
  }

  HttpClient.post("https://slack.com/api/chat.postMessage", params)
end