summaryrefslogtreecommitdiff
path: root/alarm/node_modules/pronote-api/src/fetch/pronote/navigate.js
blob: edaa3d431cdfacac358eb65e49c4c9aa4ade8aeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const { toPronote } = require('../../data/objects');
const request = require('../../request');

async function navigate(session, user, page, tab, accounts, data)
{
    if (session.user.hiddenTabs.includes(tab) || !accounts.includes(session.type.name)) {
        return null;
    }

    const content = {
        _Signature_: {
            membre: toPronote(user),
            onglet: tab
        }
    };
    if (data) {
        content.donnees = data;
    }

    return (await request(session, page, content)).donnees;
}

module.exports = navigate;