TopSapp: fix API show blocked services from client
Signed-off-by: Rodrigo Bertoldo de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
cfbc730e70
commit
d4bd364690
2 files changed
+245
-45
No files matched your search
@@ -1214,6 +1214,53 @@ class TopSappManager {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obter dados completos de uma fatura (linha digitável, PIX, etc)
|
||||
*/
|
||||
async obterDadosFatura(idFatura, location = '') {
|
||||
if (!this.isReady()) {
|
||||
return {
|
||||
success: false,
|
||||
error: 'TopSapp não está configurado'
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const credentials = this.config.getCredentialsByLocation(location);
|
||||
|
||||
// Primeiro obter a lista de faturas para pegar o idCliente
|
||||
const faturas = await this.api.obterFaturas(null, location, credentials);
|
||||
|
||||
if (!faturas.success || !faturas.data || !faturas.data.dados) {
|
||||
return {
|
||||
success: false,
|
||||
error: 'Erro ao buscar faturas'
|
||||
};
|
||||
}
|
||||
|
||||
// Encontrar a fatura específica
|
||||
const fatura = faturas.data.dados.find(f => f.id == idFatura);
|
||||
|
||||
if (!fatura) {
|
||||
return {
|
||||
success: false,
|
||||
error: 'Fatura não encontrada'
|
||||
};
|
||||
}
|
||||
|
||||
const idCliente = fatura.codigo_cliente || fatura.id_cliente;
|
||||
|
||||
// Obter dados completos da fatura
|
||||
return await this.api.obterDadosFatura(idFatura, idCliente, location, credentials);
|
||||
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
error: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TopSappManager;
|
||||
Reference in new issue
Block a user