topsapp: adicionado opção de abrir suporte
Signed-off-by: Rodrigo B. de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
1337e1c2d0
commit
3d35fc24cc
9 files changed
+1600
-1
No files matched your search
@@ -625,6 +625,86 @@ class TopSappAPI {
|
||||
return await this.alterarStatusServico(idServico, idCliente, 1, location, credentials);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obter técnicos disponíveis
|
||||
*/
|
||||
async obterTecnicos(location = '', credentials) {
|
||||
const instance = this.getInstanceByLocation(location);
|
||||
|
||||
// Obter o idUsuario da sessão atual
|
||||
const session = await this.getValidSession(instance, credentials);
|
||||
|
||||
return await this.makeRequest('ObterTecnicos', {
|
||||
idUsuario: session.idUsuario || 1
|
||||
}, instance, credentials);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obter operadores disponíveis
|
||||
*/
|
||||
async obterOperadores(location = '', credentials) {
|
||||
const instance = this.getInstanceByLocation(location);
|
||||
|
||||
// Obter o idUsuario da sessão atual
|
||||
const session = await this.getValidSession(instance, credentials);
|
||||
|
||||
return await this.makeRequest('ObterOperadores', {
|
||||
idUsuario: session.idUsuario || 1
|
||||
}, instance, credentials);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obter funcionários disponíveis
|
||||
*/
|
||||
async obterFuncionarios(location = '', credentials) {
|
||||
const instance = this.getInstanceByLocation(location);
|
||||
|
||||
// Obter o idUsuario da sessão atual
|
||||
const session = await this.getValidSession(instance, credentials);
|
||||
|
||||
return await this.makeRequest('ObterFuncionarios', {
|
||||
idUsuario: session.idUsuario || 1
|
||||
}, instance, credentials);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obter categorias de suporte
|
||||
*/
|
||||
async obterSuporteCategorias(location = '', credentials) {
|
||||
const instance = this.getInstanceByLocation(location);
|
||||
|
||||
// Obter o idUsuario da sessão atual
|
||||
const session = await this.getValidSession(instance, credentials);
|
||||
|
||||
return await this.makeRequest('ObterSuporteCategorias', {
|
||||
idUsuario: session.idUsuario || 1
|
||||
}, instance, credentials);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adicionar novo suporte
|
||||
*/
|
||||
async adicionarSuporte(dadosSuporte, location = '', credentials) {
|
||||
const instance = this.getInstanceByLocation(location);
|
||||
|
||||
// Obter o idUsuario da sessão atual
|
||||
const session = await this.getValidSession(instance, credentials);
|
||||
|
||||
const dados = {
|
||||
idUsuario: session.idUsuario || 1,
|
||||
idCliente: dadosSuporte.idCliente,
|
||||
idServico: dadosSuporte.idServico,
|
||||
idCategoria: dadosSuporte.idCategoria,
|
||||
contato: dadosSuporte.contato || '',
|
||||
contatoTelefone: dadosSuporte.contatoTelefone || '',
|
||||
descricao: dadosSuporte.descricao,
|
||||
outrasInformacoes: dadosSuporte.outrasInformacoes || '',
|
||||
...dadosSuporte // Permite campos adicionais como idAtendimento
|
||||
};
|
||||
|
||||
return await this.makeRequest('AdicionarSuporte', dados, instance, credentials);
|
||||
}
|
||||
|
||||
/**
|
||||
* Listar todas as instâncias disponíveis
|
||||
*/
|
||||
|
||||
@@ -770,6 +770,16 @@ class TopSappManager {
|
||||
|
||||
console.log(`🎯 Serviços filtrados para o cliente ${clienteId}: ${servicosDoCliente.length}`);
|
||||
|
||||
// Debug: mostrar um exemplo de serviço filtrado
|
||||
if (servicosDoCliente.length > 0) {
|
||||
console.log(`📋 Exemplo de serviço encontrado:`, {
|
||||
id: servicosDoCliente[0].id || servicosDoCliente[0].id_servico,
|
||||
descricao: servicosDoCliente[0].descricao,
|
||||
id_cliente: servicosDoCliente[0].id_cliente,
|
||||
status: servicosDoCliente[0].status
|
||||
});
|
||||
}
|
||||
|
||||
// Se ainda assim temos muitos resultados, algo está errado
|
||||
if (servicosDoCliente.length > 50) {
|
||||
console.log(`❌ ERRO: Ainda temos ${servicosDoCliente.length} serviços após filtro - possível problema na API`);
|
||||
@@ -947,6 +957,135 @@ class TopSappManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obter técnicos disponíveis
|
||||
*/
|
||||
async obterTecnicos(location = '') {
|
||||
if (!this.isReady()) {
|
||||
return {
|
||||
success: false,
|
||||
error: 'TopSapp não está configurado'
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const credentials = this.config.getCredentialsByLocation(location);
|
||||
const result = await this.api.obterTecnicos(location, credentials);
|
||||
|
||||
return result;
|
||||
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
error: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obter operadores disponíveis
|
||||
*/
|
||||
async obterOperadores(location = '') {
|
||||
if (!this.isReady()) {
|
||||
return {
|
||||
success: false,
|
||||
error: 'TopSapp não está configurado'
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const credentials = this.config.getCredentialsByLocation(location);
|
||||
const result = await this.api.obterOperadores(location, credentials);
|
||||
|
||||
return result;
|
||||
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
error: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obter funcionários disponíveis
|
||||
*/
|
||||
async obterFuncionarios(location = '') {
|
||||
if (!this.isReady()) {
|
||||
return {
|
||||
success: false,
|
||||
error: 'TopSapp não está configurado'
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const credentials = this.config.getCredentialsByLocation(location);
|
||||
const result = await this.api.obterFuncionarios(location, credentials);
|
||||
|
||||
return result;
|
||||
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
error: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obter categorias de suporte
|
||||
*/
|
||||
async obterSuporteCategorias(location = '') {
|
||||
if (!this.isReady()) {
|
||||
return {
|
||||
success: false,
|
||||
error: 'TopSapp não está configurado'
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const credentials = this.config.getCredentialsByLocation(location);
|
||||
const result = await this.api.obterSuporteCategorias(location, credentials);
|
||||
|
||||
return result;
|
||||
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
error: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adicionar novo suporte
|
||||
*/
|
||||
async adicionarSuporte(dadosSuporte, location = '') {
|
||||
if (!this.isReady()) {
|
||||
return {
|
||||
success: false,
|
||||
error: 'TopSapp não está configurado'
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const credentials = this.config.getCredentialsByLocation(location);
|
||||
const result = await this.api.adicionarSuporte(dadosSuporte, location, credentials);
|
||||
|
||||
if (result.success) {
|
||||
console.log(`✅ Suporte criado com sucesso. Protocolo: ${result.data.protocolo || 'N/A'}`);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
error: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obter instâncias disponíveis
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user