mirror of
https://github.com/classchartsapi/classcharts-api-js.git
synced 2026-05-14 11:58:13 +00:00
style: prettier and eslint
This commit is contained in:
parent
e1ac2b1364
commit
efba7086ea
8 changed files with 33 additions and 2803 deletions
|
|
@ -14,9 +14,7 @@
|
||||||
// Set *default* container specific settings.json values on container create.
|
// Set *default* container specific settings.json values on container create.
|
||||||
"settings": {},
|
"settings": {},
|
||||||
// Add the IDs of extensions you want installed when the container is created.
|
// Add the IDs of extensions you want installed when the container is created.
|
||||||
"extensions": [
|
"extensions": ["dbaeumer.vscode-eslint"],
|
||||||
"dbaeumer.vscode-eslint"
|
|
||||||
],
|
|
||||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
// "forwardPorts": [],
|
// "forwardPorts": [],
|
||||||
// Use 'postCreateCommand' to run commands after the container is created.
|
// Use 'postCreateCommand' to run commands after the container is created.
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,6 @@ docs
|
||||||
node_modules
|
node_modules
|
||||||
pnpm-lock.yaml
|
pnpm-lock.yaml
|
||||||
package.json
|
package.json
|
||||||
|
.prettierrc.json
|
||||||
|
.eslint.js
|
||||||
|
tsconfig.json
|
||||||
2732
package-lock.json
generated
2732
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -30,13 +30,12 @@ export class ClasschartsClient {
|
||||||
* @param API_BASE Base API URL, this is different depending if its called as a parent or student
|
* @param API_BASE Base API URL, this is different depending if its called as a parent or student
|
||||||
*/
|
*/
|
||||||
constructor(API_BASE: string) {
|
constructor(API_BASE: string) {
|
||||||
this.API_BASE = API_BASE
|
this.API_BASE = API_BASE;
|
||||||
}
|
}
|
||||||
public async makeAuthedRequest(
|
public async makeAuthedRequest(
|
||||||
path: string,
|
path: string,
|
||||||
options: Omit<RequestOptions, "origin" | "path">
|
options: Omit<RequestOptions, "origin" | "path">
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if (!this.authCookies) throw new Error("Not authenticated");
|
if (!this.authCookies) throw new Error("Not authenticated");
|
||||||
const requestOptions: Omit<RequestOptions, "origin" | "path"> = {
|
const requestOptions: Omit<RequestOptions, "origin" | "path"> = {
|
||||||
...options,
|
...options,
|
||||||
|
|
@ -46,7 +45,6 @@ export class ClasschartsClient {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const request = await Undici.request(path, requestOptions);
|
const request = await Undici.request(path, requestOptions);
|
||||||
|
|
||||||
let responseJSON;
|
let responseJSON;
|
||||||
|
|
@ -56,14 +54,12 @@ export class ClasschartsClient {
|
||||||
throw new Error("Invalid JSON response recieved");
|
throw new Error("Invalid JSON response recieved");
|
||||||
}
|
}
|
||||||
if (responseJSON.success == 0) {
|
if (responseJSON.success == 0) {
|
||||||
|
|
||||||
throw new Error(responseJSON.error);
|
throw new Error(responseJSON.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return responseJSON.data;
|
return responseJSON.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets general information about the logged in student
|
* Gets general information about the logged in student
|
||||||
* @returns Student object
|
* @returns Student object
|
||||||
|
|
@ -94,8 +90,6 @@ export class ClasschartsClient {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the logged in students behaviour points
|
* Gets the logged in students behaviour points
|
||||||
* @param options GetBehaviourOptions
|
* @param options GetBehaviourOptions
|
||||||
|
|
@ -143,7 +137,7 @@ export class ClasschartsClient {
|
||||||
data[i].description = data[i].description.replace(/ /g, "");
|
data[i].description = data[i].description.replace(/ /g, "");
|
||||||
data[i].description = data[i].description.trim();
|
data[i].description = data[i].description.trim();
|
||||||
}
|
}
|
||||||
console.log(data)
|
console.log(data);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
export * from "./parent";
|
export * from "./parent";
|
||||||
export * from "./student";
|
export * from "./student";
|
||||||
|
export * from "./types";
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,5 @@
|
||||||
import Undici from "undici";
|
import Undici from "undici";
|
||||||
import { RequestOptions } from "undici/types/dispatcher";
|
import type { GetPupilsResponse } from "./types";
|
||||||
import {
|
|
||||||
ActivityResponse,
|
|
||||||
AnnouncementsResponse,
|
|
||||||
BadgesResponse,
|
|
||||||
BehaviourResponse,
|
|
||||||
DetentionsResponse,
|
|
||||||
GetActivityOptions,
|
|
||||||
GetBehaviourOptions,
|
|
||||||
GetHomeworkOptions,
|
|
||||||
GetLessonsOptions,
|
|
||||||
GetPupilsResponse,
|
|
||||||
Homework,
|
|
||||||
HomeworksResponse,
|
|
||||||
LessonsResponse,
|
|
||||||
Student,
|
|
||||||
} 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";
|
||||||
|
|
@ -74,7 +58,7 @@ export class ClasschartsParentClient extends ClasschartsClient {
|
||||||
|
|
||||||
this.sessionId = sessionID.session_id;
|
this.sessionId = sessionID.session_id;
|
||||||
|
|
||||||
let pupil = await this.getPupils();
|
const pupil = await this.getPupils();
|
||||||
|
|
||||||
this.studentId = pupil[0].id;
|
this.studentId = pupil[0].id;
|
||||||
this.studentName = pupil[0].name;
|
this.studentName = pupil[0].name;
|
||||||
|
|
@ -84,10 +68,8 @@ export class ClasschartsParentClient extends ClasschartsClient {
|
||||||
* @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<GetPupilsResponse> {
|
async getPupils(): Promise<GetPupilsResponse> {
|
||||||
let pupils = this.makeAuthedRequest(this.API_BASE + "/pupils", {
|
return this.makeAuthedRequest(this.API_BASE + "/pupils", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
});
|
});
|
||||||
|
|
||||||
return pupils;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,6 @@
|
||||||
import Undici from "undici";
|
import Undici from "undici";
|
||||||
import { RequestOptions } from "undici/types/dispatcher";
|
|
||||||
import {
|
|
||||||
ActivityResponse,
|
|
||||||
AnnouncementsResponse,
|
|
||||||
BadgesResponse,
|
|
||||||
BehaviourResponse,
|
|
||||||
DetentionsResponse,
|
|
||||||
GetActivityOptions,
|
|
||||||
GetBehaviourOptions,
|
|
||||||
GetHomeworkOptions,
|
|
||||||
GetLessonsOptions,
|
|
||||||
Homework,
|
|
||||||
HomeworksResponse,
|
|
||||||
LessonsResponse,
|
|
||||||
Student,
|
|
||||||
} from "./types";
|
|
||||||
import { API_BASE_STUDENT, BASE_URL } from "./consts";
|
import { API_BASE_STUDENT, BASE_URL } from "./consts";
|
||||||
import {ClasschartsClient} from "./client"
|
import { ClasschartsClient } from "./client";
|
||||||
/**
|
/**
|
||||||
* The base client
|
* The base client
|
||||||
*/
|
*/
|
||||||
|
|
@ -31,7 +15,7 @@ export class ClasschartsStudentClient extends ClasschartsClient {
|
||||||
* @param dateOfBirth Student's date of birth
|
* @param dateOfBirth Student's date of birth
|
||||||
*/
|
*/
|
||||||
constructor(studentCode: string, dateOfBirth?: string) {
|
constructor(studentCode: string, dateOfBirth?: string) {
|
||||||
super(API_BASE_STUDENT)
|
super(API_BASE_STUDENT);
|
||||||
this.studentCode = String(studentCode);
|
this.studentCode = String(studentCode);
|
||||||
this.dateOfBirth = String(dateOfBirth);
|
this.dateOfBirth = String(dateOfBirth);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue