Class: MessageQuickly::Messaging::ButtonTemplateAttachment
- Inherits:
-
TemplateAttachment
- Object
- Base
- Attachment
- TemplateAttachment
- MessageQuickly::Messaging::ButtonTemplateAttachment
- Defined in:
- lib/message_quickly/messaging/button_template_attachment.rb
Instance Attribute Summary collapse
-
#buttons ⇒ Object
Returns the value of attribute buttons.
-
#text ⇒ Object
Returns the value of attribute text.
Attributes inherited from TemplateAttachment
Attributes inherited from Attachment
Instance Method Summary collapse
- #build_button(button_type) ⇒ Object
-
#initialize(params = {}) ⇒ ButtonTemplateAttachment
constructor
A new instance of ButtonTemplateAttachment.
- #to_hash ⇒ Object
Methods inherited from Attachment
Constructor Details
#initialize(params = {}) ⇒ ButtonTemplateAttachment
Returns a new instance of ButtonTemplateAttachment.
7 8 9 10 11 |
# File 'lib/message_quickly/messaging/button_template_attachment.rb', line 7 def initialize(params = {}) self. ||= [] params['template_type'] ||= 'button' super(params) end |
Instance Attribute Details
#buttons ⇒ Object
Returns the value of attribute buttons.
5 6 7 |
# File 'lib/message_quickly/messaging/button_template_attachment.rb', line 5 def @buttons end |
#text ⇒ Object
Returns the value of attribute text.
5 6 7 |
# File 'lib/message_quickly/messaging/button_template_attachment.rb', line 5 def text @text end |
Instance Method Details
#build_button(button_type) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/message_quickly/messaging/button_template_attachment.rb', line 13 def () case when :web_url = WebUrlButton.new when :postback = PostbackButton.new when :account_link = AccountLinkButton.new end << .tap { || yield } end |
#to_hash ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/message_quickly/messaging/button_template_attachment.rb', line 25 def to_hash { type: type, payload: { template_type: template_type, text: text, buttons: .collect { || .to_hash } } } end |