From e69a8e351a1a70d2a35d0fb3d0cd41d73f943c9e Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Thu, 6 Oct 2022 18:46:40 +0200
Subject: [PATCH] fix: switch to warning log because it was making the app
 failing

---
 src/core/contractVerification.js | 2 +-
 src/core/findUserPdl.js          | 6 +++---
 src/index.js                     | 1 +
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/core/contractVerification.js b/src/core/contractVerification.js
index 28b8913..684c3aa 100644
--- a/src/core/contractVerification.js
+++ b/src/core/contractVerification.js
@@ -52,7 +52,7 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) {
     if (Array.isArray(currentContracts)) {
       currentContract = parseContracts(parsedReply)[0]
     } else {
-      currentContract = parseContracts(parsedReply)
+      currentContract = currentContracts
     }
     if (
       (currentContract.etatCode === contractState.ACTIF ||
diff --git a/src/core/findUserPdl.js b/src/core/findUserPdl.js
index b9edb62..ff8d0ae 100644
--- a/src/core/findUserPdl.js
+++ b/src/core/findUserPdl.js
@@ -25,7 +25,7 @@ async function findUserPdl(
   inseeCode,
   escalierEtEtageEtAppartement = ''
 ) {
-  log('info', 'Fetching user data')
+  log('info', 'Fetching user pdl')
   const sgeHeaders = {
     'Content-Type': 'text/xml;charset=UTF-8',
     apikey: apiAuthKey,
@@ -57,10 +57,10 @@ async function findUserPdl(
   try {
     return parseUserPdl(parsedReply)
   } catch (error) {
-    log('error', 'Error while parsing user PDL: ' + error)
+    log('warn', 'Error while parsing user PDL: ' + error)
     if (parsedReply.Envelope.Body.Fault) {
       log(
-        'error',
+        'warn',
         `Enedis issue ${parsedReply.Envelope.Body.Fault.detail.erreur.resultat.$.code}: ${parsedReply.Envelope.Body.Fault.faultstring}`
       )
     }
diff --git a/src/index.js b/src/index.js
index 84c4184..d96fa6d 100644
--- a/src/index.js
+++ b/src/index.js
@@ -219,6 +219,7 @@ async function start(fields, cozyParameters) {
   log('info', 'Successfully logged in')
 
   await gatherData(baseUrl, apiAuthKey, sgeLogin, pointId)
+  log('info', 'Konnector success')
 }
 
 /**
-- 
GitLab