Class: WebhookEvent

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

Overview

== Schema Information

Table name: webhook_events
Database name: primary

id :integer not null, primary key
attempt :string
bounce_type :string
category :string is an Array
email :string
event :string
ip :string
reason :string
response :string
sg_machine_open :boolean
status :string
string :string
timestamp :datetime
url :string
useragent :string
created_at :datetime not null
updated_at :datetime not null
asm_group_id :string
communication_recipient_id :integer
creator_id :integer
sg_event_id :string
sg_message_id :string
smtp_id :string
unique_id :string
updater_id :integer

Indexes

index_webhook_events_on_created_at (created_at) USING brin

Constant Summary collapse

EVENTS =

Events.

{
  "processed" => "Message has been received and is ready to be delivered",
  "deferred" => "Recipient's email server temporarily rejected message",
  "delivered" => "Message has been successfully delivered",
  "opened" => "Recipient has opened the message",
  "clicked" => "Recipient clicked on a link within the message",
  "bounced" => "Receiving server could not or would not accept message, see individual email for bounce reason",
  "dropped" => "Message rejected by email server before attempting delivery, see individual email for drop reason",
  "spammed" => "Recipient marked message as spam",
  "unsubscribed" => "Recipient clicked on message's unsubscribe link"
}.freeze

Constants included from Schedulable

Schedulable::SIMPLE_FORM_OPTIONS

Belongs to collapse

Class Method Summary collapse

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Class Method Details

.with_customerActiveRecord::Relation<WebhookEvent>

A relation of WebhookEvents that are with customer. Active Record Scope

Returns:

See Also:



53
54
55
56
57
58
# File 'app/models/webhook_event.rb', line 53

scope :with_customer, -> {
  joins("left join subscribers on subscribers.id = campaign_deliveries.subscriber_id
left outer JOIN contact_points on contact_points.id = (select max(id) from contact_points where contact_points.detail = subscribers.email_address)
left outer JOIN parties contacts on contacts.id = contact_points.party_id and contacts.type = 'Contact'
left outer JOIN parties customers on customers.id = coalesce(contacts.customer_id, contact_points.party_id)")
}

Instance Method Details

#communication_recipientCommunicationRecipient



51
# File 'app/models/webhook_event.rb', line 51

belongs_to :communication_recipient, optional: true