diff --git a/src/index.js b/src/index.js index cd15b0664bef0290aaa6fa23b099054306e29f32..1340b20139c232fc03cf1bda660f2da4821d9283 100644 --- a/src/index.js +++ b/src/index.js @@ -6,6 +6,7 @@ const { addData, errors, } = require('cozy-konnector-libs') +const path = require('node:path') const soapRequest = require('easy-soap-request') const moment = require('moment') require('moment-timezone') @@ -276,25 +277,17 @@ async function deleteConsent( */ async function gatherData(baseUrl, apiAuthKey, sgeLogin, pointId) { log('info', 'Querying data...') + const measuresUrl = new URL( + path.resolve( + new URL(baseUrl).pathname, + '/enedis_SGE_ConsultationMesuresDetaillees/1.0' + ), + baseUrl + ).href await getContractStartDate(baseUrl, apiAuthKey, sgeLogin, pointId) - await getData( - `${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees/1.0`, - apiAuthKey, - sgeLogin, - pointId - ) - await getMaxPowerData( - `${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees/1.0`, - apiAuthKey, - sgeLogin, - pointId - ) - await getDataHalfHour( - `${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees/1.0`, - apiAuthKey, - sgeLogin, - pointId - ) + await getData(measuresUrl, apiAuthKey, sgeLogin, pointId) + await getMaxPowerData(measuresUrl, apiAuthKey, sgeLogin, pointId) + await getDataHalfHour(measuresUrl, apiAuthKey, sgeLogin, pointId) log('info', 'Querying data: done') }