class MessengerClient::ButtonTemplate

Public Class Methods

new(text, buttons) click to toggle source
# File lib/messenger_client/button_template.rb, line 3
def initialize(text, buttons)
  @text    = text
  @buttons = parse_buttons(buttons)
end

Public Instance Methods

to_json() click to toggle source
# File lib/messenger_client/button_template.rb, line 8
def to_json
  {
    attachment: {
      type: "template",
      payload: {
        template_type: "button",
        text:          @text,
        buttons:       @buttons
      }
    }
  }
end

Private Instance Methods

parse_buttons(buttons) click to toggle source
# File lib/messenger_client/button_template.rb, line 23
def parse_buttons(buttons)
  buttons.map(&:to_json)
end