Class: SimpleConnect::Responses::MessageDetailResponse
- Inherits:
-
Object
- Object
- SimpleConnect::Responses::MessageDetailResponse
- Defined in:
- lib/simple_connect/responses/message_detail_response.rb
Overview
Wraps the ‘messages.detail` lookup (GET /api/v1/whatsapp_messages/:id).
Server returns:
{ "message_id":, "status":, "message_group":, "recipient": }
plus, only when the message failed:
"error": { "message":, "data": }
‘#error` is nil unless the message failed; `#failed?` reflects that.
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#message_group ⇒ Object
readonly
Returns the value of attribute message_group.
-
#message_id ⇒ Object
readonly
Returns the value of attribute message_id.
-
#recipient ⇒ Object
readonly
Returns the value of attribute recipient.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #failed? ⇒ Boolean
-
#initialize(json) ⇒ MessageDetailResponse
constructor
A new instance of MessageDetailResponse.
- #to_h ⇒ Object
Constructor Details
#initialize(json) ⇒ MessageDetailResponse
Returns a new instance of MessageDetailResponse.
16 17 18 19 20 21 22 23 |
# File 'lib/simple_connect/responses/message_detail_response.rb', line 16 def initialize(json) @json = json.is_a?(Hash) ? json : {} @message_id = @json["message_id"] @status = @json["status"] @recipient = @json["recipient"] @message_group = @json["message_group"] @error = @json["error"] end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
14 15 16 |
# File 'lib/simple_connect/responses/message_detail_response.rb', line 14 def error @error end |
#message_group ⇒ Object (readonly)
Returns the value of attribute message_group.
14 15 16 |
# File 'lib/simple_connect/responses/message_detail_response.rb', line 14 def @message_group end |
#message_id ⇒ Object (readonly)
Returns the value of attribute message_id.
14 15 16 |
# File 'lib/simple_connect/responses/message_detail_response.rb', line 14 def @message_id end |
#recipient ⇒ Object (readonly)
Returns the value of attribute recipient.
14 15 16 |
# File 'lib/simple_connect/responses/message_detail_response.rb', line 14 def recipient @recipient end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
14 15 16 |
# File 'lib/simple_connect/responses/message_detail_response.rb', line 14 def status @status end |
Instance Method Details
#failed? ⇒ Boolean
25 26 27 |
# File 'lib/simple_connect/responses/message_detail_response.rb', line 25 def failed? !@error.nil? end |
#to_h ⇒ Object
29 30 31 |
# File 'lib/simple_connect/responses/message_detail_response.rb', line 29 def to_h @json.dup end |