Class: Sendly::WhatsAppMessageDetails
- Inherits:
-
Object
- Object
- Sendly::WhatsAppMessageDetails
- Defined in:
- lib/sendly/whatsapp_resource.rb
Overview
WhatsApp-specific details on a sent message. kind is what was sent
("text", "media", or "template"); template carries the sent
template's name, language, and billed category on template sends;
message_id is the WhatsApp message id, nil until the first delivery
report lands.
Constant Summary collapse
- KINDS =
%w[text media template].freeze
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#message_id ⇒ Object
readonly
Returns the value of attribute message_id.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
-
#initialize(data) ⇒ WhatsAppMessageDetails
constructor
A new instance of WhatsAppMessageDetails.
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ WhatsAppMessageDetails
Returns a new instance of WhatsAppMessageDetails.
234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/sendly/whatsapp_resource.rb', line 234 def initialize(data) @kind = data["kind"] if data["template"] @template = { name: data.dig("template", "name"), language: data.dig("template", "language"), category: data.dig("template", "category") } end @message_id = data["messageId"] || data["message_id"] end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
230 231 232 |
# File 'lib/sendly/whatsapp_resource.rb', line 230 def kind @kind end |
#message_id ⇒ Object (readonly)
Returns the value of attribute message_id.
230 231 232 |
# File 'lib/sendly/whatsapp_resource.rb', line 230 def @message_id end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
230 231 232 |
# File 'lib/sendly/whatsapp_resource.rb', line 230 def template @template end |
Instance Method Details
#to_h ⇒ Object
246 247 248 |
# File 'lib/sendly/whatsapp_resource.rb', line 246 def to_h { kind: kind, template: template, message_id: }.compact end |