From 946d0fa94eaf439c4d47a6f573748e17658fc67b Mon Sep 17 00:00:00 2001 From: lucascardo12 Date: Tue, 23 Nov 2021 16:06:30 -0400 Subject: [PATCH] =?UTF-8?q?ajuste=20do=20padr=C3=A3o=20de=20msg=20simples?= =?UTF-8?q?=20chat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Core/CoreMedia.php | 2 +- app/Interfaces/IApiMedia.php | 2 +- app/Providers/Positus.php | 15 ++++++++++++--- database/msg-text-positus.json | 17 +++++++++++++++++ 4 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 database/msg-text-positus.json diff --git a/app/Core/CoreMedia.php b/app/Core/CoreMedia.php index 4d2559a..f47a681 100644 --- a/app/Core/CoreMedia.php +++ b/app/Core/CoreMedia.php @@ -65,7 +65,7 @@ class CoreMedia $file = $this->api->baixarMidia($this->file); return $file; } - $this->ws->enviaMsg($api->convertToWebsocket($this->request)); + $this->ws->enviaMsg($api->convertToWebsocket($this->request, '1022', time())); /** * VERIFICA SE N?O MENSAGEM DO POSITUS DE CONFIRMA??O */ diff --git a/app/Interfaces/IApiMedia.php b/app/Interfaces/IApiMedia.php index 1f947a2..915da99 100644 --- a/app/Interfaces/IApiMedia.php +++ b/app/Interfaces/IApiMedia.php @@ -36,5 +36,5 @@ interface IApiMedia function response($result); public function getLinkDownload($host); public function retornaTituloDocument($msg); - public function convertToWebsocket($msg); + public function convertToWebsocket($msg, $matricula, $atendimento); } \ No newline at end of file diff --git a/app/Providers/Positus.php b/app/Providers/Positus.php index b15c6ed..00286b4 100644 --- a/app/Providers/Positus.php +++ b/app/Providers/Positus.php @@ -27,7 +27,7 @@ class Positus implements IApiMedia ######################################################################## ## RECURSOS DA API ## ######################################################################## - public function convertToWebsocket($msg) + public function convertToWebsocket($msg, $matricula = '', $atendimento) { if ($msg['contacts']) { $mensagem = []; @@ -35,17 +35,26 @@ class Positus implements IApiMedia "type" => "mensagem", "contact" => [ "name" => $msg['contacts'][0]['profile']['name'], - "number" => $msg['contacts'][0]['wa_id'] + "number" => $msg['contacts'][0]['wa_id'], + "matricula" => '' ], "mensagem" => [ "type" => $msg['messages'][0]['type'], - "content" => $msg['messages'][0]['text']['body'] + "content" => $msg['messages'][0]['text']['body'], + "id" => "425435243", + "dst" => $matricula, + "idAtendimento" => $atendimento, + "media" => $this->channel, + "datetime" => $msg['messages'][0]['timestamp'], + "status" => "sent" ] ]; + return json_encode($mensagem); } return ""; } + function enviarMsg($whatsapp, $mensagem) { $this->debug = debug_backtrace(); diff --git a/database/msg-text-positus.json b/database/msg-text-positus.json new file mode 100644 index 0000000..71b6349 --- /dev/null +++ b/database/msg-text-positus.json @@ -0,0 +1,17 @@ +{ + "contacts": [{ + "profile": { + "name": "Lucas" + }, + "wa_id": "556596107663" + }], + "messages": [{ + "from": "556596107663", + "id": "ABEGVWWWEHZjAhBQHfcZqjRX4rWUHoW5CZul", + "text": { + "body": "Test" + }, + "timestamp": "1637696166", + "type": "text" + }] +} \ No newline at end of file