34 lines
1.1 KiB
TypeScript
Executable File
34 lines
1.1 KiB
TypeScript
Executable File
/**
|
|
* perfexCrmService.ts
|
|
*
|
|
* @author Descomplicar® Crescimento Digital
|
|
* @link https://descomplicar.pt
|
|
* @copyright 2025 Descomplicar®
|
|
*/
|
|
|
|
import type { CrmSettings } from '../types';
|
|
|
|
/**
|
|
* Simula a exclusão de tickets no Perfex CRM com base nos remetentes de e-mail.
|
|
*/
|
|
export const deleteTicketsFromSendersInPerfex = (
|
|
settings: CrmSettings,
|
|
senderEmails: string[]
|
|
): Promise<number> => {
|
|
console.log('Iniciando exclusão de tickets de spam/notificações no Perfex CRM...');
|
|
console.log('Remetentes alvo:', senderEmails);
|
|
|
|
return new Promise((resolve, reject) => {
|
|
setTimeout(() => {
|
|
if (!settings.url || !settings.token) {
|
|
return reject(new Error('Não foi possível excluir tickets: URL do CRM ou Token não configurado.'));
|
|
}
|
|
if (settings.token === 'fail') {
|
|
return reject(new Error('Falha ao excluir tickets no Perfex CRM.'));
|
|
}
|
|
const simulatedDeletedCount = Math.floor(Math.random() * senderEmails.length) + 1;
|
|
console.log(`Sucesso! ${simulatedDeletedCount} tickets foram "excluídos" do Perfex CRM.`);
|
|
resolve(simulatedDeletedCount);
|
|
}, 1500);
|
|
});
|
|
}; |