From 493e5a5f1c331db923a3c9868431e0f20a0469ab Mon Sep 17 00:00:00 2001 From: build-token <build-token> Date: Mon, 29 Jan 2024 13:16:05 +0000 Subject: [PATCH] publish: update url in gatherData generated from commit 3d39bbae256a1506883d7858634531a0e3aa0086 --- index.js | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/index.js b/index.js index 6cf873e..a08278d 100644 --- a/index.js +++ b/index.js @@ -153,6 +153,7 @@ async function start(fields, cozyParameters) { */ log('info', 'User Logging...') + const boUrlSGE = new URL('/api/sge', boBaseUrl).href if (isFirstStart(await getAccount(ACCOUNT_ID))) { log('info', 'First start...') transaction.startChild({ op: 'First start' }) @@ -166,7 +167,7 @@ async function start(fields, cozyParameters) { exitIfDebug(user) let consent = await createBoConsent( - boBaseUrl, + boUrlSGE, boToken, pointId, user.lastname, @@ -201,12 +202,12 @@ async function start(fields, cozyParameters) { contractStartDate, contractEndDate ).catch(async err => { - await deleteBoConsent(boBaseUrl, boToken, consent.ID) + await deleteBoConsent(boUrlSGE, boToken, consent.ID) throw err }) } consent = await updateBoConsent( - boBaseUrl, + boUrlSGE, boToken, consent, serviceId.toString() @@ -225,7 +226,7 @@ async function start(fields, cozyParameters) { transaction.startChild({ op: 'Alternate start' }) const accountData = await getAccount(ACCOUNT_ID) const userConsent = await getBoConsent( - boBaseUrl, + boUrlSGE, boToken, accountData.data.consentId ) @@ -264,7 +265,7 @@ async function start(fields, cozyParameters) { sgeLogin, contractId, pointId, - boBaseUrl, + boUrlSGE, boToken, consentEndDate < today ) @@ -352,24 +353,13 @@ async function deleteConsent( */ async function gatherData(baseUrl, apiAuthKey, sgeLogin, pointId) { log('info', 'Querying data...') - await getData( - `${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees_v3/1.0`, - apiAuthKey, - sgeLogin, - pointId - ) - await getMaxPowerData( - `${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees_v3/1.0`, - apiAuthKey, - sgeLogin, - pointId - ) - await getDataHalfHour( - `${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees_v3/1.0`, - apiAuthKey, - sgeLogin, - pointId - ) + const measuresUrl = new URL( + '/enedis_SGE_ConsultationMesuresDetaillees_v3/1.0', + baseUrl + ).href + await getData(measuresUrl, apiAuthKey, sgeLogin, pointId) + await getMaxPowerData(measuresUrl, apiAuthKey, sgeLogin, pointId) + await getDataHalfHour(measuresUrl, apiAuthKey, sgeLogin, pointId) log('info', 'Querying data: done') } -- GitLab