Class: SlackNotify::Client

Inherits:
Object
  • Object
show all
Includes:
Connection
Defined in:
lib/slack-notify/client.rb

Instance Method Summary collapse

Methods included from Connection

#base_url, #handle_response, #hook_url, #send_payload

Constructor Details

#initialize(team, token, options = {}) ⇒ Client



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/slack-notify/client.rb', line 8

def initialize(team, token, options = {})
  @team       = team
  @token      = token
  @username   = options[:username]
  @channel    = options[:channel]
  @icon_url   = options[:icon_url]
  @icon_emoji = options[:icon_emoji]
  @link_names = options[:link_names]

  validate_arguments
end

Instance Method Details

#notify(text, channel = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/slack-notify/client.rb', line 24

def notify(text, channel = nil)
  delivery_channels(channel).each do |chan|
    payload = SlackNotify::Payload.new(
      text:       text,
      channel:    chan,
      username:   @username,
      icon_url:   @icon_url,
      icon_emoji: @icon_emoji,
      link_names: @link_names
    )

    send_payload(payload)
  end

  true
end

#testObject



20
21
22
# File 'lib/slack-notify/client.rb', line 20

def test
  notify("Test Message")
end