Class: Sespool::Bounce
- Inherits:
-
Object
- Object
- Sespool::Bounce
- Defined in:
- lib/sespool/bounce.rb
Defined Under Namespace
Instance Method Summary collapse
- #bounced_recipients ⇒ Object
- #feedback_id ⇒ Object
-
#initialize(raw_data) ⇒ Bounce
constructor
A new instance of Bounce.
- #mail ⇒ Object
- #reporting_mta ⇒ Object
- #sub_type ⇒ Object
- #timestamp ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(raw_data) ⇒ Bounce
Returns a new instance of Bounce.
7 8 9 10 11 |
# File 'lib/sespool/bounce.rb', line 7 def initialize(raw_data) = JSON.parse(JSON.parse(raw_data).fetch('Message')) @_mail_data = .fetch('mail') @_bounce_data = .fetch('bounce') end |
Instance Method Details
#bounced_recipients ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sespool/bounce.rb', line 33 def bounced_recipients @_bounced_recipients ||= @_bounce_data.fetch('bouncedRecipients').map { |recipient| Recipient.new( recipient.fetch('emailAddress'), recipient.fetch('status'), recipient.fetch('diagnosticCode'), recipient.fetch('action') ) } end |
#feedback_id ⇒ Object
25 26 27 |
# File 'lib/sespool/bounce.rb', line 25 def feedback_id @_bounce_data.fetch('feedbackId') end |
#mail ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/sespool/bounce.rb', line 44 def mail @_mail ||= Mail.new( @_mail_data.fetch('timestamp'), @_mail_data.fetch('source'), @_mail_data.fetch('messageId'), @_mail_data.fetch('destination') ) end |
#reporting_mta ⇒ Object
21 22 23 |
# File 'lib/sespool/bounce.rb', line 21 def reporting_mta @_bounce_data.fetch('reportingMTA') end |
#sub_type ⇒ Object
17 18 19 |
# File 'lib/sespool/bounce.rb', line 17 def sub_type @_bounce_data.fetch('bounceSubType') end |
#timestamp ⇒ Object
29 30 31 |
# File 'lib/sespool/bounce.rb', line 29 def Time.parse(@_bounce_data.fetch('timestamp')) end |
#type ⇒ Object
13 14 15 |
# File 'lib/sespool/bounce.rb', line 13 def type @_bounce_data.fetch('bounceType') end |