Newer
Older
return function wrap(arr) {
return callback.apply(null, arr);
};
};
/***/ }),
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
/**
* Determines whether the payload is an error thrown by Axios
*
* @param {*} payload The value to test
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
*/
module.exports = function isAxiosError(payload) {
return utils.isObject(payload) && (payload.isAxiosError === true);
};
228027
228028
228029
228030
228031
228032
228033
228034
228035
228036
228037
228038
228039
228040
228041
228042
/***/ }),
/* 1598 */
/***/ ((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
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
* @param {string} startDate
* @param {string} endDate
* @return {Promise<number>} User contractId
*/
async function activateContract(
url,
apiAuthKey,
appLogin,
contractId,
name,
pointId,
startDate,
endDate
) {
log('info', 'activateContract')
const sgeHeaders = {
'Content-Type': 'text/xml;charset=UTF-8',
apikey: apiAuthKey,
}
const { response } = await soapRequest({
url: url,
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 whileactivating contract: ' + error)
228091
228092
228093
228094
228095
228096
228097
228098
228099
228100
228101
228102
228103
228104
228105
228106
228107
228108
228109
228110
228111
228112
228113
throw errors.LOGIN_FAILED
}
}
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 } = __webpack_require__(1600)
/**
* @param {string} url
* @param {string} apiAuthKey
* @param {string} appLogin
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
* @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,
}
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,
})
228142
228143
228144
228145
228146
228147
228148
228149
228150
228151
228152
228153
228154
228155
228156
228157
228158
228159
228160
228161
228162
228163
228164
228165
228166
228167
228168
228169
228170
228171
228172
228173
228174
228175
228176
228177
228178
228179
228180
228181
228182
228183
228184
228185
228186
228187
try {
const currentContract = parseContracts(parsedReply)[0]
if (currentContract.etatCode === contractState.ACTIF)
return currentContract.serviceSouscritId
return null
} catch (error) {
log('error', 'Error while parsing user contract: ' + error)
throw errors.LOGIN_FAILED
}
}
module.exports = { verifyContract }
/***/ }),
/* 1600 */
/***/ ((module) => {
/**
* Enum for contract-state values.
* @readonly
* @enum {number}
*/
const contractState = {
TERMINE: 'TERMINE',
ACTIF: 'ACTIF',
}
module.exports = { contractState }
/***/ }),
/* 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
228189
228190
228191
228192
228193
228194
228195
228196
228197
228198
228199
228200
228201
228202
228203
228204
228205
228206
228207
228208
228209
228210
228211
228212
228213
228214
228215
228216
228217
228218
228219
228220
228221
228222
228223
228224
228225
228226
228227
228228
228229
228230
228231
228232
228233
228234
228235
228236
228237
228238
228239
228240
228241
228242
228243
228244
228245
228246
228247
228248
228249
228250
228251
228252
228253
228254
228255
228256
228257
228258
228259
228260
228261
228262
228263
228264
228265
228266
228267
228268
228269
228270
228271
228272
228273
228274
228275
228276
228277
228278
228279
228280
228281
* @param {number} serviceId
* @return {Promise<string>} User contractId
*/
async function terminateContract(
url,
apiAuthKey,
appLogin,
contractId,
pointId,
serviceId
) {
log('info', 'activateContract')
const sgeHeaders = {
'Content-Type': 'text/xml;charset=UTF-8',
apikey: apiAuthKey,
}
const { response } = await soapRequest({
url: url,
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
return parsedReply
} catch (error) {
log('error', 'Error while parsing user contract termination: ' + error)
throw errors.VENDOR_DOWN
}
}
module.exports = { terminateContract }
/***/ }),
/* 1602 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
const { log, updateOrCreate } = __webpack_require__(1)
const { iSLocal } = __webpack_require__(1603)
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 }
/***/ }),
/* 1603 */
/***/ ((module) => {
function iSLocal() {
return process.env.NODE_ENV === 'development' || process.env.NODE_ENV
}
module.exports = { iSLocal }
228282
228283
228284
228285
228286
228287
228288
228289
228290
228291
228292
228293
228294
228295
228296
228297
228298
228299
228300
228301
228302
228303
228304
228305
228306
228307
228308
228309
228310
228311
228312
228313
228314
228315
228316
228317
228318
228319
228320
228321
228322
228323
228324
228325
228326
228327
228328
228329
228330
228331
228332
228333
228334
228335
228336
228337
228338
228339
228340
228341
228342
228343
228344
228345
228346
228347
228348
228349
228350
228351
228352
228353
228354
228355
228356
228357
228358
228359
228360
228361
228362
228363
228364
228365
228366
228367
228368
228369
228370
228371
228372
228373
/***/ })
/******/ ]);
/************************************************************************/
/******/ // 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);
/******/
/******/ })()
;