Sha256: 61b34c14d349cdb1cf01377befa1b0286b685a82fb5872e44a3d4842759d3ce5

Contents?: true

Size: 731 Bytes

Versions: 9

Compression:

Stored size: 731 Bytes

Contents

# frozen_string_literal: true

module SlackMessaging
  class NotifySlack
    attr_accessor :text, :channel, :webhook_url, :username, :icon_url, :icon_emoji

    def initialize(text)
      self.text = text
      self.channel = SlackMessaging::Config.slack[:channel]
      self.webhook_url = SlackMessaging::Config.slack[:webhook_url]
      self.username = SlackMessaging::Config.slack[:username] || 'MessageMe'
      self.icon_emoji = SlackMessaging::Config.slack[:icon_emoji] || ':mailbox_with_mail'
    end

    def perform
      options = {
        channel: channel,
        username: username,
        icon_emoji: icon_emoji,
        text: text
      }

      HTTParty.post(webhook_url, body: options.to_json)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
slack_messaging-3.2.3 lib/slack_messaging/notify_slack.rb
slack_messaging-3.2.2 lib/slack_messaging/notify_slack.rb
slack_messaging-3.2.1 lib/slack_messaging/notify_slack.rb
slack_messaging-3.2.0 lib/slack_messaging/notify_slack.rb
slack_messaging-3.1.3 lib/slack_messaging/notify_slack.rb
slack_messaging-3.1.2 lib/slack_messaging/notify_slack.rb
slack_messaging-3.1.1 lib/slack_messaging/notify_slack.rb
slack_messaging-3.1.0 lib/slack_messaging/notify_slack.rb
slack_messaging-3.0.0 lib/slack_messaging/notify_slack.rb