Class: OmniEvent::WebhookEvent

Inherits:
ApplicationRecord show all
Defined in:
app/models/omni_event/webhook_event.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_from_request!(notifier, request) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'app/models/omni_event/webhook_event.rb', line 17

def self.create_from_request!(notifier, request)
  create!(
    webhook_notifier: notifier,
    headers: request.headers.to_h.select { |k, _| k == k.upcase },
    payload: request.request_parameters.presence ||
             request.query_parameters.presence   ||
             request.raw_post
  )
end

Instance Method Details

#dispatch!Object



27
28
29
30
31
32
33
# File 'app/models/omni_event/webhook_event.rb', line 27

def dispatch!
  if OmniEvent.configuration.process_async
    OmniEvent::ProcessWebhookJob.perform_later(id)
  else
    OmniEvent::ProcessDispatcher.call(self)
  end
end