Class: HeyYou::Channels::Slack

Inherits:
Base
  • Object
show all
Defined in:
lib/hey_you/channels/slack.rb

Defined Under Namespace

Classes: WebhookError

Constant Summary collapse

WEBHOOK_ERR_MSG_TMPL =
"slack webhook `%{key}` was not configured".freeze

Class Method Summary collapse

Class Method Details

.send!(builder, **options) ⇒ Object

Parameters:

  • builder (HeyYou::Builder)
    • builder with notifications texts and settings

  • [String/Symbol] (Hash)

    a customizable set of options

Raises:

  • (CredentialsNotExists)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/hey_you/channels/slack.rb', line 12

def send!(builder, **options)
  raise CredentialsNotExists unless credentials_present?

  if options[:to]&.is_a?(String) || options[:to]&.is_a?(Symbol)
    return send_to_webhook(builder, **options)
  end

  if builder.slack&.webhook_name
    options.delete(:to)
    return send_to_webhook(builder, **options)
  end

  send_to_multiple_webhooks(builder, **options)
end