1
0
Fork 0
mirror of https://github.com/classchartsapi/classcharts-api-js.git synced 2026-05-14 19:59:37 +00:00

feat: attendance

This commit is contained in:
James Cook 2022-05-25 18:18:31 +01:00
parent f45d857e9a
commit 04b72babcf
4 changed files with 29 additions and 2 deletions

View file

@ -3,6 +3,7 @@ import type { AxiosRequestConfig, AxiosInstance } from "axios";
import type {
ActivityResponse,
AnnouncementsResponse,
AttendanceResponse,
BadgesResponse,
BehaviourResponse,
DetentionsResponse,
@ -216,4 +217,16 @@ export class ClasschartsClient {
}
);
}
/**
* Gets the logged in student's attendance
* @returns Array of dates of attendance
*/
async listAttendance(): Promise<AttendanceResponse> {
return await this.makeAuthedRequest(
this.API_BASE + "/attendance/" + this.studentId,
{
method: "GET",
}
);
}
}

View file

@ -1,4 +1,4 @@
import axios, { AxiosInstance, AxiosRequestConfig } from "axios";
import type { AxiosRequestConfig } from "axios";
import type { GetPupilsResponse } from "./types";
import { ClasschartsClient } from "./baseClient";

View file

@ -1,4 +1,3 @@
import axios from "axios";
import type { AxiosRequestConfig } from "axios";
import { API_BASE_STUDENT, BASE_URL } from "./consts";
import { ClasschartsClient } from "./baseClient";

View file

@ -310,3 +310,18 @@ export interface GetFullActivityOptions {
*/
to: string;
}
export interface AttendanceDate {
AM: {
code: string;
status: "present" | "ignore";
late_minutes: number;
};
PM: {
code: string;
status: "present" | "ignore";
late_minutes: number;
};
}
export type AttendanceResponse = Array<Record<string, AttendanceDate>>;