mirror of
https://github.com/classchartsapi/classcharts-api-js.git
synced 2026-05-14 11:58:13 +00:00
fix: pupil types
This commit is contained in:
parent
ab73bd92cd
commit
e1ac2b1364
2 changed files with 33 additions and 15 deletions
|
|
@ -10,27 +10,28 @@ import {
|
||||||
GetBehaviourOptions,
|
GetBehaviourOptions,
|
||||||
GetHomeworkOptions,
|
GetHomeworkOptions,
|
||||||
GetLessonsOptions,
|
GetLessonsOptions,
|
||||||
|
GetPupilsResponse,
|
||||||
Homework,
|
Homework,
|
||||||
HomeworksResponse,
|
HomeworksResponse,
|
||||||
LessonsResponse,
|
LessonsResponse,
|
||||||
Student,
|
Student,
|
||||||
} from "./types";
|
} from "./types";
|
||||||
|
|
||||||
import {ClasschartsClient} from "./client"
|
import { ClasschartsClient } from "./client";
|
||||||
import { API_BASE_PARENT, BASE_URL } from "./consts";
|
import { API_BASE_PARENT, BASE_URL } from "./consts";
|
||||||
/**
|
/**
|
||||||
* The base client
|
* The base client
|
||||||
*/
|
*/
|
||||||
export class ClasschartsParentClient extends ClasschartsClient {
|
export class ClasschartsParentClient extends ClasschartsClient {
|
||||||
private password = "";
|
private password = "";
|
||||||
private email = "";
|
private email = "";
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param email Parents email address
|
* @param email Parents email address
|
||||||
* @param password Parents password
|
* @param password Parents password
|
||||||
*/
|
*/
|
||||||
constructor(email: string, password: string) {
|
constructor(email: string, password: string) {
|
||||||
super(API_BASE_PARENT)
|
super(API_BASE_PARENT);
|
||||||
this.email = String(email);
|
this.email = String(email);
|
||||||
this.password = String(password);
|
this.password = String(password);
|
||||||
}
|
}
|
||||||
|
|
@ -76,21 +77,17 @@ export class ClasschartsParentClient extends ClasschartsClient {
|
||||||
let pupil = await this.getPupils();
|
let pupil = await this.getPupils();
|
||||||
|
|
||||||
this.studentId = pupil[0].id;
|
this.studentId = pupil[0].id;
|
||||||
this.studentName = pupil[0].pupil_name;
|
this.studentName = pupil[0].name;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get Pupil details
|
* Get Pupil details
|
||||||
* @returns an array fo Pupils connected to this parent's account
|
* @returns an array fo Pupils connected to this parent's account
|
||||||
*/
|
*/
|
||||||
async getPupils(): Promise<Object> {
|
async getPupils(): Promise<GetPupilsResponse> {
|
||||||
let pupils = this.makeAuthedRequest(
|
let pupils = this.makeAuthedRequest(this.API_BASE + "/pupils", {
|
||||||
this.API_BASE + "/pupils",
|
method: "GET",
|
||||||
{
|
});
|
||||||
method: "GET",
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return pupils
|
return pupils;
|
||||||
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
21
src/types.ts
21
src/types.ts
|
|
@ -279,3 +279,24 @@ export interface Announcement {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AnnouncementsResponse = Array<Announcement>;
|
export type AnnouncementsResponse = Array<Announcement>;
|
||||||
|
|
||||||
|
export interface Pupil extends Student {
|
||||||
|
school_name: string;
|
||||||
|
school_logo: string;
|
||||||
|
timezone: string;
|
||||||
|
display_covid_tests: boolean;
|
||||||
|
can_record_covid_tests: boolean;
|
||||||
|
detention_yes_count: number;
|
||||||
|
detention_no_count: number;
|
||||||
|
detention_pending_count: number;
|
||||||
|
detention_upscaled_count: number;
|
||||||
|
homework_todo_count: number;
|
||||||
|
homework_late_count: number;
|
||||||
|
homework_not_completed_count: number;
|
||||||
|
homework_excused_count: number;
|
||||||
|
homework_completed_count: number;
|
||||||
|
homework_submitted_count: number;
|
||||||
|
announcements_count: number;
|
||||||
|
messages_count: number;
|
||||||
|
}
|
||||||
|
export type GetPupilsResponse = Array<Pupil>;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue