class Upcloudify::Notifiers::Slack

Public Class Methods

new(to: nil, url: nil) click to toggle source
# File lib/notifiers/slack.rb, line 8
def initialize(to: nil, url: nil)
  raise ArgumentError "url cannot be nil" unless url
  @url = url
  @to = to
end

Public Instance Methods

notify(text: nil) click to toggle source
# File lib/notifiers/slack.rb, line 14
def notify(text: nil)
  HTTParty.post(
    @url,
    headers: {"Content-Type" => content_type},
    body: payload.merge(text: text).to_json
  )
end
payload() click to toggle source
# File lib/notifiers/slack.rb, line 22
def payload
  { channel: @to }
end

Private Instance Methods

content_type() click to toggle source
# File lib/notifiers/slack.rb, line 28
def content_type
  "application/json"
end