Class: Whatsapp::MessageTemplates::Button::QuickReply

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

Overview

A tappable label that sends its own text back as a reply.

The most common use is an opt-out ("Unsubscribe from Promos"), which Meta expects on marketing templates. Up to 10 per template, but they must be grouped contiguously — see Component::Buttons. Source: https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/components/

Defined Under Namespace

Modules: Defaults

Constant Summary

Constants inherited from Base

Base::MAX_TEXT_LENGTH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#api_type

Methods included from ValueObject

included

Constructor Details

#initialize(text:) ⇒ QuickReply

Returns a new instance of QuickReply.

Parameters:

  • text (String)

    The button label (max 25 characters). @raise [ActiveModel::ValidationError] if validation fails.



25
26
27
28
29
# File 'lib/ruby/whatsapp/message_templates/button/quick_reply.rb', line 25

def initialize(text:)
  @text = text

  validate!
end

Instance Attribute Details

#textString

Returns:

  • (String)


19
20
21
# File 'lib/ruby/whatsapp/message_templates/button/quick_reply.rb', line 19

def text
  @text
end

Instance Method Details

#serializeHash

Returns The serialized button.

Returns:

  • (Hash)

    The serialized button.



32
33
34
# File 'lib/ruby/whatsapp/message_templates/button/quick_reply.rb', line 32

def serialize
  { type: Defaults::TYPE, text: }
end