Class: Whatsapp::Webhook::Message::Interactive
- Defined in:
- lib/ruby/whatsapp/webhook/message/interactive.rb
Overview
An inbound reply to an interactive message — a button tap (button_reply)
or a list row selection (list_reply).
Instance Attribute Summary collapse
-
#description ⇒ String?
Only present for
list_reply. -
#interactive_type ⇒ String?
Either
"button_reply"or"list_reply". -
#reply_id ⇒ String?
The id of the tapped button/row.
- #title ⇒ String?
Attributes inherited from Base
#context, #from, #id, #referral, #timestamp, #type
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(interactive_type:, reply_id:, title:, description: nil, **base_attributes) ⇒ Interactive
constructor
A new instance of Interactive.
Methods inherited from Base
Constructor Details
#initialize(interactive_type:, reply_id:, title:, description: nil, **base_attributes) ⇒ Interactive
Returns a new instance of Interactive.
25 26 27 28 29 30 31 32 |
# File 'lib/ruby/whatsapp/webhook/message/interactive.rb', line 25 def initialize(interactive_type:, reply_id:, title:, description: nil, **base_attributes) super(**base_attributes) @interactive_type = interactive_type @reply_id = reply_id @title = title @description = description end |
Instance Attribute Details
#description ⇒ String?
Returns Only present for list_reply.
23 24 25 |
# File 'lib/ruby/whatsapp/webhook/message/interactive.rb', line 23 def description @description end |
#interactive_type ⇒ String?
Returns Either "button_reply" or "list_reply".
11 12 13 |
# File 'lib/ruby/whatsapp/webhook/message/interactive.rb', line 11 def interactive_type @interactive_type end |
#reply_id ⇒ String?
Returns The id of the tapped button/row.
15 16 17 |
# File 'lib/ruby/whatsapp/webhook/message/interactive.rb', line 15 def reply_id @reply_id end |
#title ⇒ String?
19 20 21 |
# File 'lib/ruby/whatsapp/webhook/message/interactive.rb', line 19 def title @title end |
Class Method Details
.deserialize(data) ⇒ Interactive
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ruby/whatsapp/webhook/message/interactive.rb', line 37 def deserialize(data) interactive_type = data.dig("interactive", "type") reply = data.dig("interactive", interactive_type) || {} new( interactive_type:, reply_id: reply["id"], title: reply["title"], description: reply["description"], **common_attributes(data) ) end |