Newer
Older
parser.sgmlDecl = ''
parser.state = S.TEXT
} else if (isQuote(c)) {
parser.state = S.SGML_DECL_QUOTED
parser.sgmlDecl += c
} else {
parser.sgmlDecl += c
}
continue
case S.SGML_DECL_QUOTED:
if (c === parser.q) {
parser.state = S.SGML_DECL
parser.q = ''
}
parser.sgmlDecl += c
continue
223019
223020
223021
223022
223023
223024
223025
223026
223027
223028
223029
223030
223031
223032
223033
case S.DOCTYPE:
if (c === '>') {
parser.state = S.TEXT
emitNode(parser, 'ondoctype', parser.doctype)
parser.doctype = true // just remember that we saw it.
} else {
parser.doctype += c
if (c === '[') {
parser.state = S.DOCTYPE_DTD
} else if (isQuote(c)) {
parser.state = S.DOCTYPE_QUOTED
parser.q = c
}
}
continue
case S.DOCTYPE_QUOTED:
parser.doctype += c
if (c === parser.q) {
parser.q = ''
parser.state = S.DOCTYPE
}
continue
case S.DOCTYPE_DTD:
parser.doctype += c
if (c === ']') {
parser.state = S.DOCTYPE
} else if (isQuote(c)) {
parser.state = S.DOCTYPE_DTD_QUOTED
parser.q = c
}
continue
case S.DOCTYPE_DTD_QUOTED:
parser.doctype += c
if (c === parser.q) {
parser.state = S.DOCTYPE_DTD
parser.q = ''
}
continue
case S.COMMENT:
if (c === '-') {
parser.state = S.COMMENT_ENDING
} else {
parser.comment += c
}
continue
case S.COMMENT_ENDING:
if (c === '-') {
parser.state = S.COMMENT_ENDED
parser.comment = textopts(parser.opt, parser.comment)
if (parser.comment) {
emitNode(parser, 'oncomment', parser.comment)
}
parser.comment = ''
} else {
parser.comment += '-' + c
parser.state = S.COMMENT
}
continue
case S.COMMENT_ENDED:
if (c !== '>') {
strictFail(parser, 'Malformed comment')
// allow <!-- blah -- bloo --> in non-strict mode,
// which is a comment of " blah -- bloo "
parser.comment += '--' + c
parser.state = S.COMMENT
} else {
parser.state = S.TEXT
}
continue
case S.CDATA:
if (c === ']') {
parser.state = S.CDATA_ENDING
} else {
parser.cdata += c
}
continue
case S.CDATA_ENDING:
if (c === ']') {
parser.state = S.CDATA_ENDING_2
} else {
parser.cdata += ']' + c
parser.state = S.CDATA
}
continue
223112
223113
223114
223115
223116
223117
223118
223119
223120
223121
223122
223123
223124
223125
223126
case S.CDATA_ENDING_2:
if (c === '>') {
if (parser.cdata) {
emitNode(parser, 'oncdata', parser.cdata)
}
emitNode(parser, 'onclosecdata')
parser.cdata = ''
parser.state = S.TEXT
} else if (c === ']') {
parser.cdata += ']'
} else {
parser.cdata += ']]' + c
parser.state = S.CDATA
}
continue
case S.PROC_INST:
if (c === '?') {
parser.state = S.PROC_INST_ENDING
} else if (isWhitespace(c)) {
parser.state = S.PROC_INST_BODY
} else {
parser.procInstName += c
}
continue
case S.PROC_INST_BODY:
if (!parser.procInstBody && isWhitespace(c)) {
continue
} else if (c === '?') {
parser.state = S.PROC_INST_ENDING
} else {
parser.procInstBody += c
}
continue
case S.PROC_INST_ENDING:
if (c === '>') {
emitNode(parser, 'onprocessinginstruction', {
name: parser.procInstName,
body: parser.procInstBody
})
parser.procInstName = parser.procInstBody = ''
parser.state = S.TEXT
} else {
parser.procInstBody += '?' + c
parser.state = S.PROC_INST_BODY
}
continue
223162
223163
223164
223165
223166
223167
223168
223169
223170
223171
223172
223173
223174
223175
223176
223177
223178
case S.OPEN_TAG:
if (isMatch(nameBody, c)) {
parser.tagName += c
} else {
newTag(parser)
if (c === '>') {
openTag(parser)
} else if (c === '/') {
parser.state = S.OPEN_TAG_SLASH
} else {
if (!isWhitespace(c)) {
strictFail(parser, 'Invalid character in tag name')
}
parser.state = S.ATTRIB
}
}
continue
case S.OPEN_TAG_SLASH:
if (c === '>') {
openTag(parser, true)
closeTag(parser)
} else {
strictFail(parser, 'Forward-slash in opening tag not followed by >')
parser.state = S.ATTRIB
}
continue
223190
223191
223192
223193
223194
223195
223196
223197
223198
223199
223200
223201
223202
223203
223204
223205
case S.ATTRIB:
// haven't read the attribute name yet.
if (isWhitespace(c)) {
continue
} else if (c === '>') {
openTag(parser)
} else if (c === '/') {
parser.state = S.OPEN_TAG_SLASH
} else if (isMatch(nameStart, c)) {
parser.attribName = c
parser.attribValue = ''
parser.state = S.ATTRIB_NAME
} else {
strictFail(parser, 'Invalid attribute name')
}
continue
223207
223208
223209
223210
223211
223212
223213
223214
223215
223216
223217
223218
223219
223220
223221
223222
case S.ATTRIB_NAME:
if (c === '=') {
parser.state = S.ATTRIB_VALUE
} else if (c === '>') {
strictFail(parser, 'Attribute without value')
parser.attribValue = parser.attribName
attrib(parser)
openTag(parser)
} else if (isWhitespace(c)) {
parser.state = S.ATTRIB_NAME_SAW_WHITE
} else if (isMatch(nameBody, c)) {
parser.attribName += c
} else {
strictFail(parser, 'Invalid attribute name')
}
continue
223224
223225
223226
223227
223228
223229
223230
223231
223232
223233
223234
223235
223236
223237
223238
223239
223240
223241
223242
223243
223244
223245
223246
223247
223248
case S.ATTRIB_NAME_SAW_WHITE:
if (c === '=') {
parser.state = S.ATTRIB_VALUE
} else if (isWhitespace(c)) {
continue
} else {
strictFail(parser, 'Attribute without value')
parser.tag.attributes[parser.attribName] = ''
parser.attribValue = ''
emitNode(parser, 'onattribute', {
name: parser.attribName,
value: ''
})
parser.attribName = ''
if (c === '>') {
openTag(parser)
} else if (isMatch(nameStart, c)) {
parser.attribName = c
parser.state = S.ATTRIB_NAME
} 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
223277
223278
223279
223280
223281
223282
223283
223284
223285
223286
223287
223288
223289
223290
223291
223292
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
223294
223295
223296
223297
223298
223299
223300
223301
223302
223303
223304
223305
223306
223307
223308
223309
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
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
223339
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
}
223400
223401
223402
223403
223404
223405
223406
223407
223408
223409
223410
223411
223412
223413
223414
223415
223416
223417
223418
223419
223420
223421
223422
223423
223424
223425
223426
223427
223428
223429
223430
223431
223432
223433
223434
223435
223436
223437
223438
223439
223440
223441
223442
223443
223444
223445
223446
223447
223448
223449
223450
223451
223452
223453
223454
223455
/*! 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)
/***/ (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;
/***/ (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;
};
"use strict";
module.exports = require("timers");
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { log, cozyClient } = __webpack_require__(1)
223530
223531
223532
223533
223534
223535
223536
223537
223538
223539
223540
223541
223542
223543
223544
/**
* 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
}
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
223579
223580
/**
* 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,
}
}
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
223627
223628
/**
* 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,
}
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { log } = __webpack_require__(1)
const moment = __webpack_require__(1379)
/**
* 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 address
* @param {string} result
* @returns {Address}
*/
function parseUserAddress(result) {
log('info', 'Parsing user Address')
const json = JSON.stringify(result)
return JSON.parse(json)['Envelope']['Body'][
'consulterDonneesTechniquesContractuellesResponse'
]['point']['donneesGenerales']['adresseInstallation']
}
/**
* Return User contract start date
* @param {string} result
*/
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']
}
223722
223723
223724
223725
223726
223727
223728
223729
223730
223731
223732
223733
223734
223735
223736
223737
223738
223739
223740
/**
* 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')),
}
})
}
/**
* Check if response contains contracts
* @param {string} parsedReply
* @return {boolean}
*/
function checkContractExists(parsedReply) {
const json = JSON.stringify(parsedReply)
return JSON.parse(json)['Envelope']['Body'][
'rechercherServicesSouscritsMesuresResponse'
]['servicesSouscritsMesures']
}
/**
* 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
}
223780
223781
223782
223783
223784
223785
223786
223787
223788
223789
223790
223791
223792
223793
223794
223795
223796
223797
/**
* Remove SGE useless multiple white spaces
* @param {string} str
* @returns {string}
*/
function removeMultipleSpaces(str) {
return str.replace(/ +/g, ' ')
}
/**
* Remove SGE address number
* @param {string} str
* @returns {string}
*/
function removeAddressnumber(str) {
return str.replace(/\d+ |b |B |T |t |\d+/g, '')
}
module.exports = {
parseSgeXmlData,
formateDataForDoctype,
parseTags,
parseValue,
parseUserPdl,
parseContracts,
parseContractStartDate,
parseServiceId,
parseUserAddress,
removeMultipleSpaces,
removeAddressnumber,
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { log } = __webpack_require__(1)
223821
223822
223823
223824
223825
223826
223827
223828
223829
223830
223831
223832
223833
223834
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
223860
223861
223862
223863
223864
223865
223866
/**
* 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>
`
}
223868
223869
223870
223871
223872
223873
223874
223875
223876
223877
223878
223879
223880
223881
223882
223883
223884
223885
223886
223887
223888
223889
223890
223891
223892
223893
223894
223895
223896
223897
223898
223899
223900
223901
223902
223903
223904
223905
223906
223907
223908
223909
223910
223911
223912
223913
223914
/**
* 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>
`
}
/**
* Get user technical data (contract start date)
* @param {number} pointId
* @param {string} appLogin
* @returns {string}
*/
function consulterDonneesTechniquesContractuelles(
pointId,
appLogin,
consent = true
) {
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>${consent}</autorisationClient>
</v2:consulterDonneesTechniquesContractuelles>
</soapenv:Body>
</soapenv:Envelope>
`
}
/**
* Use rechercherPoint to find user PDL if exist
* @param {string} name
* @param {string} postalCode
* @param {string} inseeCode
* @param {string} address
* @param {string} [escalierEtEtageEtAppartement]
function rechercherPoint(
appLogin,
name,
postalCode,
inseeCode,
address,
escalierEtEtageEtAppartement
) {
`Query rechercherPoint - postal code : ${postalCode} / insee code: ${inseeCode}`
223965
223966
223967
223968
223969
223970
223971
223972
223973
223974
223975
223976
223977
223978
223979
223980
223981
223982
223983
223984
223985
223986
223987
if (escalierEtEtageEtAppartement) {
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>
<escalierEtEtageEtAppartement>${escalierEtEtageEtAppartement}</escalierEtEtageEtAppartement>
<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>`
}
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>