Class: SimpleConnect::Responses::MessageDeliverResponse
- Inherits:
-
Object
- Object
- SimpleConnect::Responses::MessageDeliverResponse
- Defined in:
- lib/simple_connect/responses/message_deliver_response.rb
Overview
Wraps the ‘messages.deliver` acknowledgement.
Server returns (200, or 422 when nothing queued):
{ "success": true,
"queued_messages": [{ "message_id":, "recipient":, "status": }],
"errors": [ ... ] }
Partial success is possible — some recipients queued, some rejected —so consumers read both ‘#queued_messages` and `#errors`.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#queued_messages ⇒ Object
readonly
Returns the value of attribute queued_messages.
Instance Method Summary collapse
- #any_queued? ⇒ Boolean
-
#initialize(json) ⇒ MessageDeliverResponse
constructor
A new instance of MessageDeliverResponse.
- #to_h ⇒ Object
Constructor Details
#initialize(json) ⇒ MessageDeliverResponse
Returns a new instance of MessageDeliverResponse.
17 18 19 20 21 |
# File 'lib/simple_connect/responses/message_deliver_response.rb', line 17 def initialize(json) @json = json.is_a?(Hash) ? json : {} @queued_messages = @json["queued_messages"] || [] @errors = @json["errors"] || [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
15 16 17 |
# File 'lib/simple_connect/responses/message_deliver_response.rb', line 15 def errors @errors end |
#queued_messages ⇒ Object (readonly)
Returns the value of attribute queued_messages.
15 16 17 |
# File 'lib/simple_connect/responses/message_deliver_response.rb', line 15 def @queued_messages end |
Instance Method Details
#any_queued? ⇒ Boolean
23 24 25 |
# File 'lib/simple_connect/responses/message_deliver_response.rb', line 23 def any_queued? @queued_messages.any? end |
#to_h ⇒ Object
27 28 29 |
# File 'lib/simple_connect/responses/message_deliver_response.rb', line 27 def to_h @json.dup end |