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