Newer
Older
// @ts-check
const { log } = require('cozy-konnector-libs')
/**
* Get daily data up to 36 months & P max
* @param {string} appLogin
* @param {string} startDt
* @param {string} endDt
* @param {'COURBE' | 'ENERGIE' | 'PMAX'} mesureType
* @param {'EA' | 'PA' | 'PMA'} unit
function consultationMesuresDetaillees(
startDt,
endDt,
mesureType = 'ENERGIE',
unit = 'EA'
) {
log(
'info',
`consultationMesuresDetaillees - ${mesureType}/${unit} between ${startDt} and ${endDt}`
)
return `<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v2="http://www.enedis.fr/sge/b2b/services/consultationmesuresdetaillees/v2.0"
xmlns:v1="http://www.enedis.fr/sge/b2b/technique/v1.0">
<soapenv:Header/>
<soapenv:Body>
<v2:consulterMesuresDetaillees>
<demande>
<initiateurLogin>${appLogin}</initiateurLogin>
<pointId>${pointId}</pointId>
<mesuresTypeCode>${mesureType}</mesuresTypeCode>
<grandeurPhysique>${unit}</grandeurPhysique>
<soutirage>true</soutirage>
<injection>false</injection>
<dateDebut>${startDt}</dateDebut>
<dateFin>${endDt}</dateFin>
<mesuresCorrigees>false</mesuresCorrigees>
<accordClient>true</accordClient>
</demande>
</v2:consulterMesuresDetaillees>
</soapenv:Body>
</soapenv:Envelope>
`
}
/**
* Get user max power
* @param {number} pointId
* @param {string} appLogin
* @param {'COURBE' | 'ENERGIE' | 'PMAX'} mesureType
* @param {'EA' | 'PA' | 'PMA'} unit
function consultationMesuresDetailleesMaxPower(
pointId,
appLogin,
startDt,
endDt,
mesureType = 'PMAX',
unit = 'PMA'
) {
log(
'info',
`consultationMesuresDetaillees - ${mesureType}/${unit} between ${startDt} and ${endDt}`
)
return `<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v2="http://www.enedis.fr/sge/b2b/services/consultationmesuresdetaillees/v2.0"
xmlns:v1="http://www.enedis.fr/sge/b2b/technique/v1.0">
<soapenv:Header/>
<soapenv:Body>
<v2:consulterMesuresDetaillees>
<demande>
<initiateurLogin>${appLogin}</initiateurLogin>
<mesuresTypeCode>${mesureType}</mesuresTypeCode>
<grandeurPhysique>${unit}</grandeurPhysique>
<soutirage>true</soutirage>
<injection>false</injection>
<dateDebut>${startDt}</dateDebut>
<dateFin>${endDt}</dateFin>
<mesuresPas>P1D</mesuresPas>
<mesuresCorrigees>false</mesuresCorrigees>
<accordClient>true</accordClient>
</demande>
</v2:consulterMesuresDetaillees>
</soapenv:Body>
</soapenv:Envelope>
`
}
/**
* Get user technical data (contract start date)
* @param {number} pointId
* @param {string} appLogin
* @returns {string}
*/
function consulterDonneesTechniquesContractuelles(pointId, appLogin) {
log('info', `Query consulterDonneesTechniquesContractuelles`)
return `<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v2="http://www.enedis.fr/sge/b2b/services/consulterdonneestechniquescontractuelles/v1.0"
xmlns:v1="http://www.enedis.fr/sge/b2b/technique/v1.0">
<soapenv:Header/>
<soapenv:Body>
<v2:consulterDonneesTechniquesContractuelles>
<pointId>${pointId}</pointId>
<loginUtilisateur>${appLogin}</loginUtilisateur>
<autorisationClient>true</autorisationClient>
</v2:consulterDonneesTechniquesContractuelles>
</soapenv:Body>
</soapenv:Envelope>
`
}
/**
* Use rechercherPoint to find user PDL if exist
* @param {string} name
* @param {string} postalCode
* @param {string} address
* @returns {string} PDL
*/
function rechercherPoint(appLogin, name, postalCode, inseeCode, address) {
log('info', `Query rechercherPoint`)
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
return `<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v2="http://www.enedis.fr/sge/b2b/services/rechercherpoint/v2.0"
xmlns:v1="http://www.enedis.fr/sge/b2b/technique/v1.0">
<soapenv:Header/>
<soapenv:Body>
<v2:rechercherPoint>
<criteres>
<adresseInstallation>
<numeroEtNomVoie>${address}</numeroEtNomVoie>
<codePostal>${postalCode}</codePostal>
<codeInseeCommune>${inseeCode}</codeInseeCommune>
</adresseInstallation>
<nomClientFinalOuDenominationSociale>${name}</nomClientFinalOuDenominationSociale>
<rechercheHorsPerimetre>true</rechercheHorsPerimetre>
</criteres>
<loginUtilisateur>${appLogin}</loginUtilisateur>
</v2:rechercherPoint>
</soapenv:Body>
</soapenv:Envelope>`
}
/**
* Search if user as a service
* @param {string} appLogin
* @param {string} contractId
* @param {string} pointId
* @returns {*}
*/
function searchServiceSouscrit(appLogin, contractId, pointId) {
log('info', `Query commanderCollectePublicationMesures`)
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
return `<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v2="http://www.enedis.fr/sge/b2b/rechercherservicessouscritsmesures/v1.0"
xmlns:v1="http://www.enedis.fr/sge/b2b/technique/v1.0">
<soapenv:Header/>
<soapenv:Body>
<v2:rechercherServicesSouscritsMesures>
<criteres>
<pointId>${pointId}</pointId>
<contratId>${contractId}</contratId>
</criteres>
<loginUtilisateur>${appLogin}</loginUtilisateur>
</v2:rechercherServicesSouscritsMesures>
</soapenv:Body>
</soapenv:Envelope>`
}
/**
* Activate half hour data collect for user
* @param {string} appLogin
* @param {string} contractId
* @param {string} pointId
* @param {string} name
* @param {string} startDate
* @param {string} endDate
* @returns {*}
*/
function commanderCollectePublicationMesures(
appLogin,
contractId,
pointId,
name,
startDate,
endDate
) {
log('info', `Query commanderCollectePublicationMesures`)
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
return `<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v2="http://www.enedis.fr/sge/b2b/commandercollectepublicationmesures/v3.0"
xmlns:v1="http://www.enedis.fr/sge/b2b/technique/v1.0">
<soapenv:Header/>
<soapenv:Body>
<v2:commanderCollectePublicationMesures>
<demande>
<donneesGenerales>
<objetCode>AME</objetCode>
<pointId>${pointId}</pointId>
<initiateurLogin>${appLogin}</initiateurLogin>
<contratId>${contractId}</contratId>
</donneesGenerales>
<accesMesures>
<dateDebut>${startDate}</dateDebut>
<dateFin>${endDate}</dateFin>
<declarationAccordClient>
<accord>true</accord>
<personnePhysique>
<nom>${name}</nom>
</personnePhysique>
</declarationAccordClient>
<mesuresTypeCode>CDC</mesuresTypeCode>
<soutirage>true</soutirage>
<injection>false</injection>
<mesuresPas>PT30M</mesuresPas>
<mesuresCorrigees>false</mesuresCorrigees>
<transmissionRecurrente>true</transmissionRecurrente>
<periodiciteTransmission>P1D</periodiciteTransmission>
</accesMesures>
</demande>
</v2:commanderCollectePublicationMesures>
</soapenv:Body>
</soapenv:Envelope>`
}
/**
*
* @param {string} appLogin
* @param {string} contractId
* @param {string} pointId
* @param {string} serviceSouscritId
* @returns {*}
*/
function stopDataCollect(appLogin, contractId, pointId, serviceSouscritId) {
log('info', `Query stopDataCollect`)
return `<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v2="http://www.enedis.fr/sge/b2b/commanderarretservicesouscritmesures/v1.0"
xmlns:v1="http://www.enedis.fr/sge/b2b/technique/v1.0">
<soapenv:Header/>
<soapenv:Body>
<v2:commanderArretServiceSouscritMesures>
<demande>
<donneesGenerales>
<objetCode>ASS</objetCode>
<pointId>${pointId}</pointId>
<initiateurLogin>${appLogin}</initiateurLogin>
<contratId>${contractId}</contratId>
</donneesGenerales>
<arretServiceSouscrit>
<serviceSouscritId>${serviceSouscritId}</serviceSouscritId>
</arretServiceSouscrit>
</demande>
</v2:commanderArretServiceSouscritMesures>
</soapenv:Body>
</soapenv:Envelope>`
}
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
/**
* Return inseeCode given a postalCode
* @param {string} postalCode
* @return {string} inseeCode
*/
function getInseeCode(postalCode) {
//TODO: Implement
log('info', `Query getInseeCode for postalCode ${postalCode}`)
throw new Error('Function not implemented.')
}
/**
*
*/
function createBoConsent() {
//TODO: Implement
log('info', `Query createBoConsent`)
throw new Error('Function not implemented.')
}
/**
*
*/
function updateBoConsent() {
//TODO: Implement
log('info', `Query updateBoConsent`)
throw new Error('Function not implemented.')
}
/**
*
*/
function getBoConsent() {
//TODO: Implement
log('info', `Query getBoConsent`)
throw new Error('Function not implemented.')
}
/**
*
*/
function deleteBoConsent() {
//TODO: deleteBoConsent
log('info', `Query createBoConsent`)
throw new Error('Function not implemented.')
}
consulterDonneesTechniquesContractuelles,
consultationMesuresDetailleesMaxPower,
consultationMesuresDetaillees,
commanderCollectePublicationMesures,
getInseeCode,
createBoConsent,
updateBoConsent,
getBoConsent,
deleteBoConsent,