Class: NineOneOne::SlackService

Inherits:
Object
  • Object
show all
Defined in:
lib/nine_one_one/slack_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(webhook_url, opts = {}) ⇒ SlackService

Returns a new instance of SlackService.



3
4
5
6
7
8
9
10
# File 'lib/nine_one_one/slack_service.rb', line 3

def initialize(webhook_url, opts = {})
  uri = URI(webhook_url)

  @channel = opts[:channel]
  @http = opts[:http] || Http.new(uri.host, uri.scheme)
  @path = uri.path
  @username = opts[:username]
end

Instance Method Details

#notify(message) ⇒ Object



12
13
14
15
16
# File 'lib/nine_one_one/slack_service.rb', line 12

def notify(message)
  body = request_body(message)
  headers = { 'Content-Type' => 'application/json' }
  http.post(path, body, headers)
end