Class: ForemanWebhooks::DeliverWebhookJob
- Inherits:
-
ApplicationJob
- Object
- ApplicationJob
- ForemanWebhooks::DeliverWebhookJob
- Defined in:
- app/jobs/foreman_webhooks/deliver_webhook_job.rb
Instance Method Summary collapse
Instance Method Details
#humanized_name ⇒ Object
34 35 36 37 |
# File 'app/jobs/foreman_webhooks/deliver_webhook_job.rb', line 34 def humanized_name webhook = webhook_id && Webhook.unscoped.find_by(id: webhook_id) (webhook && (_('Deliver webhook %s') % webhook.name)) || _('Deliver webhook') end |
#perform(options) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/jobs/foreman_webhooks/deliver_webhook_job.rb', line 7 def perform() webhook = Webhook.unscoped.find_by(id: [:webhook_id]) result = WebhookService.new( webhook: webhook, headers: [:headers], url: [:url], event_name: [:event_name], payload: [:payload] ).execute return unless result[:status] == :error raise [result[:http_status], result[:message]].compact.join(': ') end |
#webhook_id ⇒ Object
30 31 32 |
# File 'app/jobs/foreman_webhooks/deliver_webhook_job.rb', line 30 def webhook_id arguments.first['webhook_id'] unless arguments.first.nil? end |