Skip to content

Commit 6d0942a

Browse files
docs: improve code documentation
1 parent cb8e252 commit 6d0942a

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

src/core/baseClient.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,27 @@ import { PING_INTERVAL } from "../utils/consts.ts";
2424
*/
2525
export abstract class BaseClient {
2626
/**
27-
* @property studentId Currently selected student ID
27+
* Currently selected student ID
2828
*/
2929
public studentId = 0;
3030
/**
31-
* @property authCookies Cookies used for authentication (set during login and can be empty)
31+
* Cookies used for authentication (set during login and can be empty)
3232
*/
3333
public authCookies: string[];
3434
/**
35-
* @property sessionId Session ID used for authentication
35+
* Session ID used for authentication
3636
*/
3737
public sessionId = "";
3838
/**
39-
* @property lastPing Last time the sessionId was updated
39+
* Last time the sessionId was updated
4040
*/
4141
public lastPing = 0;
4242
/**
43-
* @property API_BASE Base API URL, this is different depending on if its called as a parent or student
43+
* Base API URL, this is different depending on if its called as a parent or student
4444
*/
4545
protected API_BASE = "";
4646
/**
47+
* Create a new client with the given API url
4748
* @param API_BASE Base API URL, this is different depending on if its called as a parent or student
4849
*/
4950
constructor(API_BASE: string) {
@@ -55,7 +56,7 @@ export abstract class BaseClient {
5556
/**
5657
* Revalidates the session ID.
5758
*
58-
* This is called automatically when the session ID is older than 3 minutes or when initially using the .login() method
59+
* This is called automatically when the session ID is older than 3 minutes and initially using the .login() method
5960
*/
6061
public async getNewSessionId() {
6162
const pingFormData = new URLSearchParams();

src/core/parentClient.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@ import { BaseClient } from "../core/baseClient.ts";
44
import { API_BASE_PARENT, BASE_URL } from "../utils/consts.ts";
55
import { parseCookies } from "../utils/utils.ts";
66
/**
7-
* Parent Client
7+
* Parent Client.
8+
* See {@link BaseClient} for all shared methods.
9+
*
10+
* @example
11+
* ```ts
12+
* import { ParentClient } from "classcharts-api";
13+
* const client = new ParentClient("username", "password");
14+
* await client.login();
15+
* ```
816
*/
917
export class ParentClient extends BaseClient {
1018
private password = "";
1119
private email = "";
12-
// @ts-expect-error Init in .login
1320
public pupils: GetPupilsResponse;
1421
/**
1522
* @param email Parent's email address
@@ -19,6 +26,7 @@ export class ParentClient extends BaseClient {
1926
super(API_BASE_PARENT);
2027
this.email = String(email);
2128
this.password = String(password);
29+
this.pupils = [];
2230
}
2331

2432
/**

src/core/studentClient.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
import { API_BASE_STUDENT, BASE_URL } from "../utils/consts.ts";
22
import { BaseClient } from "../core/baseClient.ts";
33
import { parseCookies } from "../utils/utils.ts";
4-
import {
4+
import type {
55
GetStudentCodeOptions,
66
GetStudentCodeResponse,
77
RewardPurchaseResponse,
88
RewardsResponse,
99
} from "../types.ts";
10-
1110
/**
12-
* Student Client
11+
* Student Client.
12+
* See {@link BaseClient} for all shared methods.
13+
*
14+
* @example
15+
* ```ts
16+
* import { StudentClient } from "classcharts-api";
17+
* // Date of birth MUST in the format DD/MM/YYYY
18+
* const client = new StudentClient("classchartsCode", "01/01/2000");
19+
* await client.login();
20+
* ```
1321
*/
1422
export class StudentClient extends BaseClient {
1523
/**
16-
* @property studentCode ClassCharts student code
24+
* ClassCharts student code
1725
*/
1826
private studentCode = "";
1927
/**
20-
* @property dateOfBirth Student's date of birth
28+
* Student's date of birth
2129
*/
2230
private dateOfBirth = "";
2331

0 commit comments

Comments
 (0)