Class: MaxBotApi::Builders::KeyboardRowBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/max_bot_api/builders/keyboard_builder.rb

Overview

Builder for a single keyboard row.

Instance Method Summary collapse

Constructor Details

#initializeKeyboardRowBuilder

Returns a new instance of KeyboardRowBuilder.



26
27
28
# File 'lib/max_bot_api/builders/keyboard_builder.rb', line 26

def initialize
  @cols = []
end

Instance Method Details

#add_button(button) ⇒ Object

Add a prebuilt button hash.



31
32
33
34
# File 'lib/max_bot_api/builders/keyboard_builder.rb', line 31

def add_button(button)
  @cols << button
  self
end

#add_callback(text, intent, payload) ⇒ Object

Add a callback button.



47
48
49
50
51
52
53
54
55
# File 'lib/max_bot_api/builders/keyboard_builder.rb', line 47

def add_callback(text, intent, payload)
  button = {
    type: 'callback',
    text: text,
    payload: payload,
    intent: intent
  }
  add_button(button)
end

#add_clipboard(text, payload) ⇒ Object

Add a clipboard button.



98
99
100
101
102
103
104
105
# File 'lib/max_bot_api/builders/keyboard_builder.rb', line 98

def add_clipboard(text, payload)
  button = {
    type: 'clipboard',
    text: text,
    payload: payload
  }
  add_button(button)
end

#add_contact(text) ⇒ Object

Add a contact request button.



58
59
60
61
62
63
64
# File 'lib/max_bot_api/builders/keyboard_builder.rb', line 58

def add_contact(text)
  button = {
    type: 'request_contact',
    text: text
  }
  add_button(button)
end

#add_geolocation(text, quick) ⇒ Object

Add a geolocation request button.



67
68
69
70
71
72
73
74
# File 'lib/max_bot_api/builders/keyboard_builder.rb', line 67

def add_geolocation(text, quick)
  button = {
    type: 'request_geo_location',
    text: text,
    quick: quick
  }
  add_button(button)
end

Add a link button.



37
38
39
40
41
42
43
44
# File 'lib/max_bot_api/builders/keyboard_builder.rb', line 37

def add_link(text, _intent, url)
  button = {
    type: 'link',
    text: text,
    url: url
  }
  add_button(button)
end

#add_message(text) ⇒ Object

Add a message button.



89
90
91
92
93
94
95
# File 'lib/max_bot_api/builders/keyboard_builder.rb', line 89

def add_message(text)
  button = {
    type: 'message',
    text: text
  }
  add_button(button)
end

#add_open_app(text, app, payload, contact_id) ⇒ Object

Add an open app button.



77
78
79
80
81
82
83
84
85
86
# File 'lib/max_bot_api/builders/keyboard_builder.rb', line 77

def add_open_app(text, app, payload, contact_id)
  button = {
    type: 'open_app',
    text: text,
    web_app: app,
    payload: payload,
    contact_id: contact_id
  }
  add_button(button)
end

#buildObject

Build row payload.



108
109
110
# File 'lib/max_bot_api/builders/keyboard_builder.rb', line 108

def build
  @cols
end