Class: ForemanWebhooks::DeliverWebhookJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/foreman_webhooks/deliver_webhook_job.rb

Instance Method Summary collapse

Instance Method Details

#humanized_nameObject



22
23
24
25
# File 'app/jobs/foreman_webhooks/deliver_webhook_job.rb', line 22

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
# File 'app/jobs/foreman_webhooks/deliver_webhook_job.rb', line 7

def perform(options)
  webhook = Webhook.unscoped.find_by(id: options[:webhook_id])
  WebhookService.new(
    webhook: webhook,
    headers: options[:headers],
    url: options[:url],
    event_name: options[:event_name],
    payload: options[:payload]
  ).execute
end

#webhook_idObject



18
19
20
# File 'app/jobs/foreman_webhooks/deliver_webhook_job.rb', line 18

def webhook_id
  arguments.first['webhook_id'] unless arguments.first.nil?
end