Class: EmailEvents::Adapters::Ses::EventData
- Inherits:
-
Abstract::EventData
- Object
- Abstract::EventData
- EmailEvents::Adapters::Ses::EventData
- Defined in:
- lib/email_events/adapters/ses/event_data.rb
Instance Method Summary collapse
- #event_timestamp ⇒ Object
- #event_type ⇒ Object
-
#initialize(raw_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(raw_data) ⇒ EventData
Returns a new instance of EventData.
4 5 6 7 8 |
# File 'lib/email_events/adapters/ses/event_data.rb', line 4 def initialize(raw_data) @sns_data = JSON.parse raw_data['Message'] raise "Unrecognized SES event type" if event_type.nil? end |
Instance Method Details
#event_timestamp ⇒ Object
23 24 25 |
# File 'lib/email_events/adapters/ses/event_data.rb', line 23 def Time.parse @sns_data['mail']['timestamp'] end |
#event_type ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/email_events/adapters/ses/event_data.rb', line 10 def event_type case @sns_data['notificationType'] when 'Bounce' :bounce when 'Complaint' :spamreport when 'Delivery' :delivered else nil end end |
#provider_message_id ⇒ Object
53 54 55 |
# File 'lib/email_events/adapters/ses/event_data.rb', line 53 def @sns_data['mail']['messageId'] end |
#raw_data ⇒ Object
57 58 59 |
# File 'lib/email_events/adapters/ses/event_data.rb', line 57 def raw_data @sns_data end |
#reason ⇒ Object
41 42 43 44 45 46 |
# File 'lib/email_events/adapters/ses/event_data.rb', line 41 def reason # only supported for bounce events return nil unless event_type == :bounce @sns_data['bounce']['bounceSubType'] end |
#recipients ⇒ Object
27 28 29 |
# File 'lib/email_events/adapters/ses/event_data.rb', line 27 def recipients @sns_data['mail']['destination'] end |
#smtp_message_id ⇒ Object
48 49 50 51 |
# File 'lib/email_events/adapters/ses/event_data.rb', line 48 def # not supported by SNS nil end |
#smtp_status_code ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/email_events/adapters/ses/event_data.rb', line 31 def smtp_status_code # only supported for bounce events return nil unless event_type == :bounce status_code_str = @sns_data['bounce']['bouncedRecipients'].last['status'] return nil if status_code_str.nil? status_code_str.gsub(/\./,'').to_i end |