diff --git a/readme.md b/readme.md
index d46851f..a5ee3c8 100644
--- a/readme.md
+++ b/readme.md
@@ -1,10 +1,11 @@
Classcharts API JS
A Node.js and Deno wrapper for getting information from the Classcharts API.
diff --git a/src/core/baseClient.ts b/src/core/baseClient.ts
index 7075527..d88d620 100644
--- a/src/core/baseClient.ts
+++ b/src/core/baseClient.ts
@@ -67,7 +67,7 @@ export class BaseClient {
method: "POST",
body: pingFormData,
},
- { revalidateToken: false }
+ { revalidateToken: false },
);
this.sessionId = pingData.meta.session_id;
this.lastPing = Date.now();
@@ -86,7 +86,7 @@ export class BaseClient {
public async makeAuthedRequest(
path: string,
fetchOptions: RequestInit,
- options?: { revalidateToken?: boolean }
+ options?: { revalidateToken?: boolean },
) {
if (!this.sessionId) throw new Error("No session ID");
if (!options) {
@@ -114,7 +114,7 @@ export class BaseClient {
responseJSON = await request.json();
} catch {
throw new Error(
- "Error parsing JSON. Returned response: " + (await request.text())
+ "Error parsing JSON. Returned response: " + (await request.text()),
);
}
if (responseJSON.success == 0) {
@@ -153,7 +153,7 @@ export class BaseClient {
this.API_BASE + "/activity/" + this.studentId + "?" + params.toString(),
{
method: "GET",
- }
+ },
);
}
/**
@@ -165,7 +165,7 @@ export class BaseClient {
* @see getActivity
*/
async getFullActivity(
- options: GetFullActivityOptions
+ options: GetFullActivityOptions,
): Promise {
let data: ActivityResponse["data"] = [];
let prevLast: number | undefined;
@@ -194,7 +194,7 @@ export class BaseClient {
* @returns Array of behaviour points
*/
async getBehaviour(
- options?: GetBehaviourOptions
+ options?: GetBehaviourOptions,
): Promise {
const params = new URLSearchParams();
options?.from && params.append("from", options?.from);
@@ -203,7 +203,7 @@ export class BaseClient {
this.API_BASE + "/behaviour/" + this.studentId + "?" + params.toString(),
{
method: "GET",
- }
+ },
);
}
/**
@@ -223,7 +223,7 @@ export class BaseClient {
this.API_BASE + "/homeworks/" + this.studentId + "?" + params.toString(),
{
method: "GET",
- }
+ },
);
for (let i = 0; i < data.data.length; i++) {
@@ -231,11 +231,11 @@ export class BaseClient {
// homework.lesson.replace(/\\/g, '')
data.data[i].description = data.data[i].description.replace(
/(<([^>]+)>)/gi,
- ""
+ "",
);
data.data[i].description = data.data[i].description.replace(
/ /g,
- ""
+ "",
);
data.data[i].description = data.data[i].description.trim();
}
@@ -254,7 +254,7 @@ export class BaseClient {
this.API_BASE + "/timetable/" + this.studentId + "?" + params.toString(),
{
method: "GET",
- }
+ },
);
}
/**
@@ -266,7 +266,7 @@ export class BaseClient {
this.API_BASE + "/eventbadges/" + this.studentId,
{
method: "GET",
- }
+ },
);
}
/**
@@ -279,7 +279,7 @@ export class BaseClient {
this.API_BASE + "/announcements/" + this.studentId,
{
method: "GET",
- }
+ },
)
).data;
}
@@ -293,7 +293,7 @@ export class BaseClient {
this.API_BASE + "/detentions/" + this.studentId,
{
method: "GET",
- }
+ },
)
).data;
}
@@ -303,7 +303,7 @@ export class BaseClient {
* @returns Array of dates of attendance
*/
async getAttendance(
- options?: GetAttendanceOptions
+ options?: GetAttendanceOptions,
): Promise {
const params = new URLSearchParams();
options?.from && params.append("from", options?.from);
@@ -317,7 +317,7 @@ export class BaseClient {
params.toString(),
{
method: "GET",
- }
+ },
)
).data;
}
diff --git a/src/core/parentClient.ts b/src/core/parentClient.ts
index e87a6e8..3a6ab65 100644
--- a/src/core/parentClient.ts
+++ b/src/core/parentClient.ts
@@ -46,7 +46,7 @@ export class ParentClient extends BaseClient {
"Unauthenticated: ClassCharts returned an error: " +
response.status +
" " +
- response.statusText
+ response.statusText,
);
}
@@ -54,7 +54,7 @@ export class ParentClient extends BaseClient {
// this.authCookies = cookies.split(";");
const sessionCookies = parseCookies(cookies);
const sessionID = JSON.parse(
- String(sessionCookies["parent_session_credentials"])
+ String(sessionCookies["parent_session_credentials"]),
);
super.sessionId = sessionID.session_id;
this.pupils = await this.getPupils();
diff --git a/src/core/studentClient.ts b/src/core/studentClient.ts
index 5d2ac24..c5ba6fc 100644
--- a/src/core/studentClient.ts
+++ b/src/core/studentClient.ts
@@ -46,14 +46,14 @@ export class StudentClient extends BaseClient {
if (request.status != 302 || !request.headers.get("set-cookie")) {
await request.body?.cancel(); // Make deno tests happy by closing the body, unsure whether this is needed for the actual library
throw new Error(
- "Unauthenticated: ClassCharts didn't return authentication cookies"
+ "Unauthenticated: ClassCharts didn't return authentication cookies",
);
}
const cookies = String(request.headers.get("set-cookie"));
this.authCookies = cookies.split(",");
const sessionCookies = parseCookies(cookies);
const sessionID = JSON.parse(
- String(sessionCookies["student_session_credentials"])
+ String(sessionCookies["student_session_credentials"]),
);
this.sessionId = sessionID.session_id;
await this.getNewSessionId();
diff --git a/src/core/studentClient_test.ts b/src/core/studentClient_test.ts
index 1de98e5..6932a75 100644
--- a/src/core/studentClient_test.ts
+++ b/src/core/studentClient_test.ts
@@ -9,7 +9,7 @@ Deno.test("Throws when no student code is provided", async () => {
await client.login();
},
Error,
- "Student Code not provided"
+ "Student Code not provided",
);
});
@@ -20,6 +20,6 @@ Deno.test("Throws with invalid student code", async () => {
await client.login();
},
Error,
- "Unauthenticated: ClassCharts didn't return authentication cookies"
+ "Unauthenticated: ClassCharts didn't return authentication cookies",
);
});
diff --git a/src/utils/utils.ts b/src/utils/utils.ts
index 4ebf6d8..455d7a2 100644
--- a/src/utils/utils.ts
+++ b/src/utils/utils.ts
@@ -10,7 +10,7 @@ export function parseCookies(input: string) {
for (const cookie of cookies) {
const cookieSplit = cookie.split(";")[0].split("=");
output[leftTrim(decodeURIComponent(cookieSplit[0]))] = decodeURIComponent(
- cookieSplit[1]
+ cookieSplit[1],
);
}
return output;