Class: Webhooks::Outgoing::Event

Inherits:
ApplicationRecord
  • Object
show all
Includes:
HasUuid
Defined in:
app/models/webhooks/outgoing/event.rb

Instance Method Summary collapse

Methods included from HasUuid

#short_uuid

Instance Method Details

#deliverObject



30
31
32
33
34
35
36
# File 'app/models/webhooks/outgoing/event.rb', line 30

def deliver
  endpoints.each do |endpoint|
    unless endpoint.deliveries.where(event: self).any?
      endpoint.deliveries.create(event: self, endpoint_url: endpoint.url).deliver_async
    end
  end
end

#endpointsObject



26
27
28
# File 'app/models/webhooks/outgoing/event.rb', line 26

def endpoints
  team.webhooks_outgoing_endpoints.listening_for_event_type_id(event_type_id)
end

#event_type_nameObject



22
23
24
# File 'app/models/webhooks/outgoing/event.rb', line 22

def event_type_name
  payload.dig("event_type")
end

#generate_payloadObject



12
13
14
15
16
17
18
19
20
# File 'app/models/webhooks/outgoing/event.rb', line 12

def generate_payload
  {
    event_id: uuid,
    event_type: event_type_id,
    subject_id: subject_id,
    subject_type: subject_type,
    data: data
  }
end

#label_stringObject



38
39
40
# File 'app/models/webhooks/outgoing/event.rb', line 38

def label_string
  short_uuid
end