Class: Whatsapp::MessageTemplates::Component::Buttons
- Defined in:
- lib/ruby/whatsapp/message_templates/component/buttons.rb
Overview
The container for a template's tappable buttons. At most one per template, holding up to 10 buttons.
Note the asymmetry with the send side: here every button lives inside this one
component, whereas sending a template emits one button component per button,
addressed by a zero-based index that follows the order declared here. That is
why #serialize preserves the caller's order exactly.
Source: https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/components/
Defined Under Namespace
Modules: Defaults
Constant Summary collapse
- MAX_PER_TYPE =
Documented per-type caps. Only the limits Meta actually publishes are enforced; OTP is deliberately uncapped here (the overall MAX_BUTTONS still applies) because no per-type limit is stated for it.
{ Button::QuickReply::Defaults::TYPE => 10, Button::Url::Defaults::TYPE => 2, Button::PhoneNumber::Defaults::TYPE => 1, Button::CopyCode::Defaults::TYPE => 1, }.freeze
Instance Attribute Summary collapse
Attributes inherited from Base
#example_error, #parameter_format
Instance Method Summary collapse
-
#api_types ⇒ Array<String>
The wire types in declared order.
-
#initialize(buttons: []) ⇒ Buttons
constructor
A new instance of Buttons.
-
#serialize ⇒ Hash
The serialized component.
Methods inherited from Base
Methods included from ValueObject
Constructor Details
#initialize(buttons: []) ⇒ Buttons
Returns a new instance of Buttons.
41 42 43 44 45 46 47 |
# File 'lib/ruby/whatsapp/message_templates/component/buttons.rb', line 41 def initialize(buttons: [], **) super(**) @buttons = () validate! end |
Instance Attribute Details
#buttons ⇒ Array<Button::Base>
32 33 34 |
# File 'lib/ruby/whatsapp/message_templates/component/buttons.rb', line 32 def @buttons end |
Instance Method Details
#api_types ⇒ Array<String>
52 53 54 |
# File 'lib/ruby/whatsapp/message_templates/component/buttons.rb', line 52 def api_types .map(&:api_type) end |