1
0
Fork 0
mirror of https://github.com/classchartsapi/classcharts-api-js.git synced 2026-05-14 11:58:13 +00:00

feat: attendance filtering

Co-authored-by: Harrison <harrisondcrafter@gmail.com>
This commit is contained in:
James Cook 2022-06-24 13:15:13 +01:00
parent 257f5d052c
commit 39aa5cb7ea
2 changed files with 20 additions and 2 deletions

View file

@ -8,6 +8,7 @@ import type {
BehaviourResponse, BehaviourResponse,
DetentionsResponse, DetentionsResponse,
GetActivityOptions, GetActivityOptions,
GetAttendanceOptions,
GetBehaviourOptions, GetBehaviourOptions,
GetFullActivityOptions, GetFullActivityOptions,
GetHomeworkOptions, GetHomeworkOptions,
@ -219,11 +220,17 @@ export class ClasschartsClient {
} }
/** /**
* Gets the logged in student's attendance * Gets the logged in student's attendance
* @param options GetAttendanceOptions
* @returns Array of dates of attendance * @returns Array of dates of attendance
*/ */
async listAttendance(): Promise<AttendanceResponse> { async listAttendance(
options?: GetAttendanceOptions
): Promise<AttendanceResponse> {
const params = new URLSearchParams();
options?.from && params.append("from", options?.from);
options?.to && params.append("to", options?.to);
return await this.makeAuthedRequest( return await this.makeAuthedRequest(
this.API_BASE + "/attendance/" + this.studentId, this.API_BASE + "/attendance/" + this.studentId + "?" + params.toString(),
{ {
method: "GET", method: "GET",
} }

View file

@ -311,6 +311,17 @@ export interface GetFullActivityOptions {
to: string; to: string;
} }
export interface GetAttendanceOptions {
/**
* From date, in format YYYY-MM-DD
*/
from: string;
/**
* To date, in format YYYY-MM-DD
*/
to: string;
}
export interface AttendanceDate { export interface AttendanceDate {
AM: { AM: {
code: string; code: string;