Sha256: 8c3606d6af63413c0858d6b74d56f34ff97bf9cca01890ad421df43b54ac32ac

Contents?: true

Size: 784 Bytes

Versions: 2

Compression:

Stored size: 784 Bytes

Contents

# frozen_string_literal: true

module Boppers
  module Notifier
    class Slack
      attr_reader :api_token, :channel, :subscribe

      def initialize(api_token:, channel:, subscribe: nil)
        @api_token = api_token
        @channel = channel
        @subscribe = subscribe
      end

      def call(subject, message, options)
        params = {
          token: api_token,
          text: "",
          channel: channel,
          attachments: JSON.dump(
            [
              {
                fallback: message,
                title: subject,
                text: message,
                color: options[:color]
              }
            ]
          )
        }

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
boppers-0.0.2 lib/boppers/notifier/slack.rb
boppers-0.0.1 lib/boppers/notifier/slack.rb