From 74bb0e1075e19d742c3e101beb3109502bb86305 Mon Sep 17 00:00:00 2001 From: nkilders <71071641+nkilders@users.noreply.github.com> Date: Sun, 11 Feb 2024 18:43:08 +0100 Subject: [PATCH] Add getCurrentSchoolyear() --- src/base.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/base.ts b/src/base.ts index 0bf2299..9f2ce08 100644 --- a/src/base.ts +++ b/src/base.ts @@ -764,6 +764,24 @@ export class Base { return await this._request('getStatusData', {}, validateSession); } + /** + * Get the current school year + * @param [validateSession=true] + * @returns {Promise.} + */ + async getCurrentSchoolyear(validateSession = true): Promise { + const data = await this._request('getCurrentSchoolyear', {}, validateSession); + + if (!data) throw new Error('Failed to retrieve current school year'); + + return { + name: data.name, + id: data.id, + startDate: Base.convertUntisDate(data.startDate), + endDate: Base.convertUntisDate(data.endDate), + }; + } + /** * Convert a JS Date Object to a WebUntis date string * @param {Date} date