UNPKG

ecoledirecte.js

Version:

Good-looking client for EcoleDirecte's private API.

36 lines (35 loc) 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.downloadDocument = exports.getDocuments = void 0; const v3_1 = require("ecoledirecte-api-types/v3"); const util_1 = require("../util"); async function getDocuments(token, archiveYear) { const body = await (0, util_1.makeRequest)({ method: "POST", path: v3_1.Routes.studentDocuments({ archive: archiveYear !== null && archiveYear !== void 0 ? archiveYear : "" }), body: { token }, guard: true, }); return body; } exports.getDocuments = getDocuments; async function downloadDocument(token, documentId, fileType, archiveYear) { const body = await (0, util_1.makeRequest)({ method: "GET", path: v3_1.Routes.downloadDocument({ fichierId: documentId, leTypeDeFichier: fileType || "", archive: !!archiveYear, anneeArchive: archiveYear || "", }), body: { forceDownload: 0, archivve: !!archiveYear, anneeArchive: archiveYear || "", }, guard: true, expectBuffer: true, }, undefined, undefined, token); return body; } exports.downloadDocument = downloadDocument;