Class: SidekiqVigil::Notifier::Webhook
- Defined in:
- lib/sidekiq_vigil/notifier/webhook.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(options: {}, logger: SidekiqVigil.logger, transport: HttpTransport.new) ⇒ Webhook
constructor
A new instance of Webhook.
- #notify(event) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(options: {}, logger: SidekiqVigil.logger, transport: HttpTransport.new) ⇒ Webhook
Returns a new instance of Webhook.
8 9 10 11 |
# File 'lib/sidekiq_vigil/notifier/webhook.rb', line 8 def initialize(options: {}, logger: SidekiqVigil.logger, transport: HttpTransport.new) super(options:, logger:) @transport = transport end |
Instance Method Details
#notify(event) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/sidekiq_vigil/notifier/webhook.rb', line 13 def notify(event) response = transport.post(.fetch(:url), JSON.generate(event.to_h), headers: .fetch(:headers, {})) raise Error, "webhook returned HTTP #{response.code}" unless response.success? true end |