class MessageQuickly::Messaging::ButtonTemplateAttachment

Attributes

buttons[RW]
text[RW]

Public Class Methods

new(params = {}) click to toggle source
Calls superclass method
# File lib/message_quickly/messaging/button_template_attachment.rb, line 7
def initialize(params = {})
  self.buttons ||= []
  params['template_type'] ||= 'button'
  super(params)
end

Public Instance Methods

build_button(button_type) { |button| ... } click to toggle source
# File lib/message_quickly/messaging/button_template_attachment.rb, line 13
def build_button(button_type)
  case button_type
  when :web_url
    button = WebUrlButton.new
  when :postback
    button = PostbackButton.new
  when :account_link
    button = AccountLinkButton.new
  end
  buttons << button.tap { |button| yield button }
end
to_hash() click to toggle source
# File lib/message_quickly/messaging/button_template_attachment.rb, line 25
def to_hash
  {
    type: type,
    payload: {
      template_type: template_type,
      text: text,
      buttons: buttons.collect { |button| button.to_hash }
    }
  }
end