Class: ApiBrasil::Services::Messaging::WhatsAppService
- Inherits:
-
DeviceProxyService
- Object
- BaseService
- DeviceProxyService
- ApiBrasil::Services::Messaging::WhatsAppService
- Defined in:
- lib/api_brasil/services/messaging/whatsapp_service.rb
Overview
API de WhatsApp (device-based): POST /whatsapp/{action}.
Exige Authorization: Bearer + DeviceToken.
Alem dos metodos nomeados, request(action, body) aceita qualquer
action do catalogo (ApiBrasil::Generated::Catalog::WHATSAPP_ACTIONS).
Instance Attribute Summary
Attributes inherited from DeviceProxyService
Attributes inherited from BaseService
Instance Method Summary collapse
-
#close(body = nil, options = {}) ⇒ Object
Fecha o navegador/sessao no servidor.
-
#connection_status(body = nil, options = {}) ⇒ Object
Status da conexao:
POST /whatsapp/getConnectionStatus. -
#delete_session(body = nil, options = {}) ⇒ Object
Apaga a sessao no servidor.
-
#initialize(http) ⇒ WhatsAppService
constructor
A new instance of WhatsAppService.
-
#logout(body = nil, options = {}) ⇒ Object
Encerra a sessao.
-
#qrcode(body = nil, options = {}) ⇒ Object
Retorna o QR Code de pareamento (
response.qrcodeem base64). -
#send_audio(body, options = {}) ⇒ Object
Envia audio (URL; convertido para mp3 pelo gateway, max. 6 min).
-
#send_contact(body, options = {}) ⇒ Object
Envia um contato.
-
#send_file(body, options = {}) ⇒ Object
Envia arquivo a partir de uma URL:
{"number" => ..., "path" => ...}. -
#send_file64(body, options = {}) ⇒ Object
Envia arquivo em base64.
-
#send_link(body, options = {}) ⇒ Object
Envia um link com preview.
-
#send_location(body, options = {}) ⇒ Object
Envia uma localizacao:
{"number" => ..., "lat" => ..., "lng" => ...}. -
#send_text(body, options = {}) ⇒ Object
Envia mensagem de texto:
{"number" => "5511999999999", "text" => "Ola!"}. -
#send_video(body, options = {}) ⇒ Object
Envia video a partir de uma URL.
-
#start(body = nil, options = {}) ⇒ Object
Inicia a sessao do device (aceita webhooks opcionais):
webhook_wh_status,webhook_wh_message,webhook_wh_connect,webhook_wh_qrcode.
Methods inherited from DeviceProxyService
Methods inherited from BaseService
#delete, #download, #get, #patch, #post, #put
Constructor Details
#initialize(http) ⇒ WhatsAppService
Returns a new instance of WhatsAppService.
14 15 16 |
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 14 def initialize(http) super(http, "whatsapp") end |
Instance Method Details
#close(body = nil, options = {}) ⇒ Object
Fecha o navegador/sessao no servidor.
44 45 46 |
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 44 def close(body = nil, = {}) request("close", body, ) end |
#connection_status(body = nil, options = {}) ⇒ Object
Status da conexao: POST /whatsapp/getConnectionStatus.
58 59 60 |
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 58 def connection_status(body = nil, = {}) request("getConnectionStatus", body, ) end |
#delete_session(body = nil, options = {}) ⇒ Object
Apaga a sessao no servidor.
51 52 53 |
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 51 def delete_session(body = nil, = {}) request("deleteSession", body, ) end |
#logout(body = nil, options = {}) ⇒ Object
Encerra a sessao.
37 38 39 |
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 37 def logout(body = nil, = {}) request("logout", body, ) end |
#qrcode(body = nil, options = {}) ⇒ Object
Retorna o QR Code de pareamento (response.qrcode em base64).
30 31 32 |
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 30 def qrcode(body = nil, = {}) request("qrcode", body, ) end |
#send_audio(body, options = {}) ⇒ Object
Envia audio (URL; convertido para mp3 pelo gateway, max. 6 min).
86 87 88 |
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 86 def send_audio(body, = {}) request("sendAudio", body, ) end |
#send_contact(body, options = {}) ⇒ Object
Envia um contato.
114 115 116 |
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 114 def send_contact(body, = {}) request("sendContact", body, ) end |
#send_file(body, options = {}) ⇒ Object
Envia arquivo a partir de uma URL: {"number" => ..., "path" => ...}.
72 73 74 |
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 72 def send_file(body, = {}) request("sendFile", body, ) end |
#send_file64(body, options = {}) ⇒ Object
Envia arquivo em base64.
79 80 81 |
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 79 def send_file64(body, = {}) request("sendFile64", body, ) end |
#send_link(body, options = {}) ⇒ Object
Envia um link com preview.
100 101 102 |
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 100 def send_link(body, = {}) request("sendLink", body, ) end |
#send_location(body, options = {}) ⇒ Object
Envia uma localizacao: {"number" => ..., "lat" => ..., "lng" => ...}.
107 108 109 |
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 107 def send_location(body, = {}) request("sendLocation", body, ) end |
#send_text(body, options = {}) ⇒ Object
Envia mensagem de texto: {"number" => "5511999999999", "text" => "Ola!"}.
65 66 67 |
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 65 def send_text(body, = {}) request("sendText", body, ) end |
#send_video(body, options = {}) ⇒ Object
Envia video a partir de uma URL.
93 94 95 |
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 93 def send_video(body, = {}) request("sendVideo", body, ) end |
#start(body = nil, options = {}) ⇒ Object
Inicia a sessao do device (aceita webhooks opcionais):
webhook_wh_status, webhook_wh_message, webhook_wh_connect,
webhook_wh_qrcode.
23 24 25 |
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 23 def start(body = nil, = {}) request("start", body, ) end |