Skip to content
Snippets Groups Projects
Commit ebbd568a authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

Merge branch 'chore/update-bo-url' into 'dev'

chore: update backoffice endpoint parsing

See merge request !53
parents 369c4306 9866fe35
No related branches found
No related tags found
2 merge requests!56v1.4.0,!53chore: update backoffice endpoint parsing
Pipeline #92214 passed
...@@ -4,4 +4,4 @@ Retrieving consumption data from Enedis SGE SOAP api ...@@ -4,4 +4,4 @@ Retrieving consumption data from Enedis SGE SOAP api
## Documentation ## 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/)
...@@ -38,7 +38,7 @@ async function verifyUserIdentity( ...@@ -38,7 +38,7 @@ async function verifyUserIdentity(
// Store if user is going through safety sge onboarding // Store if user is going through safety sge onboarding
let userSafetyOnBoarding = false let userSafetyOnBoarding = false
// First try with user adresse // First try with user address
let pdl = await findUserPdl( let pdl = await findUserPdl(
`${baseUrl}/enedis_SDE_recherche-point/1.0`, `${baseUrl}/enedis_SDE_recherche-point/1.0`,
apiAuthKey, apiAuthKey,
......
...@@ -148,6 +148,7 @@ async function start(fields, cozyParameters) { ...@@ -148,6 +148,7 @@ async function start(fields, cozyParameters) {
*/ */
log('info', 'User Logging...') log('info', 'User Logging...')
const boUrlSGE = new URL('/api/sge', boBaseUrl).href
if (isFirstStart(await getAccount(ACCOUNT_ID))) { if (isFirstStart(await getAccount(ACCOUNT_ID))) {
log('info', 'First start...') log('info', 'First start...')
transaction.startChild({ op: 'First start' }) transaction.startChild({ op: 'First start' })
...@@ -161,7 +162,7 @@ async function start(fields, cozyParameters) { ...@@ -161,7 +162,7 @@ async function start(fields, cozyParameters) {
exitIfDebug(user) exitIfDebug(user)
let consent = await createBoConsent( let consent = await createBoConsent(
boBaseUrl, boUrlSGE,
boToken, boToken,
pointId, pointId,
user.lastname, user.lastname,
...@@ -196,12 +197,12 @@ async function start(fields, cozyParameters) { ...@@ -196,12 +197,12 @@ async function start(fields, cozyParameters) {
contractStartDate, contractStartDate,
contractEndDate contractEndDate
).catch(async err => { ).catch(async err => {
await deleteBoConsent(boBaseUrl, boToken, consent.ID) await deleteBoConsent(boUrlSGE, boToken, consent.ID)
throw err throw err
}) })
} }
consent = await updateBoConsent( consent = await updateBoConsent(
boBaseUrl, boUrlSGE,
boToken, boToken,
consent, consent,
serviceId.toString() serviceId.toString()
...@@ -220,7 +221,7 @@ async function start(fields, cozyParameters) { ...@@ -220,7 +221,7 @@ async function start(fields, cozyParameters) {
transaction.startChild({ op: 'Alternate start' }) transaction.startChild({ op: 'Alternate start' })
const accountData = await getAccount(ACCOUNT_ID) const accountData = await getAccount(ACCOUNT_ID)
const userConsent = await getBoConsent( const userConsent = await getBoConsent(
boBaseUrl, boUrlSGE,
boToken, boToken,
accountData.data.consentId accountData.data.consentId
) )
...@@ -259,7 +260,7 @@ async function start(fields, cozyParameters) { ...@@ -259,7 +260,7 @@ async function start(fields, cozyParameters) {
sgeLogin, sgeLogin,
contractId, contractId,
pointId, pointId,
boBaseUrl, boUrlSGE,
boToken, boToken,
consentEndDate < today consentEndDate < today
) )
...@@ -347,24 +348,13 @@ async function deleteConsent( ...@@ -347,24 +348,13 @@ async function deleteConsent(
*/ */
async function gatherData(baseUrl, apiAuthKey, sgeLogin, pointId) { async function gatherData(baseUrl, apiAuthKey, sgeLogin, pointId) {
log('info', 'Querying data...') log('info', 'Querying data...')
await getData( const measuresUrl = new URL(
`${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees_v3/1.0`, '/enedis_SGE_ConsultationMesuresDetaillees_v3/1.0',
apiAuthKey, baseUrl
sgeLogin, ).href
pointId await getData(measuresUrl, apiAuthKey, sgeLogin, pointId)
) await getMaxPowerData(measuresUrl, apiAuthKey, sgeLogin, pointId)
await getMaxPowerData( await getDataHalfHour(measuresUrl, apiAuthKey, sgeLogin, pointId)
`${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees_v3/1.0`,
apiAuthKey,
sgeLogin,
pointId
)
await getDataHalfHour(
`${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees_v3/1.0`,
apiAuthKey,
sgeLogin,
pointId
)
log('info', 'Querying data: done') log('info', 'Querying data: done')
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment