Class: God::Contacts::Webhook
- Inherits:
-
God::Contact
- Object
- God::Contact
- God::Contacts::Webhook
- Defined in:
- lib/god/contacts/webhook.rb
Instance Attribute Summary collapse
-
#hook_url ⇒ Object
Returns the value of attribute hook_url.
Attributes inherited from God::Contact
Instance Method Summary collapse
Methods inherited from God::Contact
#friendly_name, generate, normalize, valid?
Methods included from God::Configurable
#base_name, complain, #complain, #friendly_name, #prepare, #reset
Instance Attribute Details
#hook_url ⇒ Object
Returns the value of attribute hook_url.
16 17 18 |
# File 'lib/god/contacts/webhook.rb', line 16 def hook_url @hook_url end |
Instance Method Details
#notify(message, time, priority, category, host) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/god/contacts/webhook.rb', line 22 def notify(, time, priority, category, host) begin data = { :message => , :time => time, :priority => priority, :category => category, :host => host } uri = URI.parse(self.hook_url) Net::HTTP.post_form(uri, data) self.info = "sent webhook to #{self.hook_url}" rescue => e puts e. puts e.backtrace.join("\n") self.info = "failed to send webhook to #{self.hook_url}: #{e.}" end end |
#valid? ⇒ Boolean
18 19 20 |
# File 'lib/god/contacts/webhook.rb', line 18 def valid? valid = true end |