addONU: Adicionado função de vincular ao TopSapp_par6
Signed-off-by: Rodrigo Bertoldo de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
486682b751
commit
94e93e46a4
3 files changed
+35
-1
No files matched your search
@@ -6252,6 +6252,14 @@ Digite /help para ver todos os comandos disponíveis!
|
|||||||
const resultado = await this.topsapp.atualizarFTTH(idCliente, idServico, ftthData, location);
|
const resultado = await this.topsapp.atualizarFTTH(idCliente, idServico, ftthData, location);
|
||||||
|
|
||||||
if (resultado.success) {
|
if (resultado.success) {
|
||||||
|
// Provisionar para sincronizar onuid e serviceport do OLT → TopSapp
|
||||||
|
try {
|
||||||
|
const provResult = await this.topsapp.provisionarServico(idCliente, idServico, location);
|
||||||
|
console.log(`🔄 ProvisionarServico resultado:`, JSON.stringify(provResult?.data || provResult));
|
||||||
|
} catch (provError) {
|
||||||
|
console.warn(`⚠️ ProvisionarServico falhou (não-fatal):`, provError.message);
|
||||||
|
}
|
||||||
|
|
||||||
await this.bot.sendMessage(chatId,
|
await this.bot.sendMessage(chatId,
|
||||||
`✅ *ONU vinculada com sucesso no TopSapp!*\n\n` +
|
`✅ *ONU vinculada com sucesso no TopSapp!*\n\n` +
|
||||||
`📱 *Serial:* \`${ftthData.serial}\`\n` +
|
`📱 *Serial:* \`${ftthData.serial}\`\n` +
|
||||||
|
|||||||
+18
-1
@@ -168,7 +168,7 @@ class TopSappAPI {
|
|||||||
console.log(`📊 Status da resposta: ${response.status}`);
|
console.log(`📊 Status da resposta: ${response.status}`);
|
||||||
console.log(`📋 Dados da resposta:`, response.data);
|
console.log(`📋 Dados da resposta:`, response.data);
|
||||||
|
|
||||||
if (response.data && response.data.resultado === true) {
|
if (response.data && (response.data.resultado === true || response.data.status === true)) {
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
data: response.data,
|
data: response.data,
|
||||||
@@ -859,6 +859,23 @@ class TopSappAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provisionar manualmente um serviço (sincroniza dados do OLT → TopSapp)
|
||||||
|
*/
|
||||||
|
async provisionarServico(idCliente, idServico, location = '', credentials) {
|
||||||
|
const instance = this.getInstanceByLocation(location);
|
||||||
|
try {
|
||||||
|
const session = await this.getValidSession(instance, credentials);
|
||||||
|
return await this.makeRequest('ProvisionarServico', {
|
||||||
|
idUsuario: session.idUsuario || 1,
|
||||||
|
idCliente: parseInt(idCliente),
|
||||||
|
idServico: parseInt(idServico)
|
||||||
|
}, instance, credentials);
|
||||||
|
} catch (error) {
|
||||||
|
return { success: false, error: error.message };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listar todas as instâncias disponíveis
|
* Listar todas as instâncias disponíveis
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1278,6 +1278,15 @@ class TopSappManager {
|
|||||||
const credentials = this.config.getCredentialsByLocation(location);
|
const credentials = this.config.getCredentialsByLocation(location);
|
||||||
return await this.api.atualizarFTTH(idCliente, idServico, ftthData, location, credentials);
|
return await this.api.atualizarFTTH(idCliente, idServico, ftthData, location, credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provisionar manualmente um serviço (sincroniza dados do OLT → TopSapp)
|
||||||
|
*/
|
||||||
|
async provisionarServico(idCliente, idServico, location = '') {
|
||||||
|
if (!this.isReady()) return { success: false, error: 'TopSapp não configurado' };
|
||||||
|
const credentials = this.config.getCredentialsByLocation(location);
|
||||||
|
return await this.api.provisionarServico(idCliente, idServico, location, credentials);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = TopSappManager;
|
module.exports = TopSappManager;
|
||||||
Reference in new issue
Block a user