Class: EmailEvents::Adapters::Sendgrid::EventData
- Inherits:
-
Abstract::EventData
- Object
- Abstract::EventData
- EmailEvents::Adapters::Sendgrid::EventData
- Defined in:
- lib/email_events/adapters/sendgrid/event_data.rb
Instance Method Summary collapse
- #event_timestamp ⇒ Object
- #event_type ⇒ Object
-
#initialize(sendgrid_data) ⇒ EventData
constructor
A new instance of EventData.
- #provider_message_id ⇒ Object
- #raw_data ⇒ Object
- #reason ⇒ Object
- #recipients ⇒ Object
- #smtp_message_id ⇒ Object
- #smtp_status_code ⇒ Object
Methods inherited from Abstract::EventData
Constructor Details
#initialize(sendgrid_data) ⇒ EventData
Returns a new instance of EventData.
4 5 6 7 8 9 |
# File 'lib/email_events/adapters/sendgrid/event_data.rb', line 4 def initialize(sendgrid_data) @sendgrid_data = sendgrid_data raise "Unrecognized Sendgrid event type" unless event_type.in?([:delivered, :bounce, :dropped, :deferred, :processed, :click, :open, :spamreport, :group_unsubscribe, :group_resubscribe]) end |
Instance Method Details
#event_timestamp ⇒ Object
15 16 17 18 |
# File 'lib/email_events/adapters/sendgrid/event_data.rb', line 15 def return nil if @sendgrid_data.nil? Time.at @sendgrid_data['timestamp'] end |
#event_type ⇒ Object
11 12 13 |
# File 'lib/email_events/adapters/sendgrid/event_data.rb', line 11 def event_type @sendgrid_data['event'].to_sym end |
#provider_message_id ⇒ Object
39 40 41 42 |
# File 'lib/email_events/adapters/sendgrid/event_data.rb', line 39 def return nil if @sendgrid_data['sg_message_id'].nil? @sendgrid_data['sg_message_id'].gsub(/\.filter.*/,'') end |
#raw_data ⇒ Object
44 45 46 |
# File 'lib/email_events/adapters/sendgrid/event_data.rb', line 44 def raw_data @sendgrid_data end |
#reason ⇒ Object
31 32 33 |
# File 'lib/email_events/adapters/sendgrid/event_data.rb', line 31 def reason @sendgrid_data[:reason] end |
#recipients ⇒ Object
20 21 22 23 |
# File 'lib/email_events/adapters/sendgrid/event_data.rb', line 20 def recipients return nil if @sendgrid_data.nil? [@sendgrid_data['email']] end |
#smtp_message_id ⇒ Object
35 36 37 |
# File 'lib/email_events/adapters/sendgrid/event_data.rb', line 35 def @sendgrid_data['smtp-id'] end |
#smtp_status_code ⇒ Object
25 26 27 28 29 |
# File 'lib/email_events/adapters/sendgrid/event_data.rb', line 25 def smtp_status_code return nil if @sendgrid_data[:status].blank? @sendgrid_data[:status].gsub(/\./,'').to_i end |