Newer
Older
228001
228002
228003
228004
228005
228006
228007
228008
228009
228010
228011
228012
228013
228014
228015
228016
228017
228018
228019
228020
228021
228022
228023
228024
228025
228026
228027
228028
228029
228030
228031
228032
228033
228034
228035
228036
228037
228038
228039
228040
228041
228042
228043
228044
228045
228046
228047
228048
228049
228050
228051
228052
228053
228054
228055
228056
228057
228058
228059
228060
228061
228062
228063
228064
228065
228066
228067
228068
228069
228070
228071
228072
228073
228074
228075
228076
228077
228078
228079
228080
228081
228082
228083
228084
228085
228086
228087
228088
228089
228090
228091
228092
228093
228094
228095
228096
228097
228098
228099
228100
228101
228102
228103
228104
228105
228106
228107
228108
228109
228110
228111
228112
228113
228114
228115
228116
228117
228118
228119
228120
228121
228122
228123
228124
228125
228126
228127
228128
228129
228130
228131
228132
228133
228134
228135
228136
228137
228138
228139
228140
228141
228142
228143
228144
apiAuthKey,
loginUtilisateur,
fields.lastname,
fields.address,
fields.postalCode,
inseeCode
)
if (fields.pointId != pdl) {
log('error', 'PointId does not match')
if (isAlternateStart) {
throw errors.TERMS_VERSION_MISMATCH
} else {
throw errors.LOGIN_FAILED
}
}
return {
lastname: fields.lastname,
firstname: fields.firstname,
pointId: fields.pointId,
inseeCode,
postalCode: fields.postalCode,
address: fields.address,
}
}
module.exports = { verifyUserIdentity }
/***/ }),
/* 1596 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { log, errors } = __webpack_require__(1)
const soapRequest = __webpack_require__(1331)
const { parseUserPdl, parseTags, parseValue } = __webpack_require__(1555)
const { rechercherPoint } = __webpack_require__(1556)
const xml2js = __webpack_require__(1513)
/**
* @param {string} url
* @param {string} apiAuthKey
* @param {string} appLogin
* @param {string} name
* @param {string} address
* @param {string} postalCode
* @param {string} inseeCode
* @return {Promise<string | null>} User Pdl
*/
async function findUserPdl(
url,
apiAuthKey,
appLogin,
name,
address,
postalCode,
inseeCode
) {
log('info', 'Fetching user data')
const sgeHeaders = {
'Content-Type': 'text/xml;charset=UTF-8',
apikey: apiAuthKey,
}
const { response } = await soapRequest({
url: url,
headers: sgeHeaders,
xml: rechercherPoint(appLogin, name, postalCode, inseeCode, address),
}).catch(err => {
log('error', 'rechercherPointResponse')
log('error', err)
throw errors.LOGIN_FAILED
})
console.log(rechercherPoint(appLogin, name, postalCode, inseeCode, address))
const parsedReply = await xml2js.parseStringPromise(response.body, {
tagNameProcessors: [parseTags],
valueProcessors: [parseValue],
explicitArray: false,
})
try {
return parseUserPdl(parsedReply)
} catch (error) {
log('error', 'Error while parsing user PDL: ' + error)
log(
'error',
`Enedis issue ${parsedReply.Envelope.Body.Fault.detail.erreur.resultat.$.code}: ${parsedReply.Envelope.Body.Fault.faultstring}`
)
throw errors.LOGIN_FAILED
}
}
module.exports = { findUserPdl }
/***/ }),
/* 1597 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { default: axios } = __webpack_require__(1558)
const { log, errors } = __webpack_require__(1)
const API_URL = 'https://apicarto.ign.fr/api/codes-postaux/communes'
/**
* Return inseeCode given a postalCode
* @param {string} postalCode
* @param {string} [city]
* @return {Promise<string>} inseeCode
*/
async function getInseeCode(postalCode, city) {
try {
log('info', `Query getInseeCode for postalCode ${postalCode} / ${city}`)
const response = await axios.get(`${API_URL}/${postalCode}`)
if (response.data.length === 1) {
return response.data[0].codeCommune
} else {
if (!city) throw errors.USER_ACTION_NEEDED
const filteredResponse = response.data.filter(
town => town.nomCommune.toLowerCase() === city.toLowerCase()
)
return filteredResponse[0].codeCommune
}
} catch (error) {
log(
'error',
`Query getInseeCode failed for postalCode ${postalCode} / ${city}`
)
throw errors.USER_ACTION_NEEDED
}
}
module.exports = {
getInseeCode,
}
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { log, errors } = __webpack_require__(1)
const soapRequest = __webpack_require__(1331)
const { parseTags, parseValue, parseServiceId } = __webpack_require__(1555)
const { commanderCollectePublicationMesures } = __webpack_require__(1556)
const xml2js = __webpack_require__(1513)
* @param {string} url
* @param {string} apiAuthKey
* @param {string} appLogin
* @param {string} name
* @param {number} pointId
* @param {string} startDate
* @param {string} endDate
* @return {Promise<number>} User contractId
async function activateContract(
url,
apiAuthKey,
contractId,
name,
pointId,
startDate,
endDate
log('info', 'activateContract')
const sgeHeaders = {
'Content-Type': 'text/xml;charset=UTF-8',
apikey: apiAuthKey,
}
url: `${url}/enedis_SGE_CommandeCollectePublicationMesures/1.0`,
228184
228185
228186
228187
228188
228189
228190
228191
228192
228193
228194
228195
228196
228197
228198
228199
228200
228201
228202
228203
228204
228205
228206
228207
headers: sgeHeaders,
xml: commanderCollectePublicationMesures(
appLogin,
contractId,
pointId,
name,
startDate,
endDate
),
}).catch(err => {
log('error', 'commanderCollectePublicationMesures')
log('error', err)
throw errors.LOGIN_FAILED
})
const parsedReply = await xml2js.parseStringPromise(response.body, {
tagNameProcessors: [parseTags],
valueProcessors: [parseValue],
explicitArray: false,
})
try {
return parseServiceId(parsedReply)
} catch (error) {
log('error', 'Error while activating contract: ' + error)
log(
'error',
`Enedis issue ${parsedReply.Envelope.Body.Fault.detail.erreur.resultat.$.code}: ${parsedReply.Envelope.Body.Fault.faultstring}`
)
//TODO: handle SGT4B8: Il existe déjà plusieurs demandes en cours sur le point ?
module.exports = { activateContract }
/***/ }),
/* 1599 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { log, errors } = __webpack_require__(1)
const soapRequest = __webpack_require__(1331)
const { parseTags, parseValue, parseContracts } = __webpack_require__(1555)
const { rechercherServicesSouscritsMesures } = __webpack_require__(1556)
const xml2js = __webpack_require__(1513)
const { contractState, contractLibelle } = __webpack_require__(1600)
* @param {string} url
* @param {string} apiAuthKey
* @param {string} appLogin
* @param {number} pointId
* @return {Promise<number | null>} User contractId
async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) {
log('info', 'verifyContract')
const sgeHeaders = {
'Content-Type': 'text/xml;charset=UTF-8',
apikey: apiAuthKey,
}
228247
228248
228249
228250
228251
228252
228253
228254
228255
228256
228257
228258
228259
228260
228261
228262
228263
const { response } = await soapRequest({
url: `${url}/enedis_SGE_RechercheServicesMesures/1.0`,
headers: sgeHeaders,
xml: rechercherServicesSouscritsMesures(appLogin, contractId, pointId),
}).catch(err => {
log('error', 'rechercherServicesSouscritsMesures')
log('error', err)
throw errors.LOGIN_FAILED
})
const parsedReply = await xml2js.parseStringPromise(response.body, {
tagNameProcessors: [parseTags],
valueProcessors: [parseValue],
explicitArray: false,
})
try {
const currentContracts = parseContracts(parsedReply)
let currentContract = null
if (Array.isArray(currentContracts)) {
currentContract = parseContracts(parsedReply)[0]
} else {
currentContract = parseContracts(parsedReply)
}
if (
(currentContract.etatCode === contractState.ACTIF ||
currentContract.etatCode === contractState.DEMANDE) &&
currentContract.serviceSouscritLibelle === contractLibelle.ACTIF
)
return currentContract.serviceSouscritId
return null
} catch (error) {
log('error', 'Error while parsing user contract: ' + error)
log(
'error',
`Enedis issue ${parsedReply.Envelope.Body.Fault.detail.erreur.resultat.$.code}: ${parsedReply.Envelope.Body.Fault.faultstring}`
)
module.exports = { verifyContract }
/***/ }),
/* 1600 */
/***/ ((module) => {
* Enum for contract-state values.
* @readonly
* @enum {number}
const contractState = {
TERMINE: 'TERMINE',
ACTIF: 'ACTIF',
DEMANDE: 'DEMANDE',
}
/**
* Enum for contractLibelle values.
* @readonly
* @enum {number}
*/
const contractLibelle = {
ACTIF:
'Collecte de la courbe de charge au pas 30 min avec transmission quotidienne des données brutes en soutirage',
module.exports = { contractState, contractLibelle }
/***/ }),
/* 1601 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { log, errors } = __webpack_require__(1)
const soapRequest = __webpack_require__(1331)
const { parseTags, parseValue } = __webpack_require__(1555)
const { commanderArretServiceSouscritMesures } = __webpack_require__(1556)
const xml2js = __webpack_require__(1513)
* @param {string} url
* @param {string} apiAuthKey
* @param {string} appLogin
* @param {number} pointId
* @param {number} serviceId
* @return {Promise<string>} User contractId
async function terminateContract(
url,
apiAuthKey,
appLogin,
contractId,
pointId,
const sgeHeaders = {
'Content-Type': 'text/xml;charset=UTF-8',
apikey: apiAuthKey,
}
const { response } = await soapRequest({
url: `${url}/enedis_SGE_CommandeArretServiceSouscritMesures/1.0`,
228354
228355
228356
228357
228358
228359
228360
228361
228362
228363
228364
228365
228366
228367
228368
228369
228370
228371
228372
228373
228374
headers: sgeHeaders,
xml: commanderArretServiceSouscritMesures(
appLogin,
contractId,
pointId,
serviceId
),
}).catch(err => {
log('error', 'commanderArretServiceSouscritMesures')
log('error', err)
throw errors.VENDOR_DOWN
})
const parsedReply = await xml2js.parseStringPromise(response.body, {
tagNameProcessors: [parseTags],
valueProcessors: [parseValue],
explicitArray: false,
})
try {
// We don't need any action on reply for now
if (parsedReply.Envelope.Body.Fault) {
log(
'error',
`Enedis issue ${parsedReply.Envelope.Body.Fault.detail.erreur.resultat.$.code}: ${parsedReply.Envelope.Body.Fault.faultstring}`
)
}
return parsedReply
} catch (error) {
log('error', 'Error while parsing user contract termination: ' + error)
log(
'error',
`Enedis issue ${parsedReply.Envelope.Body.Fault.detail.erreur.resultat.$.code}: ${parsedReply.Envelope.Body.Fault.faultstring}`
)
module.exports = { terminateContract }
/***/ }),
/* 1602 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
228399
228400
228401
228402
228403
228404
228405
228406
228407
228408
228409
228410
228411
228412
228413
228414
228415
228416
228417
228418
228419
228420
228421
228422
228423
228424
228425
228426
228427
228428
228429
228430
228431
228432
228433
228434
228435
228436
228437
228438
228439
228440
228441
228442
// @ts-check
const { log, errors } = __webpack_require__(1)
const soapRequest = __webpack_require__(1331)
const {
parseTags,
parseValue,
parseContractStartDate,
} = __webpack_require__(1555)
const xml2js = __webpack_require__(1513)
const { consulterDonneesTechniquesContractuelles } = __webpack_require__(1556)
/**
* Get user contract start date
* @param {string} url
* @param {string} apiAuthKey
* @param {string} userLogin
* @param {number} pointId
* @returns {Promise<string>}
*/
async function getContractStartDate(url, apiAuthKey, userLogin, pointId) {
log('info', 'Fetching data start date')
const sgeHeaders = {
'Content-Type': 'text/xml;charset=UTF-8',
apikey: apiAuthKey,
}
const { response } = await soapRequest({
url: `${url}/enedis_SGE_ConsultationDonneesTechniquesContractuelles/1.0`,
headers: sgeHeaders,
xml: consulterDonneesTechniquesContractuelles(pointId, userLogin),
}).catch(err => {
log('error', 'Error while fetching contract start date : ' + err)
throw errors.VENDOR_DOWN
})
const result = await xml2js.parseStringPromise(response.body, {
tagNameProcessors: [parseTags],
valueProcessors: [parseValue],
explicitArray: false,
})
try {
return parseContractStartDate(result)
} catch (error) {
log('error', 'Error while processing contract start date: ' + error)
log(
'error',
`Enedis issue ${result.Envelope.Body.Fault.detail.erreur.resultat.$.code}: ${result.Envelope.Body.Fault.faultstring}`
)
throw errors.NOT_EXISTING_DIRECTORY
}
}
module.exports = { getContractStartDate }
/***/ }),
/* 1603 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
const { log, updateOrCreate } = __webpack_require__(1)
const cozyClient = __webpack_require__(485)
async function saveAccountData(accountId, accountData) {
log('info', `saveAccountData: ${accountId}`)
let account = await getAccount(accountId)
account = await updateOrCreate(
[{ ...account, data: accountData }],
'io.cozy.accounts'
)
return account
async function getAccount(accountId) {
log('info', `getAccount: ${accountId}`)
//TODO: refactor with usageof cozy-libs. Not working during implementation
const accounts = await cozyClient.data.findAll('io.cozy.accounts')
return accounts.filter(account =>
iSLocal() ? account._id === accountId : account.account_type === accountId
)[0]
module.exports = { getAccount, saveAccountData }
/***/ }),
/***/ ((module) => {
function iSLocal() {
return (
process.env.NODE_ENV === 'development' ||
process.env.NODE_ENV === 'local' ||
process.env.NODE_ENV === 'standalone'
)
}
module.exports = { iSLocal }
228500
228501
228502
228503
228504
228505
228506
228507
228508
228509
228510
228511
228512
228513
228514
228515
228516
228517
228518
228519
228520
228521
228522
228523
228524
228525
228526
228527
228528
228529
228530
228531
228532
228533
228534
228535
228536
228537
228538
228539
228540
228541
228542
228543
228544
228545
228546
228547
228548
228549
228550
228551
228552
228553
228554
228555
228556
228557
228558
228559
228560
228561
228562
228563
228564
228565
228566
228567
228568
228569
228570
228571
228572
228573
228574
228575
228576
228577
228578
228579
228580
228581
228582
228583
228584
228585
228586
228587
228588
228589
228590
228591
228592
/***/ })
/******/ ]);
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ id: moduleId,
/******/ loaded: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = __webpack_module_cache__;
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
/******/ () => (module['default']) :
/******/ () => (module);
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/node module decorator */
/******/ (() => {
/******/ __webpack_require__.nmd = (module) => {
/******/ module.paths = [];
/******/ if (!module.children) module.children = [];
/******/ return module;
/******/ };
/******/ })();
/******/
/************************************************************************/
/******/
/******/ // module cache are used so entry inlining is disabled
/******/ // startup
/******/ // Load entry module and return exports
/******/ var __webpack_exports__ = __webpack_require__(__webpack_require__.s = 0);
/******/
/******/ })()
;