Class: Upcloudify::Notifiers::Slack

Inherits:
Object
  • Object
show all
Defined in:
lib/notifiers/slack.rb

Instance Method Summary collapse

Constructor Details

#initialize(to: nil, url:) ⇒ Slack

Returns a new instance of Slack.



6
7
8
9
# File 'lib/notifiers/slack.rb', line 6

def initialize(to: nil, url:)
  @url = url
  @to = to
end

Instance Method Details

#notify(text: nil) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/notifiers/slack.rb', line 11

def notify(text: nil)
  HTTParty.post(
    @url,
    headers: {"Content-Type" => content_type},
    body: payload.merge(text: text).to_json
  )
end

#payloadObject



19
20
21
# File 'lib/notifiers/slack.rb', line 19

def payload
  { channel: @to }
end