-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathd2l.js
38 lines (37 loc) · 1.64 KB
/
d2l.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const D2LApi = {
GET_DATA_REQ: 'GET_DATA_REQ',
GET_DATA_RES: 'GET_DATA_RES',
APIKEY_URL: 'https://d2lapi.sicame.io/api/D2L/Security/GetAPIKey',
APIKEY_REQ: 'APIKEY_REQ',
APIKEY_RES: 'APIKEY_RES',
COMPTEUR_URL: 'https://d2lapi.sicame.io/api/D2L/D2Ls',
COMPTEUR_REQ: 'COMPTEUR_REQ',
COMPTEUR_RES: 'COMPTEUR_RES',
LAST_INDEX_URL: function (compteurId) {
return `https://d2lapi.sicame.io/api/D2L/D2Ls/${compteurId}/LastIndexes`
},
LAST_INDEX_REQ: 'LAST_INDEX_REQ',
LAST_INDEX_RES: 'LAST_INDEX_RES',
LAST_INDEXES_URL: function (compteurId, nbHoursToFetch) {
let to = new Date().toISOString();
let from = new Date(new Date().getTime() - ((parseInt(nbHoursToFetch) * 60 * 60 * 1000))).toISOString();
return `https://d2lapi.sicame.io/api/D2L/D2Ls/${compteurId}/IndexesBetween?from=${from}&to=${to}`
},
LAST_INDEXES_REQ: 'LAST_INDEXES_REQ',
LAST_INDEXES_RES: 'LAST_INDEXES_RES',
LAST_CURRENT_URL: function (compteurId) {
return `https://d2lapi.sicame.io/api/D2L/D2Ls/${compteurId}/LastCurrents`
},
LAST_CURRENT_REQ: 'LAST_CURRENT_REQ',
LAST_CURRENT_RES: 'LAST_CURRENT_RES',
LAST_CURRENTS_URL: function (compteurId, nbHoursToFetch) {
let to = new Date().toISOString();
let from = new Date(new Date().getTime() - ((parseInt(nbHoursToFetch) * 60 * 60 * 1000))).toISOString();
return `https://d2lapi.sicame.io/api/D2L/D2Ls/${compteurId}/CurrentsBetween?from=${from}&to=${to}`
},
LAST_CURRENTS_REQ: 'LAST_CURRENTS_REQ',
LAST_CURRENTS_RES: 'LAST_CURRENTS_RES',
};
if (typeof module !== 'undefined') {
module.exports = { D2LApi }
}