mirror of
https://github.com/classchartsapi/classcharts-api-js.git
synced 2026-05-14 11:58:13 +00:00
add getcode endpoint
This commit is contained in:
parent
4cfb4128de
commit
fad2b99ff8
3 changed files with 39 additions and 0 deletions
5
.changeset/gold-pigs-lick.md
Normal file
5
.changeset/gold-pigs-lick.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"classcharts-api": minor
|
||||
---
|
||||
|
||||
Added getcode endpoint
|
||||
|
|
@ -10,6 +10,8 @@ import type {
|
|||
GetActivityOptions,
|
||||
GetAttendanceOptions,
|
||||
GetBehaviourOptions,
|
||||
GetCodeOptions,
|
||||
GetCodeResponse,
|
||||
GetFullActivityOptions,
|
||||
GetHomeworkOptions,
|
||||
GetLessonsOptions,
|
||||
|
|
@ -319,4 +321,19 @@ export class BaseClient {
|
|||
)
|
||||
).data;
|
||||
}
|
||||
/**
|
||||
* Gets the current student's code
|
||||
* @param options GetCodeOptions
|
||||
* @param options.dateOfBirth Date of birth in the format YYYY-MM-DD
|
||||
* @returns
|
||||
*/
|
||||
async getCode(options: GetCodeOptions): Promise<GetCodeResponse> {
|
||||
const data = await this.makeAuthedRequest(this.API_BASE + "/getcode", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
date: options.dateOfBirth,
|
||||
}),
|
||||
});
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
17
src/types.ts
17
src/types.ts
|
|
@ -429,3 +429,20 @@ export interface AttendanceDate {
|
|||
}
|
||||
// TODO: Update typings to include meta response. Currently not possible since I don't have access
|
||||
export type AttendanceResponse = Record<string, AttendanceDate>[];
|
||||
|
||||
export interface GetCodeOptions {
|
||||
/**
|
||||
* Date of birth, in format YYYY-MM-DD
|
||||
*/
|
||||
dateOfBirth: string;
|
||||
}
|
||||
|
||||
export interface GetCodeResponseData {
|
||||
code: string;
|
||||
}
|
||||
|
||||
export type GetCodeResponseMeta = [];
|
||||
export type GetCodeResponse = ClassChartsResponse<
|
||||
GetCodeResponseData,
|
||||
GetCodeResponseMeta
|
||||
>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue