Class: Paubox::EmailDisposition
- Inherits:
-
Object
- Object
- Paubox::EmailDisposition
- Defined in:
- lib/paubox/email_disposition.rb
Overview
Parses email dispositions from /v1/message_reciept response to friendly Ruby
Defined Under Namespace
Classes: MessageDelivery, MessageDeliveryStatus, MessageMultiDeliveryStatus, ResponseError
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#message_deliveries ⇒ Object
readonly
Returns the value of attribute message_deliveries.
-
#message_id ⇒ Object
readonly
Returns the value of attribute message_id.
-
#raw_json_response ⇒ Object
readonly
Returns the value of attribute raw_json_response.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#source_tracking_id ⇒ Object
readonly
Returns the value of attribute source_tracking_id.
Instance Method Summary collapse
- #build_errors ⇒ Object
- #errors? ⇒ Boolean
-
#initialize(response) ⇒ EmailDisposition
constructor
A new instance of EmailDisposition.
Constructor Details
#initialize(response) ⇒ EmailDisposition
Returns a new instance of EmailDisposition.
15 16 17 18 19 20 21 22 23 |
# File 'lib/paubox/email_disposition.rb', line 15 def initialize(response) @response = response @raw_json_response = response.to_json @source_tracking_id = response.dig('sourceTrackingId') @message_data = response.dig('data', 'message') @message_id = @message_data ? @message_data['id'] : nil @message_deliveries ||= @errors ||= build_errors end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
7 8 9 |
# File 'lib/paubox/email_disposition.rb', line 7 def errors @errors end |
#message_deliveries ⇒ Object (readonly)
Returns the value of attribute message_deliveries.
7 8 9 |
# File 'lib/paubox/email_disposition.rb', line 7 def @message_deliveries end |
#message_id ⇒ Object (readonly)
Returns the value of attribute message_id.
7 8 9 |
# File 'lib/paubox/email_disposition.rb', line 7 def @message_id end |
#raw_json_response ⇒ Object (readonly)
Returns the value of attribute raw_json_response.
7 8 9 |
# File 'lib/paubox/email_disposition.rb', line 7 def raw_json_response @raw_json_response end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
7 8 9 |
# File 'lib/paubox/email_disposition.rb', line 7 def response @response end |
#source_tracking_id ⇒ Object (readonly)
Returns the value of attribute source_tracking_id.
7 8 9 |
# File 'lib/paubox/email_disposition.rb', line 7 def source_tracking_id @source_tracking_id end |
Instance Method Details
#build_errors ⇒ Object
29 30 31 32 33 34 |
# File 'lib/paubox/email_disposition.rb', line 29 def build_errors return [] unless response['errors'] errors = response['errors'] errors.map { |e| ResponseError.new(e['code'], e['status'], e['title'], e['details']) } end |
#errors? ⇒ Boolean
25 26 27 |
# File 'lib/paubox/email_disposition.rb', line 25 def errors? errors.any? end |