Newer
Older
} else {
strictFail(parser, 'Invalid attribute name')
parser.state = S.ATTRIB
}
}
continue
case S.ATTRIB_VALUE:
if (isWhitespace(c)) {
continue
} else if (isQuote(c)) {
parser.q = c
parser.state = S.ATTRIB_VALUE_QUOTED
} else {
strictFail(parser, 'Unquoted attribute value')
parser.state = S.ATTRIB_VALUE_UNQUOTED
parser.attribValue = c
}
continue
case S.ATTRIB_VALUE_QUOTED:
if (c !== parser.q) {
if (c === '&') {
parser.state = S.ATTRIB_VALUE_ENTITY_Q
} else {
parser.attribValue += c
}
continue
}
attrib(parser)
parser.q = ''
parser.state = S.ATTRIB_VALUE_CLOSED
continue
223035
223036
223037
223038
223039
223040
223041
223042
223043
223044
223045
223046
223047
223048
223049
223050
case S.ATTRIB_VALUE_CLOSED:
if (isWhitespace(c)) {
parser.state = S.ATTRIB
} else if (c === '>') {
openTag(parser)
} else if (c === '/') {
parser.state = S.OPEN_TAG_SLASH
} else if (isMatch(nameStart, c)) {
strictFail(parser, 'No whitespace between attributes')
parser.attribName = c
parser.attribValue = ''
parser.state = S.ATTRIB_NAME
} else {
strictFail(parser, 'Invalid attribute name')
}
continue
223052
223053
223054
223055
223056
223057
223058
223059
223060
223061
223062
223063
223064
223065
223066
223067
case S.ATTRIB_VALUE_UNQUOTED:
if (!isAttribEnd(c)) {
if (c === '&') {
parser.state = S.ATTRIB_VALUE_ENTITY_U
} else {
parser.attribValue += c
}
continue
}
attrib(parser)
if (c === '>') {
openTag(parser)
} else {
parser.state = S.ATTRIB
}
continue
223069
223070
223071
223072
223073
223074
223075
223076
223077
223078
223079
223080
223081
223082
223083
223084
223085
223086
223087
223088
223089
223090
223091
223092
223093
223094
223095
223096
223097
case S.CLOSE_TAG:
if (!parser.tagName) {
if (isWhitespace(c)) {
continue
} else if (notMatch(nameStart, c)) {
if (parser.script) {
parser.script += '</' + c
parser.state = S.SCRIPT
} else {
strictFail(parser, 'Invalid tagname in closing tag.')
}
} else {
parser.tagName = c
}
} else if (c === '>') {
closeTag(parser)
} else if (isMatch(nameBody, c)) {
parser.tagName += c
} else if (parser.script) {
parser.script += '</' + parser.tagName
parser.tagName = ''
parser.state = S.SCRIPT
} else {
if (!isWhitespace(c)) {
strictFail(parser, 'Invalid tagname in closing tag')
}
parser.state = S.CLOSE_TAG_SAW_WHITE
}
continue
case S.CLOSE_TAG_SAW_WHITE:
if (isWhitespace(c)) {
continue
}
if (c === '>') {
closeTag(parser)
} else {
strictFail(parser, 'Invalid characters in closing tag')
}
continue
case S.TEXT_ENTITY:
case S.ATTRIB_VALUE_ENTITY_Q:
case S.ATTRIB_VALUE_ENTITY_U:
var returnState
var buffer
switch (parser.state) {
case S.TEXT_ENTITY:
returnState = S.TEXT
buffer = 'textNode'
break
case S.ATTRIB_VALUE_ENTITY_Q:
returnState = S.ATTRIB_VALUE_QUOTED
buffer = 'attribValue'
break
case S.ATTRIB_VALUE_ENTITY_U:
returnState = S.ATTRIB_VALUE_UNQUOTED
buffer = 'attribValue'
break
}
if (c === ';') {
parser[buffer] += parseEntity(parser)
parser.entity = ''
parser.state = returnState
} else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
parser.entity += c
} else {
strictFail(parser, 'Invalid character in entity name')
parser[buffer] += '&' + parser.entity + c
parser.entity = ''
parser.state = returnState
}
default:
throw new Error(parser, 'Unknown state: ' + parser.state)
if (parser.position >= parser.bufferCheckPosition) {
checkBufferLength(parser)
}
return parser
}
223158
223159
223160
223161
223162
223163
223164
223165
223166
223167
223168
223169
223170
223171
223172
223173
223174
223175
223176
223177
223178
223179
223180
223181
223182
223183
223184
223185
223186
223187
223188
223189
223190
223191
223192
223193
223194
223195
223196
223197
223198
223199
223200
223201
223202
223203
223204
223205
223206
223207
223208
223209
223210
223211
223212
223213
/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
/* istanbul ignore next */
if (!String.fromCodePoint) {
(function () {
var stringFromCharCode = String.fromCharCode
var floor = Math.floor
var fromCodePoint = function () {
var MAX_SIZE = 0x4000
var codeUnits = []
var highSurrogate
var lowSurrogate
var index = -1
var length = arguments.length
if (!length) {
return ''
}
var result = ''
while (++index < length) {
var codePoint = Number(arguments[index])
if (
!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
codePoint < 0 || // not a valid Unicode code point
codePoint > 0x10FFFF || // not a valid Unicode code point
floor(codePoint) !== codePoint // not an integer
) {
throw RangeError('Invalid code point: ' + codePoint)
}
if (codePoint <= 0xFFFF) { // BMP code point
codeUnits.push(codePoint)
} else { // Astral code point; split in surrogate halves
// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
codePoint -= 0x10000
highSurrogate = (codePoint >> 10) + 0xD800
lowSurrogate = (codePoint % 0x400) + 0xDC00
codeUnits.push(highSurrogate, lowSurrogate)
}
if (index + 1 === length || codeUnits.length > MAX_SIZE) {
result += stringFromCharCode.apply(null, codeUnits)
codeUnits.length = 0
}
}
return result
}
/* istanbul ignore next */
if (Object.defineProperty) {
Object.defineProperty(String, 'fromCodePoint', {
value: fromCodePoint,
configurable: true,
writable: true
})
} else {
String.fromCodePoint = fromCodePoint
}
}())
}
})( false ? 0 : exports)
/* 1551 */
/***/ (function(__unused_webpack_module, exports) {
// Generated by CoffeeScript 1.12.7
(function() {
"use strict";
exports.stripBOM = function(str) {
if (str[0] === '\uFEFF') {
return str.substring(1);
} else {
return str;
/* 1552 */
/***/ (function(__unused_webpack_module, exports) {
// Generated by CoffeeScript 1.12.7
(function() {
exports.normalize = function(str) {
return str.toLowerCase();
};
exports.firstCharLowerCase = function(str) {
return str.charAt(0).toLowerCase() + str.slice(1);
};
exports.stripPrefix = function(str) {
return str.replace(prefixMatch, '');
};
exports.parseNumbers = function(str) {
if (!isNaN(str)) {
str = str % 1 === 0 ? parseInt(str, 10) : parseFloat(str);
exports.parseBooleans = function(str) {
if (/^(?:true|false)$/i.test(str)) {
str = str.toLowerCase() === 'true';
}
return str;
};
/***/ }),
/* 1553 */
/***/ ((module) => {
"use strict";
module.exports = require("timers");
/* 1554 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { log, cozyClient } = __webpack_require__(1)
223288
223289
223290
223291
223292
223293
223294
223295
223296
223297
223298
223299
223300
223301
223302
/**
* Retrieve and remove old data for a specific doctype
* Return an Array of agregated data
*/
async function buildAgregatedData(data, doctype) {
let agregatedData = []
// eslint-disable-next-line no-unused-vars
for (let [key, value] of Object.entries(data)) {
const data = buildDataFromKey(doctype, key, value)
const oldValue = await resetInProgressAggregatedData(data, doctype)
data.load += oldValue
agregatedData.push(data)
}
return agregatedData
}
223304
223305
223306
223307
223308
223309
223310
223311
223312
223313
223314
223315
223316
223317
223318
223319
223320
223321
223322
223323
223324
223325
223326
223327
223328
223329
223330
223331
223332
223333
223334
223335
223336
223337
223338
/**
* Format an entry for DB storage
* using key and value
* For year doctype: key = "YYYY"
* For month doctype: key = "YYYY-MM"
*/
function buildDataFromKey(doctype, key, value) {
let year, month, day, hour
if (doctype === 'com.grandlyon.enedis.year') {
year = key
month = 1
day = 0
hour = 0
} else if (doctype === 'com.grandlyon.enedis.month') {
const split = key.split('-')
year = split[0]
month = split[1]
day = 0
hour = 0
} else {
const split = key.split('-')
year = split[0]
month = split[1]
day = split[2]
hour = split[3]
}
return {
load: Math.round(value * 10000) / 10000,
year: parseInt(year),
month: parseInt(month),
day: parseInt(day),
hour: parseInt(hour),
minute: 0,
}
}
223340
223341
223342
223343
223344
223345
223346
223347
223348
223349
223350
223351
223352
223353
223354
223355
223356
223357
223358
223359
223360
223361
223362
223363
223364
223365
223366
223367
223368
223369
223370
223371
223372
223373
223374
223375
223376
223377
223378
223379
223380
223381
223382
223383
223384
223385
223386
/**
* Function handling special case.
* The temporary aggregated data need to be remove in order for the most recent one te be saved.
* ex for com.grandlyon.enedis.year :
* { load: 76.712, year: 2020, ... } need to be replace by
* { load: 82.212, year: 2020, ... } after enedis data reprocess
*/
async function resetInProgressAggregatedData(data, doctype) {
// /!\ Warning: cannot use mongo queries because not supported for dev by cozy-konnectors-libs
log('debug', doctype, 'Remove aggregated data for')
const result = await cozyClient.data.findAll(doctype)
if (result && result.length > 0) {
// Filter data to remove
var filtered = []
if (doctype === 'com.grandlyon.enedis.year') {
// Yearly case
filtered = result.filter(function(el) {
return el.year == data.year
})
} else if (doctype === 'com.grandlyon.enedis.month') {
// Monthly case
filtered = result.filter(function(el) {
return el.year == data.year && el.month == data.month
})
} else {
// Hourly case
filtered = result.filter(function(el) {
return (
el.year == data.year &&
el.month == data.month &&
el.day == data.day &&
el.hour == data.hour
)
})
}
// Remove data
let sum = 0.0
// eslint-disable-next-line no-unused-vars
for (const doc of filtered) {
sum += doc.load
log('debug', doc, 'Removing this entry for ' + doctype)
await cozyClient.data.delete(doctype, doc)
}
return sum
}
return 0.0
}
module.exports = {
buildAgregatedData,
}
/***/ }),
/* 1555 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { log } = __webpack_require__(1)
const moment = __webpack_require__(1373)
/**
* Return User PDL
* @param {string} result
* @returns {string}
*/
function parseUserPdl(result) {
log('info', 'Parsing User Pdl')
const json = JSON.stringify(result)
return JSON.parse(json)['Envelope']['Body']['rechercherPointResponse'][
'points'
]['point']['$'].id
}
/**
* Return User contract start date
* @param {string} result
* @returns {string}
*/
function parseContractStartDate(result) {
log('info', 'Parsing contract start date')
const json = JSON.stringify(result)
return JSON.parse(json)['Envelope']['Body'][
'consulterDonneesTechniquesContractuellesResponse'
]['point']['donneesGenerales'][
'dateDerniereModificationFormuleTarifaireAcheminement'
]
}
/**
* Return User contract start date
* @param {string} result
* @returns {Contract[]}
*/
function parseContracts(result) {
log('info', 'Parsing contract')
const json = JSON.stringify(result)
return JSON.parse(json)['Envelope']['Body'][
'rechercherServicesSouscritsMesuresResponse'
]['servicesSouscritsMesures']['serviceSouscritMesures']
}
/**
* Return User contract start date
* @param {string} result
* @returns {number}
*/
function parseServiceId(result) {
log('info', 'Parsing serviceId')
const json = JSON.stringify(result)
return JSON.parse(json)['Envelope']['Body'][
'commanderCollectePublicationMesuresResponse'
]['serviceSouscritId']
}
/**
* Parsing SGE xml reply to get only mesure data
* @param {string} result
* @returns {SGEData[]}
*/
function parseSgeXmlData(result) {
log('info', 'Parsing list of documents')
const json = JSON.stringify(result)
return JSON.parse(json)['Envelope']['Body'][
'consulterMesuresDetailleesResponse'
]['grandeur']['mesure']
}
223468
223469
223470
223471
223472
223473
223474
223475
223476
223477
223478
223479
223480
223481
223482
223483
223484
223485
223486
/**
* Format data for DB storage
* @param {SGEData[]} data
* @returns {Promise<EnedisKonnectorData[]>} Parsed timestamp array
*/
async function formateDataForDoctype(data) {
log('info', 'Formating data')
return data.map(record => {
const date = moment(record.d, 'YYYY/MM/DD h:mm:ss')
return {
load: record.v,
year: parseInt(date.format('YYYY')),
month: parseInt(date.format('M')),
day: parseInt(date.format('D')),
hour: parseInt(date.format('H')),
minute: parseInt(date.format('m')),
}
})
}
/**
* Format tag in order to be manipulated easly
* @param {string} name
* @returns {string} name
*/
function parseTags(name) {
if (name.split(':')[1] !== undefined) {
return name.split(':')[1]
}
return name
}
/**
*
* @param {string} value
* @param {string} name
* @returns {string|number} value
*/
function parseValue(value, name) {
// Wh => KWh
if (name === 'v') {
return parseFloat((parseInt(value) / 1000).toFixed(2))
}
return value
}
module.exports = {
parseSgeXmlData,
formateDataForDoctype,
parseTags,
parseValue,
parseUserPdl,
parseContracts,
parseContractStartDate,
parseServiceId,
}
/***/ }),
/* 1556 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { log } = __webpack_require__(1)
223533
223534
223535
223536
223537
223538
223539
223540
223541
223542
223543
223544
223545
223546
223547
223548
223549
223550
223551
223552
223553
223554
223555
223556
223557
223558
223559
223560
223561
223562
223563
223564
223565
223566
223567
223568
223569
223570
223571
223572
223573
223574
223575
223576
223577
223578
/**
* Get daily data up to 36 months & P max
* @param {number} pointId
* @param {string} appLogin
* @param {string} startDate
* @param {string} endDate
* @param {'COURBE' | 'ENERGIE' | 'PMAX'} mesureType
* @param {'EA' | 'PA' | 'PMA'} unit
* @returns {string}
*/
function consultationMesuresDetaillees(
pointId,
appLogin,
startDate,
endDate,
mesureType = 'ENERGIE',
unit = 'EA'
) {
log(
'info',
`Query consultationMesuresDetaillees - ${mesureType}/${unit} between ${startDate} and ${endDate}`
)
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>${startDate}</dateDebut>
<dateFin>${endDate}</dateFin>
<mesuresCorrigees>false</mesuresCorrigees>
<accordClient>true</accordClient>
</demande>
</v2:consulterMesuresDetaillees>
</soapenv:Body>
</soapenv:Envelope>
`
}
223580
223581
223582
223583
223584
223585
223586
223587
223588
223589
223590
223591
223592
223593
223594
223595
223596
223597
223598
223599
223600
223601
223602
223603
223604
223605
223606
223607
223608
223609
223610
223611
223612
223613
223614
223615
223616
223617
223618
223619
223620
223621
223622
223623
223624
223625
223626
/**
* Get user max power
* @param {number} pointId
* @param {string} appLogin
* @param {string} startDate
* @param {string} endDate
* @param {'COURBE' | 'ENERGIE' | 'PMAX'} mesureType
* @param {'EA' | 'PA' | 'PMA'} unit
* @returns {string}
*/
function consultationMesuresDetailleesMaxPower(
pointId,
appLogin,
startDate,
endDate,
mesureType = 'PMAX',
unit = 'PMA'
) {
log(
'info',
`Query consultationMesuresDetaillees - ${mesureType}/${unit} between ${startDate} and ${endDate}`
)
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>${startDate}</dateDebut>
<dateFin>${endDate}</dateFin>
<mesuresPas>P1D</mesuresPas>
<mesuresCorrigees>false</mesuresCorrigees>
<accordClient>true</accordClient>
</demande>
</v2:consulterMesuresDetaillees>
</soapenv:Body>
</soapenv:Envelope>
`
}
223628
223629
223630
223631
223632
223633
223634
223635
223636
223637
223638
223639
223640
223641
223642
223643
223644
223645
223646
223647
223648
223649
223650
/**
* 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>
`
}
223652
223653
223654
223655
223656
223657
223658
223659
223660
223661
223662
223663
223664
223665
223666
223667
223668
223669
223670
223671
223672
223673
223674
223675
223676
223677
223678
223679
223680
223681
223682
223683
223684
223685
/**
* Use rechercherPoint to find user PDL if exist
* @param {string} name
* @param {string} postalCode
* @param {string} inseeCode
* @param {string} [address]
* @returns {string} PDL
*/
function rechercherPoint(appLogin, name, postalCode, inseeCode, address) {
log(
'info',
`Query rechercherPoint - postal code / insee code: ${postalCode} / ${inseeCode}`
)
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>`
}
223687
223688
223689
223690
223691
223692
223693
223694
223695
223696
223697
223698
223699
223700
223701
223702
223703
223704
223705
223706
223707
223708
223709
223710
223711
/**
* Search if user as a service
* @param {string} appLogin
* @param {string} contractId
* @param {number} pointId
* @returns {*}
*/
function rechercherServicesSouscritsMesures(appLogin, contractId, pointId) {
log('info', `Query rechercherServicesSouscritsMesures`)
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>`
}
223713
223714
223715
223716
223717
223718
223719
223720
223721
223722
223723
223724
223725
223726
223727
223728
223729
223730
223731
223732
223733
223734
223735
223736
223737
223738
223739
223740
223741
223742
223743
223744
223745
223746
223747
223748
223749
223750
223751
223752
223753
223754
223755
223756
223757
223758
223759
223760
223761
223762
223763
223764
223765
223766
223767
223768
223769
223770
/**
* Activate half hour data collect for user
* @param {string} appLogin
* @param {string} contractId
* @param {number} pointId
* @param {string} name
* @param {string} startDate
* @param {string} endDate
* @returns {*}
*/
function commanderCollectePublicationMesures(
appLogin,
contractId,
pointId,
name,
startDate,
endDate
) {
log(
'info',
`Query commanderCollectePublicationMesures - between ${startDate} and ${endDate}`
)
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>`
}
223772
223773
223774
223775
223776
223777
223778
223779
223780
223781
223782
223783
223784
223785
223786
223787
223788
223789
223790
223791
223792
223793
223794
223795
223796
223797
223798
223799
223800
223801
223802
223803
223804
223805
223806
223807
223808
223809
223810
223811
/**
* Stop the user consent
* @param {string} appLogin
* @param {string} contractId
* @param {number} pointId
* @param {number} serviceSouscritId
* @returns {*}
*/
function commanderArretServiceSouscritMesures(
appLogin,
contractId,
pointId,
serviceSouscritId
) {
log(
'info',
`Query commanderArretServiceSouscritMesures - serviceSouscritId: ${serviceSouscritId}`
)
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>`
}
module.exports = {
consulterDonneesTechniquesContractuelles,
consultationMesuresDetailleesMaxPower,
consultationMesuresDetaillees,
rechercherPoint,
rechercherServicesSouscritsMesures,
commanderCollectePublicationMesures,
commanderArretServiceSouscritMesures,
}
/***/ }),
/* 1557 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
* @param {string} lastname
* @param {string} firstname
223835
223836
223837
223838
223839
223840
223841
223842
223843
223844
223845
223846
223847
223848
223849
223850
223851
223852
223853
223854
223855
223856
223857
223858
223859
* @param {string} address
* @param {string} postalCode
* @param {string} inseeCode
* @returns {Consent}
*/
function createBoConsent(
pointId,
lastname,
firstname,
address,
postalCode,
inseeCode
) {
//TODO: Implement
log('info', `Query createBoConsent`)
return {
id: 1,
pointId,
lastname,
firstname,
address,
postalCode,
inseeCode,
}
}
/**
* @param {Consent} consent
* @param {number} serviceId
* @returns {Consent}
*/
function updateBoConsent(consent, serviceId) {
//TODO: Implement
log('info', `Query updateBoConsent`)
return {
...consent,
serviceId: serviceId,
}
}
/**
* @param {number} boId
* @returns {Consent}
*/
function getBoConsent(boId) {
//TODO: Implement
223882
223883
223884
223885
223886
223887
223888
223889
223890
223891
223892
223893
223894
223895
223896
223897
223898
223899
223900
return {
pointId: 1234,
lastname: 'SUBTIL',
firstname: 'hugo',
address: 'mad',
postalCode: '69007',
inseeCode: '69383',
serviceId: 1234,
}
// throw errors.VENDOR_DOWN
}
/**
*
*/
function deleteBoConsent() {
//TODO: deleteBoConsent
log('info', `Query deleteBoConsent`)
throw new Error('Function not implemented.')
}
module.exports = {
createBoConsent,
updateBoConsent,
getBoConsent,
deleteBoConsent,
}
/***/ }),
/* 1558 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { log, errors } = __webpack_require__(1)
const { findUserPdl } = __webpack_require__(1559)
const { getInseeCode } = __webpack_require__(1560)
223919
223920
223921
223922
223923
223924
223925
223926
223927
223928
223929
223930
223931
223932
223933
/**
* Verify user identity
* @param {object} fields
* @param {string} baseUrl
* @param {string} apiAuthKey
* @param {string} loginUtilisateur
* @returns {Promise<User>}
*/
async function verifyUserIdentity(
fields,
baseUrl,
apiAuthKey,
loginUtilisateur
) {
const inseeCode = await getInseeCode(fields.postalCode)
const pdl = await findUserPdl(
`${baseUrl}/enedis_SDE_recherche-point/1.0`,
apiAuthKey,
loginUtilisateur,
fields.lastname,
fields.address,
fields.postalCode,
inseeCode
)
if (fields.pointId != pdl) {
log('error', 'PointId does not match')
throw errors.LOGIN_FAILED
}
return {
lastname: fields.lastname,
firstname: fields.firstname,
pointId: fields.pointId,
inseeCode,
postalCode: fields.postalCode,
address: fields.address,
}
}
/* 1559 */
/***/ ((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)
223974
223975
223976
223977
223978
223979
223980
223981
223982
223983
223984
223985
223986
223987
223988
223989
223990
223991
223992
223993
223994
223995
223996
223997
/**
* @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,