diff --git a/src/core/baseClient.ts b/src/core/baseClient.ts index da97ba4..b41489d 100644 --- a/src/core/baseClient.ts +++ b/src/core/baseClient.ts @@ -126,11 +126,10 @@ export class BaseClient { async getStudentInfo(): Promise { const body = new URLSearchParams(); body.append("include_data", "true"); - const data = await this.makeAuthedRequest(this.API_BASE + "/ping", { + return await this.makeAuthedRequest(this.API_BASE + "/ping", { method: "POST", body: body, }); - return data; } /** * Gets the current student's activity @@ -215,13 +214,12 @@ export class BaseClient { options?.from && params.append("from", String(options?.from)); options?.to && params.append("to", String(options?.to)); - const data: HomeworksResponse = await this.makeAuthedRequest( + return await this.makeAuthedRequest( this.API_BASE + "/homeworks/" + this.studentId + "?" + params.toString(), { method: "GET", }, ); - return data; } /** * Gets the current student's lessons for a given date @@ -256,13 +254,11 @@ export class BaseClient { * @returns Array of announcements */ async getAnnouncements(): Promise { - return ( - await this.makeAuthedRequest( - this.API_BASE + "/announcements/" + this.studentId, - { - method: "GET", - }, - ) + return await this.makeAuthedRequest( + this.API_BASE + "/announcements/" + this.studentId, + { + method: "GET", + }, ); } /** @@ -270,13 +266,11 @@ export class BaseClient { * @returns Array of detentions */ async getDetentions(): Promise { - return ( - await this.makeAuthedRequest( - this.API_BASE + "/detentions/" + this.studentId, - { - method: "GET", - }, - ) + return await this.makeAuthedRequest( + this.API_BASE + "/detentions/" + this.studentId, + { + method: "GET", + }, ); } /** @@ -290,17 +284,15 @@ export class BaseClient { const params = new URLSearchParams(); options?.from && params.append("from", options?.from); options?.to && params.append("to", options?.to); - return ( - await this.makeAuthedRequest( - this.API_BASE + - "/attendance/" + - this.studentId + - "?" + - params.toString(), - { - method: "GET", - }, - ) + return await this.makeAuthedRequest( + this.API_BASE + + "/attendance/" + + this.studentId + + "?" + + params.toString(), + { + method: "GET", + }, ); } /** @@ -308,13 +300,11 @@ export class BaseClient { * @returns Array of stats */ async getPupilFields(): Promise { - return ( - await this.makeAuthedRequest( - this.API_BASE + "/customfields/" + this.studentId, - { - method: "GET", - }, - ) + return await this.makeAuthedRequest( + this.API_BASE + "/customfields/" + this.studentId, + { + method: "GET", + }, ); } } diff --git a/src/core/studentClient.ts b/src/core/studentClient.ts index 7805a9a..d52daff 100644 --- a/src/core/studentClient.ts +++ b/src/core/studentClient.ts @@ -59,8 +59,9 @@ export class StudentClient extends BaseClient { const user = await this.getStudentInfo(); this.studentId = user.data.user.id; } + /** - * Gets the current student's rewards shop + * Gets the available items in the current student's rewards shop * @returns Array of purchasable items */ async getRewards(): Promise { @@ -73,10 +74,11 @@ export class StudentClient extends BaseClient { ) ); } + /** * Purchase a reward item from the current student's rewards shop * @param itemId number - * @returns An object containg balence and id + * @returns An object containing the current student's balance and item ID purchased */ async purchaseReward(itemId: number): Promise { return (