Class: Webhooks::Outgoing::Event
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Webhooks::Outgoing::Event
- Includes:
- HasUuid
- Defined in:
- app/models/webhooks/outgoing/event.rb
Instance Method Summary collapse
- #deliver ⇒ Object
- #endpoints ⇒ Object
- #event_type_name ⇒ Object
- #generate_payload ⇒ Object
- #label_string ⇒ Object
Methods included from HasUuid
Instance Method Details
#deliver ⇒ Object
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 |
#endpoints ⇒ Object
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_name ⇒ Object
22 23 24 |
# File 'app/models/webhooks/outgoing/event.rb', line 22 def event_type_name payload.dig("event_type") end |
#generate_payload ⇒ Object
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_string ⇒ Object
38 39 40 |
# File 'app/models/webhooks/outgoing/event.rb', line 38 def label_string short_uuid end |