diff --git a/README.md b/README.md index f70e98872cc60929900ad995b01b2dc73dae935c..b01b30f63ee10dc67f45c60e3cfdca1c8d63d74c 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ Retrieving consumption data from Enedis SGE SOAP api ## Documentation -[Enedis SGE Konnector - Self-Data](https://doc.self-data.alpha.grandlyon.com/konnectors/enedis-sge/) +[Enedis SGE Konnector - Self-Data](https://doc-self-data.apps.grandlyon.com/konnectors/enedis-sge/) diff --git a/src/core/verifyUserIdentity.js b/src/core/verifyUserIdentity.js index a7376fd11d77f29e60011425efa6c76a22cc9953..08a7d20a9981cb853dcdb1be6c0d052e350fd0f1 100644 --- a/src/core/verifyUserIdentity.js +++ b/src/core/verifyUserIdentity.js @@ -38,7 +38,7 @@ async function verifyUserIdentity( // Store if user is going through safety sge onboarding let userSafetyOnBoarding = false - // First try with user adresse + // First try with user address let pdl = await findUserPdl( `${baseUrl}/enedis_SDE_recherche-point/1.0`, apiAuthKey, diff --git a/src/index.js b/src/index.js index 4df3db2428e06c95d30e90c38371b74a4fd0b575..b64aab5151a969aec29b32c2506664f723563a06 100644 --- a/src/index.js +++ b/src/index.js @@ -148,6 +148,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' }) @@ -161,7 +162,7 @@ async function start(fields, cozyParameters) { exitIfDebug(user) let consent = await createBoConsent( - boBaseUrl, + boUrlSGE, boToken, pointId, user.lastname, @@ -196,12 +197,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() @@ -220,7 +221,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 ) @@ -259,7 +260,7 @@ async function start(fields, cozyParameters) { sgeLogin, contractId, pointId, - boBaseUrl, + boUrlSGE, boToken, consentEndDate < today ) @@ -347,24 +348,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') }