From c9fa544162384b38ac3f20d664a125b8b59ea316 Mon Sep 17 00:00:00 2001 From: Noah Kilders <71071641+nkilders@users.noreply.github.com> Date: Fri, 16 Feb 2024 20:56:30 +0100 Subject: [PATCH] feat: add getCurrentSchoolyear() (#109) --- 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