2021-04-21 14:48:50 +00:00
|
|
|
/**
|
|
|
|
* Forez Presence Helper
|
|
|
|
*
|
|
|
|
* @author Pierre Hubert
|
|
|
|
*/
|
|
|
|
|
|
|
|
class Presence {
|
|
|
|
constructor(userID, year, month, day) {
|
|
|
|
this.userID = userID;
|
|
|
|
this.year = year;
|
|
|
|
this.month = month;
|
|
|
|
this.day = day;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class ForezPresenceHelper {
|
|
|
|
/**
|
|
|
|
* Load the list of presence
|
|
|
|
*
|
|
|
|
* @param {number} groupID Target group ID
|
|
|
|
* @returns {Promise<Presence[]>}
|
|
|
|
*/
|
|
|
|
static async GetList(groupID) {
|
|
|
|
const list = await ws("forez_presence/list", {group: groupID});
|
|
|
|
|
|
|
|
return list.map(el => {
|
|
|
|
const infos = el.split(",").map(e => Number(e));
|
|
|
|
return new Presence(...infos)
|
|
|
|
});
|
|
|
|
}
|
2021-04-21 15:49:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a day of presence
|
|
|
|
*
|
|
|
|
* @param {number} groupID
|
|
|
|
* @param {number} year
|
|
|
|
* @param {number} month
|
|
|
|
* @param {number} day
|
|
|
|
*/
|
|
|
|
static async AddDay(groupID, year, month, day) {
|
|
|
|
await ws("forez_presence/add_day", {
|
|
|
|
group: groupID,
|
|
|
|
year: year,
|
|
|
|
month: month,
|
|
|
|
day: day
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a day of presence
|
|
|
|
*
|
|
|
|
* @param {number} groupID
|
|
|
|
* @param {number} year
|
|
|
|
* @param {number} month
|
|
|
|
* @param {number} day
|
|
|
|
*/
|
|
|
|
static async DelDay(groupID, year, month, day) {
|
|
|
|
await ws("forez_presence/add_day", {
|
|
|
|
group: groupID,
|
|
|
|
year: year,
|
|
|
|
month: month,
|
|
|
|
day: day
|
|
|
|
})
|
|
|
|
}
|
2021-04-21 14:48:50 +00:00
|
|
|
}
|