Class: Upcloudify::Notifiers::Slack
- Inherits:
-
Object
- Object
- Upcloudify::Notifiers::Slack
- Defined in:
- lib/notifiers/slack.rb
Instance Method Summary collapse
-
#initialize(to: nil, url: nil) ⇒ Slack
constructor
A new instance of Slack.
- #notify(text: nil) ⇒ Object
- #payload ⇒ Object
Constructor Details
#initialize(to: nil, url: nil) ⇒ Slack
Returns a new instance of Slack.
8 9 10 11 12 |
# 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 |
Instance Method Details
#notify(text: nil) ⇒ Object
14 15 16 17 18 19 20 |
# 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 ⇒ Object
22 23 24 |
# File 'lib/notifiers/slack.rb', line 22 def payload { channel: @to } end |