Class: SimpleConnect::Responses::MessageDetailResponse

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#errorObject (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_groupObject (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
  @message_group
end

#message_idObject (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
  @message_id
end

#recipientObject (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

#statusObject (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

Returns:

  • (Boolean)


25
26
27
# File 'lib/simple_connect/responses/message_detail_response.rb', line 25

def failed?
  !@error.nil?
end

#to_hObject



29
30
31
# File 'lib/simple_connect/responses/message_detail_response.rb', line 29

def to_h
  @json.dup
end