From 99c1d9af689e5325f3cf535c4007b3aeb8325229 Mon Sep 17 00:00:00 2001 From: Minteck Date: Tue, 10 Jan 2023 14:54:04 +0100 Subject: Update - This is an automated commit --- school/node_modules/pronote-api/src/fetch/files.js | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 school/node_modules/pronote-api/src/fetch/files.js (limited to 'school/node_modules/pronote-api/src/fetch/files.js') diff --git a/school/node_modules/pronote-api/src/fetch/files.js b/school/node_modules/pronote-api/src/fetch/files.js new file mode 100644 index 0000000..7703ee4 --- /dev/null +++ b/school/node_modules/pronote-api/src/fetch/files.js @@ -0,0 +1,32 @@ +const { parseDate } = require('../data/dates'); +const { getFileURL } = require('../data/files'); +const { withId, checkDuplicates } = require('../data/id'); + +const getFiles = require('./pronote/files'); + +async function files(session, user) { + const files = await getFiles(session, user); + if (!files) { + return null; + } + + const result = []; + + const subjects = {}; + for (const subject of files.listeMatieres.V) { + subjects[subject.N] = subject.L; + } + + for (const file of files.listeRessources.V) { + result.push(withId({ + time: parseDate(file.date.V), + subject: subjects[file.matiere.V.N], + name: file.ressource.V.L, + url: getFileURL(session, { id: file.ressource.V.N, name: file.ressource.V.L, type: file.ressource.V.G }) + }, 'subject', 'name')); + } + + return checkDuplicates(result); +} + +module.exports = files; -- cgit