Class: EvolutionApi::Instance
- Inherits:
-
Object
- Object
- EvolutionApi::Instance
- Defined in:
- lib/evolution_api/instance.rb
Overview
Classe para gerenciar instâncias do WhatsApp
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#archive_chat(number) ⇒ Object
Arquivar chat.
-
#block_contact(number) ⇒ Object
Bloqueia um contato.
-
#chats ⇒ Object
Obtém chats da instância.
-
#check_number(number) ⇒ Object
Verifica se um número existe no WhatsApp.
-
#connect ⇒ Object
Conecta a instância.
-
#connected? ⇒ Boolean
Verifica se a instância está conectada.
-
#contact(number) ⇒ Object
Obtém informações de um contato.
-
#contacts ⇒ Object
Obtém contatos da instância.
-
#delete ⇒ Object
Remove a instância.
-
#delete_chat(number) ⇒ Object
Deletar chat.
-
#delete_webhook ⇒ Object
Remove webhook.
-
#disconnect ⇒ Object
Desconecta a instância.
-
#info ⇒ Object
Obtém informações da instância.
-
#initialize(name, client) ⇒ Instance
constructor
A new instance of Instance.
-
#mark_as_read(number) ⇒ Object
Marca mensagens como lidas.
-
#messages(number, options = {}) ⇒ Object
Obtém mensagens de um chat.
-
#qr_code ⇒ Object
Obtém QR Code para conexão.
-
#send_audio(number, audio_url, options = {}) ⇒ Object
Envia uma mensagem de áudio.
-
#send_button(number, title, description, buttons) ⇒ Object
Envia uma mensagem com botões.
-
#send_contact(number, contact_number, contact_name) ⇒ Object
Envia um contato.
-
#send_document(number, document_url, caption = nil, options = {}) ⇒ Object
Envia um documento.
-
#send_image(number, image_url, caption = nil, options = {}) ⇒ Object
Envia uma mensagem de imagem.
-
#send_list(number, title, description, sections) ⇒ Object
Envia uma lista de opções.
-
#send_location(number, latitude, longitude, description = nil) ⇒ Object
Envia uma localização.
-
#send_text(number, text, options = {}) ⇒ Object
Envia uma mensagem de texto.
-
#send_video(number, video_url, caption = nil, options = {}) ⇒ Object
Envia uma mensagem de vídeo.
-
#set_webhook(webhook_url, events = nil) ⇒ Object
Configura webhook.
-
#unarchive_chat(number) ⇒ Object
Desarquivar chat.
-
#unblock_contact(number) ⇒ Object
Desbloqueia um contato.
-
#webhook ⇒ Object
Obtém configuração de webhook.
Constructor Details
#initialize(name, client) ⇒ Instance
Returns a new instance of Instance.
8 9 10 11 |
# File 'lib/evolution_api/instance.rb', line 8 def initialize(name, client) @name = name @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/evolution_api/instance.rb', line 6 def client @client end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/evolution_api/instance.rb', line 6 def name @name end |
Instance Method Details
#archive_chat(number) ⇒ Object
Arquivar chat
107 108 109 |
# File 'lib/evolution_api/instance.rb', line 107 def archive_chat(number) client.archive_chat(name, number) end |
#block_contact(number) ⇒ Object
Bloqueia um contato
137 138 139 |
# File 'lib/evolution_api/instance.rb', line 137 def block_contact(number) client.block_contact(name, number) end |
#chats ⇒ Object
Obtém chats da instância
92 93 94 |
# File 'lib/evolution_api/instance.rb', line 92 def chats client.get_chats(name) end |
#check_number(number) ⇒ Object
Verifica se um número existe no WhatsApp
132 133 134 |
# File 'lib/evolution_api/instance.rb', line 132 def check_number(number) client.check_number(name, number) end |
#connect ⇒ Object
Conecta a instância
19 20 21 |
# File 'lib/evolution_api/instance.rb', line 19 def connect client.connect_instance(name) end |
#connected? ⇒ Boolean
Verifica se a instância está conectada
39 40 41 42 43 44 |
# File 'lib/evolution_api/instance.rb', line 39 def connected? info = self.info info['status'] == 'open' rescue StandardError false end |
#contact(number) ⇒ Object
Obtém informações de um contato
127 128 129 |
# File 'lib/evolution_api/instance.rb', line 127 def contact(number) client.get_contact(name, number) end |
#contacts ⇒ Object
Obtém contatos da instância
122 123 124 |
# File 'lib/evolution_api/instance.rb', line 122 def contacts client.get_contacts(name) end |
#delete ⇒ Object
Remove a instância
29 30 31 |
# File 'lib/evolution_api/instance.rb', line 29 def delete client.delete_instance(name) end |
#delete_chat(number) ⇒ Object
Deletar chat
117 118 119 |
# File 'lib/evolution_api/instance.rb', line 117 def delete_chat(number) client.delete_chat(name, number) end |
#delete_webhook ⇒ Object
Remove webhook
157 158 159 |
# File 'lib/evolution_api/instance.rb', line 157 def delete_webhook client.delete_webhook(name) end |
#disconnect ⇒ Object
Desconecta a instância
24 25 26 |
# File 'lib/evolution_api/instance.rb', line 24 def disconnect client.disconnect_instance(name) end |
#info ⇒ Object
Obtém informações da instância
14 15 16 |
# File 'lib/evolution_api/instance.rb', line 14 def info client.get_instance(name) end |
#mark_as_read(number) ⇒ Object
Marca mensagens como lidas
102 103 104 |
# File 'lib/evolution_api/instance.rb', line 102 def mark_as_read(number) client.(name, number) end |
#messages(number, options = {}) ⇒ Object
Obtém mensagens de um chat
97 98 99 |
# File 'lib/evolution_api/instance.rb', line 97 def (number, = {}) client.(name, number, ) end |
#qr_code ⇒ Object
Obtém QR Code para conexão
34 35 36 |
# File 'lib/evolution_api/instance.rb', line 34 def qr_code client.get_qr_code(name) end |
#send_audio(number, audio_url, options = {}) ⇒ Object
Envia uma mensagem de áudio
57 58 59 |
# File 'lib/evolution_api/instance.rb', line 57 def send_audio(number, audio_url, = {}) client.(name, number, audio_url, ) end |
#send_button(number, title, description, buttons) ⇒ Object
Envia uma mensagem com botões
82 83 84 |
# File 'lib/evolution_api/instance.rb', line 82 def (number, title, description, ) client.(name, number, title, description, ) end |
#send_contact(number, contact_number, contact_name) ⇒ Object
Envia um contato
77 78 79 |
# File 'lib/evolution_api/instance.rb', line 77 def send_contact(number, contact_number, contact_name) client.(name, number, contact_number, contact_name) end |
#send_document(number, document_url, caption = nil, options = {}) ⇒ Object
Envia um documento
67 68 69 |
# File 'lib/evolution_api/instance.rb', line 67 def send_document(number, document_url, caption = nil, = {}) client.(name, number, document_url, caption, ) end |
#send_image(number, image_url, caption = nil, options = {}) ⇒ Object
Envia uma mensagem de imagem
52 53 54 |
# File 'lib/evolution_api/instance.rb', line 52 def send_image(number, image_url, caption = nil, = {}) client.(name, number, image_url, caption, ) end |
#send_list(number, title, description, sections) ⇒ Object
Envia uma lista de opções
87 88 89 |
# File 'lib/evolution_api/instance.rb', line 87 def send_list(number, title, description, sections) client.(name, number, title, description, sections) end |
#send_location(number, latitude, longitude, description = nil) ⇒ Object
Envia uma localização
72 73 74 |
# File 'lib/evolution_api/instance.rb', line 72 def send_location(number, latitude, longitude, description = nil) client.(name, number, latitude, longitude, description) end |
#send_text(number, text, options = {}) ⇒ Object
Envia uma mensagem de texto
47 48 49 |
# File 'lib/evolution_api/instance.rb', line 47 def send_text(number, text, = {}) client.(name, number, text, ) end |
#send_video(number, video_url, caption = nil, options = {}) ⇒ Object
Envia uma mensagem de vídeo
62 63 64 |
# File 'lib/evolution_api/instance.rb', line 62 def send_video(number, video_url, caption = nil, = {}) client.(name, number, video_url, caption, ) end |
#set_webhook(webhook_url, events = nil) ⇒ Object
Configura webhook
147 148 149 |
# File 'lib/evolution_api/instance.rb', line 147 def set_webhook(webhook_url, events = nil) client.set_webhook(name, webhook_url, events) end |
#unarchive_chat(number) ⇒ Object
Desarquivar chat
112 113 114 |
# File 'lib/evolution_api/instance.rb', line 112 def unarchive_chat(number) client.unarchive_chat(name, number) end |
#unblock_contact(number) ⇒ Object
Desbloqueia um contato
142 143 144 |
# File 'lib/evolution_api/instance.rb', line 142 def unblock_contact(number) client.unblock_contact(name, number) end |
#webhook ⇒ Object
Obtém configuração de webhook
152 153 154 |
# File 'lib/evolution_api/instance.rb', line 152 def webhook client.get_webhook(name) end |