Skip to content
Snippets Groups Projects
Commit defecee3 authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

fix: no contract found throw errors

parent 500cb668
No related branches found
No related tags found
1 merge request!13fix: no contract found throw errors
Pipeline #40355 failed
...@@ -37,6 +37,11 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) { ...@@ -37,6 +37,11 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) {
}) })
try { try {
if (!checkContractExists(parsedReply)) {
log('error', 'no contract found')
return null
}
const currentContracts = parseContracts(parsedReply) const currentContracts = parseContracts(parsedReply)
let currentContract = null let currentContract = null
if (Array.isArray(currentContracts)) { if (Array.isArray(currentContracts)) {
...@@ -61,4 +66,15 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) { ...@@ -61,4 +66,15 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) {
} }
} }
/**
* @param {string} parsedReply
* @return {boolean}
*/
function checkContractExists(parsedReply) {
const json = JSON.stringify(parsedReply)
return JSON.parse(json)['Envelope']['Body'][
'rechercherServicesSouscritsMesuresResponse'
]['servicesSouscritsMesures']
}
module.exports = { verifyContract } module.exports = { verifyContract }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment