Class: Whatsapp::Webhook::Message::Button

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby/whatsapp/webhook/message/button.rb

Overview

An inbound tap on a template's quick-reply button.

Instance Attribute Summary collapse

Attributes inherited from Base

#context, #from, #id, #referral, #timestamp, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

common_attributes

Constructor Details

#initialize(text:, payload:, **base_attributes) ⇒ Button

Returns a new instance of Button.



16
17
18
19
20
21
# File 'lib/ruby/whatsapp/webhook/message/button.rb', line 16

def initialize(text:, payload:, **base_attributes)
  super(**base_attributes)

  @text = text
  @payload = payload
end

Instance Attribute Details

#payloadString?

Returns The developer-defined payload configured on the template button.

Returns:

  • (String, nil)

    The developer-defined payload configured on the template button.



14
15
16
# File 'lib/ruby/whatsapp/webhook/message/button.rb', line 14

def payload
  @payload
end

#textString?

Returns The button's display text.

Returns:

  • (String, nil)

    The button's display text.



10
11
12
# File 'lib/ruby/whatsapp/webhook/message/button.rb', line 10

def text
  @text
end

Class Method Details

.deserialize(data) ⇒ Button

Parameters:

  • data (Hash)

    The raw message hash.

Returns:



26
27
28
# File 'lib/ruby/whatsapp/webhook/message/button.rb', line 26

def deserialize(data)
  new(text: data.dig("button", "text"), payload: data.dig("button", "payload"), **common_attributes(data))
end