Class: Viberroo::Bot
- Inherits:
-
Object
- Object
- Viberroo::Bot
- Defined in:
- lib/viberroo/bot.rb
Instance Method Summary collapse
- #broadcast(message:, to:) ⇒ Object
- #get_account_info ⇒ Object
- #get_online(ids:) ⇒ Object
- #get_user_details(id:) ⇒ Object
-
#initialize(token:, response: {}) ⇒ Bot
constructor
A new instance of Bot.
- #remove_webhook ⇒ Object
- #send(message:, keyboard: {}) ⇒ Object
- #set_webhook(url:, event_types: nil, send_name: nil, send_photo: nil) ⇒ Object
Constructor Details
#initialize(token:, response: {}) ⇒ Bot
Returns a new instance of Bot.
3 4 5 6 |
# File 'lib/viberroo/bot.rb', line 3 def initialize(token:, response: {}) @headers = { 'X-Viber-Auth-Token': token, 'Content-Type': 'application/json' } @response = response end |
Instance Method Details
#broadcast(message:, to:) ⇒ Object
29 30 31 |
# File 'lib/viberroo/bot.rb', line 29 def broadcast(message:, to:) request(URL::BROADCAST_MESSAGE, .merge(broadcast_list: to)) end |
#get_account_info ⇒ Object
33 34 35 |
# File 'lib/viberroo/bot.rb', line 33 def get_account_info request(URL::GET_ACCOUNT_INFO) end |
#get_online(ids:) ⇒ Object
41 42 43 |
# File 'lib/viberroo/bot.rb', line 41 def get_online(ids:) request(URL::GET_ONLINE, ids: ids) end |
#get_user_details(id:) ⇒ Object
37 38 39 |
# File 'lib/viberroo/bot.rb', line 37 def get_user_details(id:) request(URL::GET_USER_DETAILS, id: id) end |
#remove_webhook ⇒ Object
18 19 20 |
# File 'lib/viberroo/bot.rb', line 18 def remove_webhook request(URL::WEBHOOK, url: '') end |
#send(message:, keyboard: {}) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/viberroo/bot.rb', line 22 def send(message:, keyboard: {}) request( URL::MESSAGE, { receiver: @response.user_id }.merge().merge(keyboard) ) end |
#set_webhook(url:, event_types: nil, send_name: nil, send_photo: nil) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/viberroo/bot.rb', line 8 def set_webhook(url:, event_types: nil, send_name: nil, send_photo: nil) request( URL::WEBHOOK, url: url, event_types: event_types, send_name: send_name, send_photo: send_photo ) end |