Class: Integral::Webhook::DeliveryJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/integral/webhook/delivery_job.rb

Overview

Handles the delivery of a webhook event payload to a webhook endpoint

Instance Method Summary collapse

Instance Method Details

#perform(endpoint_id, payload) ⇒ Object

Delivers webhook payload to endpoint



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/jobs/integral/webhook/delivery_job.rb', line 8

def perform(endpoint_id, payload)
  return unless endpoint = Webhook::Endpoint.find(endpoint_id)

  response = request(endpoint.target_url, payload)

  case response.code
  when 410
    endpoint.destroy
  when 400..599
    raise response.to_s
  end
end