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

Returns a new instance of Client.



8
9
10
11
12
13
14
15
16
17
# 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]

  validate_arguments
end

Instance Method Details

#notify(text, channel = nil) ⇒ Object



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

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
    )

    send_payload(payload)
  end

  true
end

#testObject



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

def test
  notify("Test Message")
end