Skip to content
Snippets Groups Projects
Commit f294cdb4 authored by Rémi PAILHAREY's avatar Rémi PAILHAREY :fork_knife_plate:
Browse files

feat: updated dependencies for node 16.19.0

parent 66276007
No related branches found
No related tags found
1 merge request!22Chore/update node version to 16
Pipeline #50125 failed
......@@ -7,7 +7,7 @@ const {
cozyClient,
} = require('cozy-konnector-libs')
const rp = require('request-promise')
const fetch = require('node-fetch')
const moment = require('moment')
require('moment-timezone')
......@@ -198,20 +198,19 @@ async function buildAggregatedData(data, doctype) {
async function authenticate(login, password, baseUrl, apiAuthKey) {
const authRequest = {
method: 'POST',
uri: baseUrl + '/connect.aspx',
headers: {
AuthKey: apiAuthKey,
'Content-Type': 'application/x-www-form-urlencoded',
},
formData: {
body: new URLSearchParams({
login: login,
pass: password,
},
json: true,
}),
}
let response = {}
try {
response = await rp(authRequest)
const data = await fetch(baseUrl + '/connect.aspx', authRequest)
const response = await data.json()
if (response.codeRetour === 100) {
return response
} else {
......@@ -228,27 +227,27 @@ async function getData(response, baseUrl, apiAuthKey) {
log('debug', 'End date : ' + endDate)
const dataRequest = {
method: 'POST',
uri: baseUrl + '/getAllAgregatsByAbonnement.aspx',
headers: {
AuthKey: apiAuthKey,
'Content-Type': 'application/x-www-form-urlencoded',
},
form: {
body: new URLSearchParams({
token: response.resultatRetour.token,
num_abt: response.resultatRetour.num_abt,
date_debut: startDate,
date_fin: endDate,
},
json: true,
}),
}
try {
// Sort data by date
const responseEgl = await rp(dataRequest).then(eglRawData => {
eglRawData.resultatRetour.sort(function(a, b) {
return new Date(a.DateReleve) - new Date(b.DateReleve)
})
return eglRawData
const data = await fetch(
baseUrl + '/getAllAgregatsByAbonnement.aspx',
dataRequest
)
const responseEgl = await data.json()
log('debug', responseEgl)
responseEgl.resultatRetour.sort(function(a, b) {
return new Date(a.DateReleve) - new Date(b.DateReleve)
})
switch (responseEgl.codeRetour) {
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment