Class: ApiBrasil::Services::Messaging::WhatsAppService

Inherits:
DeviceProxyService show all
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

#service

Attributes inherited from BaseService

#http

Instance Method Summary collapse

Methods inherited from DeviceProxyService

#queue, #request

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.

Returns:

  • (Object)


44
45
46
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 44

def close(body = nil, options = {})
  request("close", body, options)
end

#connection_status(body = nil, options = {}) ⇒ Object

Status da conexao: POST /whatsapp/getConnectionStatus.

Returns:

  • (Object)


58
59
60
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 58

def connection_status(body = nil, options = {})
  request("getConnectionStatus", body, options)
end

#delete_session(body = nil, options = {}) ⇒ Object

Apaga a sessao no servidor.

Returns:

  • (Object)


51
52
53
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 51

def delete_session(body = nil, options = {})
  request("deleteSession", body, options)
end

#logout(body = nil, options = {}) ⇒ Object

Encerra a sessao.

Returns:

  • (Object)


37
38
39
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 37

def logout(body = nil, options = {})
  request("logout", body, options)
end

#qrcode(body = nil, options = {}) ⇒ Object

Retorna o QR Code de pareamento (response.qrcode em base64).

Returns:

  • (Object)


30
31
32
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 30

def qrcode(body = nil, options = {})
  request("qrcode", body, options)
end

#send_audio(body, options = {}) ⇒ Object

Envia audio (URL; convertido para mp3 pelo gateway, max. 6 min).

Returns:

  • (Object)


86
87
88
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 86

def send_audio(body, options = {})
  request("sendAudio", body, options)
end

#send_contact(body, options = {}) ⇒ Object

Envia um contato.

Returns:

  • (Object)


114
115
116
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 114

def send_contact(body, options = {})
  request("sendContact", body, options)
end

#send_file(body, options = {}) ⇒ Object

Envia arquivo a partir de uma URL: {"number" => ..., "path" => ...}.

Returns:

  • (Object)


72
73
74
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 72

def send_file(body, options = {})
  request("sendFile", body, options)
end

#send_file64(body, options = {}) ⇒ Object

Envia arquivo em base64.

Returns:

  • (Object)


79
80
81
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 79

def send_file64(body, options = {})
  request("sendFile64", body, options)
end

Envia um link com preview.

Returns:

  • (Object)


100
101
102
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 100

def send_link(body, options = {})
  request("sendLink", body, options)
end

#send_location(body, options = {}) ⇒ Object

Envia uma localizacao: {"number" => ..., "lat" => ..., "lng" => ...}.

Returns:

  • (Object)


107
108
109
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 107

def send_location(body, options = {})
  request("sendLocation", body, options)
end

#send_text(body, options = {}) ⇒ Object

Envia mensagem de texto: {"number" => "5511999999999", "text" => "Ola!"}.

Returns:

  • (Object)


65
66
67
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 65

def send_text(body, options = {})
  request("sendText", body, options)
end

#send_video(body, options = {}) ⇒ Object

Envia video a partir de uma URL.

Returns:

  • (Object)


93
94
95
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 93

def send_video(body, options = {})
  request("sendVideo", body, options)
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.

Returns:

  • (Object)


23
24
25
# File 'lib/api_brasil/services/messaging/whatsapp_service.rb', line 23

def start(body = nil, options = {})
  request("start", body, options)
end