Class: Whatsapp::MessageTemplates::Button::Url
- Defined in:
- lib/ruby/whatsapp/message_templates/button/url.rb
Overview
Opens a URL in the device's default browser.
May carry a single variable, and only appended at the very end of the URL —
Meta substitutes the send-side value there. Note the example here is a flat
array on the button, unlike the header/body example object built by
Example; that inconsistency is Meta's.
Source: https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/components/
Defined Under Namespace
Modules: Defaults
Constant Summary collapse
- TRAILING_VARIABLE =
Matches a placeholder occupying the very end of the URL.
/\{\{\s*\w+\s*\}\}\z/
Constants inherited from Base
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(text:, url:, example: nil) ⇒ Url
constructor
@raise [ActiveModel::ValidationError] if validation fails.
-
#serialize ⇒ Hash
The serialized button.
Methods inherited from Base
Methods included from ValueObject
Constructor Details
#initialize(text:, url:, example: nil) ⇒ Url
@raise [ActiveModel::ValidationError] if validation fails.
46 47 48 49 50 51 52 |
# File 'lib/ruby/whatsapp/message_templates/button/url.rb', line 46 def initialize(text:, url:, example: nil) @text = text @url = url @example = normalize_example(example) validate! end |
Instance Attribute Details
#example ⇒ Array<String>?
33 34 35 |
# File 'lib/ruby/whatsapp/message_templates/button/url.rb', line 33 def example @example end |
#text ⇒ String
25 26 27 |
# File 'lib/ruby/whatsapp/message_templates/button/url.rb', line 25 def text @text end |
#url ⇒ String
29 30 31 |
# File 'lib/ruby/whatsapp/message_templates/button/url.rb', line 29 def url @url end |