Class: NineOneOne::SlackService
- Inherits:
-
Object
- Object
- NineOneOne::SlackService
- Defined in:
- lib/nine_one_one/slack_service.rb
Instance Method Summary collapse
-
#initialize(webhook_url, opts = {}) ⇒ SlackService
constructor
A new instance of SlackService.
- #notify(message) ⇒ Object
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() body = request_body() headers = { 'Content-Type' => 'application/json' } http.post(path, body, headers) end |