Class: Whatsapp::MessageTemplates::Button::CopyCode
- Defined in:
- lib/ruby/whatsapp/message_templates/button/copy_code.rb
Overview
Copies a string — typically a coupon code — to the recipient's clipboard.
Two things are unusual about this button: it carries no text, because Meta
supplies and localises the label itself; and its example is a bare string
rather than an array. At most one per template.
In a limited-time-offer template the example is capped at 15 characters rather than 20, and the button must sit at index 0 — both enforced by Template, which is the only place that can see the sibling components. Source: https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/components/
Defined Under Namespace
Modules: Defaults
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
- #example ⇒ String
-
#text ⇒ nil
Always nil.
Instance Method Summary collapse
-
#initialize(example:, text: nil) ⇒ CopyCode
constructor
A new instance of CopyCode.
-
#serialize ⇒ Hash
The serialized button.
Methods inherited from Base
Methods included from ValueObject
Constructor Details
#initialize(example:, text: nil) ⇒ CopyCode
Returns a new instance of CopyCode.
38 39 40 41 42 43 |
# File 'lib/ruby/whatsapp/message_templates/button/copy_code.rb', line 38 def initialize(example:, text: nil) @example = example @text = text validate! end |
Instance Attribute Details
#example ⇒ String
24 25 26 |
# File 'lib/ruby/whatsapp/message_templates/button/copy_code.rb', line 24 def example @example end |
#text ⇒ nil
Always nil. Accepted only so a caller who supplies one gets told why it is not allowed, rather than an opaque ArgumentError.
30 31 32 |
# File 'lib/ruby/whatsapp/message_templates/button/copy_code.rb', line 30 def text @text end |