Class: Posthaste::Result
- Inherits:
-
Object
- Object
- Posthaste::Result
- Defined in:
- lib/posthaste/result.rb
Overview
What the API said about one send.
Reachable as mail.posthaste_result after deliver_now, because
ActionMailer's own return value is the Mail::Message and there is nowhere
else to put a message id that a caller needs in order to look the delivery
up later.
Instance Attribute Summary collapse
-
#emails ⇒ Object
readonly
Returns the value of attribute emails.
-
#group_id ⇒ Object
readonly
Returns the value of attribute group_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#mapping_warnings ⇒ Object
readonly
Returns the value of attribute mapping_warnings.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#scheduled_at ⇒ Object
readonly
Returns the value of attribute scheduled_at.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#suppressed ⇒ Object
readonly
Returns the value of attribute suppressed.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
-
#duplicate? ⇒ Boolean
An idempotency replay: no new message was created and
idis the original's. -
#initialize(body, mapping_warnings: []) ⇒ Result
constructor
A new instance of Result.
- #inspect ⇒ Object
- #scheduled? ⇒ Boolean
Constructor Details
#initialize(body, mapping_warnings: []) ⇒ Result
Returns a new instance of Result.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/posthaste/result.rb', line 14 def initialize(body, mapping_warnings: []) @raw = body @id = body['id'] @status = body['status'] @group_id = body['groupId'] @scheduled_at = body['scheduledAt'] # Per-recipient outcome, present only when there was more than one. @emails = body['emails'] || [] # Recipients skipped because they are on the suppression list. Repeated # here as well as inside `emails` deliberately: a recipient we did not # send to is the one outcome that must be impossible to miss. @suppressed = body['suppressed'] || [] # The platform's pre-send lint findings, warnings included. @warnings = body['warnings'] || [] # What this gem had to change to express the message. @mapping_warnings = mapping_warnings end |
Instance Attribute Details
#emails ⇒ Object (readonly)
Returns the value of attribute emails.
11 12 13 |
# File 'lib/posthaste/result.rb', line 11 def emails @emails end |
#group_id ⇒ Object (readonly)
Returns the value of attribute group_id.
11 12 13 |
# File 'lib/posthaste/result.rb', line 11 def group_id @group_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/posthaste/result.rb', line 11 def id @id end |
#mapping_warnings ⇒ Object (readonly)
Returns the value of attribute mapping_warnings.
11 12 13 |
# File 'lib/posthaste/result.rb', line 11 def mapping_warnings @mapping_warnings end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
11 12 13 |
# File 'lib/posthaste/result.rb', line 11 def raw @raw end |
#scheduled_at ⇒ Object (readonly)
Returns the value of attribute scheduled_at.
11 12 13 |
# File 'lib/posthaste/result.rb', line 11 def scheduled_at @scheduled_at end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
11 12 13 |
# File 'lib/posthaste/result.rb', line 11 def status @status end |
#suppressed ⇒ Object (readonly)
Returns the value of attribute suppressed.
11 12 13 |
# File 'lib/posthaste/result.rb', line 11 def suppressed @suppressed end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
11 12 13 |
# File 'lib/posthaste/result.rb', line 11 def warnings @warnings end |
Instance Method Details
#duplicate? ⇒ Boolean
An idempotency replay: no new message was created and id is the
original's.
Read off the BODY, not off a 200-versus-202, because the body is the authoritative answer and survives a proxy that normalises the status.
37 38 39 |
# File 'lib/posthaste/result.rb', line 37 def duplicate? status == 'duplicate' end |
#inspect ⇒ Object
45 46 47 48 |
# File 'lib/posthaste/result.rb', line 45 def inspect "#<Posthaste::Result id=#{id.inspect} status=#{status.inspect} " \ "suppressed=#{suppressed.length} warnings=#{warnings.length}>" end |
#scheduled? ⇒ Boolean
41 42 43 |
# File 'lib/posthaste/result.rb', line 41 def scheduled? status == 'scheduled' end |