From a449ac9e5dc46cbec399fe3a09c6eb9a20b83918 Mon Sep 17 00:00:00 2001 From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com> Date: Fri, 12 Aug 2022 17:18:32 +0200 Subject: [PATCH] fix: onDelete --- src/core/types/types.js | 2 +- src/index.js | 4 ++-- src/onDeleteAccount.js | 13 +++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/core/types/types.js b/src/core/types/types.js index c32a10c..bcaa2ff 100644 --- a/src/core/types/types.js +++ b/src/core/types/types.js @@ -38,7 +38,7 @@ * @property {string} postalCode * @property {string} inseeCode * @property {string} endDate - * @property {number} [serviceId] + * @property {number} [serviceID] * @property {number} [ID] */ diff --git a/src/index.js b/src/index.js index b28010b..2341b17 100644 --- a/src/index.js +++ b/src/index.js @@ -235,14 +235,14 @@ async function deleteConsent( boToken ) { log('error', `Invalid or not found consent for user`) - if (userConsent.serviceId) { + if (userConsent.serviceID) { await terminateContract( baseUrl, apiAuthKey, sgeLogin, contractId, pointId, - userConsent.serviceId + userConsent.serviceID ) await deleteBoConsent( boBaseUrl, diff --git a/src/onDeleteAccount.js b/src/onDeleteAccount.js index 97fb151..add4eaf 100644 --- a/src/onDeleteAccount.js +++ b/src/onDeleteAccount.js @@ -1,3 +1,4 @@ +// @ts-check const { log, errors } = require('cozy-konnector-libs') const { getAccountRev, getAccountSecret } = require('./helpers/account') const { getBoConsent, deleteBoConsent } = require('./requests/bo') @@ -26,21 +27,21 @@ async function onDeleteAccount() { accountData.data.consentId ) - if (userConsent.pointId && userConsent.pointId) { - log('error', `Consent found for user`) - if (userConsent.serviceId) { + if (userConsent.ID && userConsent.pointID && userConsent.pointID) { + log('log', `Consent ${userConsent.ID} found for user`) + if (userConsent.serviceID) { await deleteBoConsent( secrets.boBaseUrl, secrets.boToken, - userConsent.id + userConsent.ID ) await terminateContract( secrets.baseUrl, secrets.apiAuthKey, secrets.sgeLogin, secrets.contractId, - userConsent.pointId, - userConsent.serviceId + userConsent.pointID, + userConsent.serviceID ) } else { log('error', `No service id retrieved from BO`) -- GitLab