Class: MaxBotApi::Builders::KeyboardRowBuilder
- Inherits:
-
Object
- Object
- MaxBotApi::Builders::KeyboardRowBuilder
- Defined in:
- lib/max_bot_api/builders/keyboard_builder.rb
Overview
Builder for a single keyboard row.
Instance Method Summary collapse
-
#add_button(button) ⇒ Object
Add a prebuilt button hash.
-
#add_callback(text, intent, payload) ⇒ Object
Add a callback button.
-
#add_clipboard(text, payload) ⇒ Object
Add a clipboard button.
-
#add_contact(text) ⇒ Object
Add a contact request button.
-
#add_geolocation(text, quick) ⇒ Object
Add a geolocation request button.
-
#add_link(text, _intent, url) ⇒ Object
Add a link button.
-
#add_message(text) ⇒ Object
Add a message button.
-
#add_open_app(text, app, payload, contact_id) ⇒ Object
Add an open app button.
-
#build ⇒ Object
Build row payload.
-
#initialize ⇒ KeyboardRowBuilder
constructor
A new instance of KeyboardRowBuilder.
Constructor Details
#initialize ⇒ KeyboardRowBuilder
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 () @cols << 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) = { type: 'callback', text: text, payload: payload, intent: intent } () 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) = { type: 'clipboard', text: text, payload: payload } () 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) = { type: 'request_contact', text: text } () 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) = { type: 'request_geo_location', text: text, quick: quick } () end |
#add_link(text, _intent, url) ⇒ Object
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) = { type: 'link', text: text, url: url } () 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 (text) = { type: 'message', text: text } () 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) = { type: 'open_app', text: text, web_app: app, payload: payload, contact_id: contact_id } () end |
#build ⇒ Object
Build row payload.
108 109 110 |
# File 'lib/max_bot_api/builders/keyboard_builder.rb', line 108 def build @cols end |