Class: Messenger::Elements::Button

Inherits:
Object
  • Object
show all
Defined in:
lib/messenger/components/elements/button.rb

Instance Method Summary collapse

Constructor Details

#initialize(type:, title:, value:) ⇒ Button

Returns a new instance of Button.



4
5
6
7
8
# File 'lib/messenger/components/elements/button.rb', line 4

def initialize(type:, title:, value:)
  @type = type
  @title = title
  @value = value
end

Instance Method Details

#buildObject



10
11
12
# File 'lib/messenger/components/elements/button.rb', line 10

def build
  { type: @type, title: @title }.merge! eval(@type.to_s)
end

#postbackObject



18
19
20
# File 'lib/messenger/components/elements/button.rb', line 18

def postback
  { payload: @value }
end

#web_urlObject



14
15
16
# File 'lib/messenger/components/elements/button.rb', line 14

def web_url
  { url: @value }
end