1
0
Fork 0
mirror of https://github.com/classchartsapi/classcharts-api-js.git synced 2026-05-14 03:56:59 +00:00

chore: fmt

This commit is contained in:
James Cook 2023-09-18 20:52:01 +01:00
parent 41f23e01d0
commit 821a5c26ea
2 changed files with 30 additions and 38 deletions

View file

@ -126,11 +126,10 @@ export class BaseClient {
async getStudentInfo(): Promise<GetStudentInfoResponse> { async getStudentInfo(): Promise<GetStudentInfoResponse> {
const body = new URLSearchParams(); const body = new URLSearchParams();
body.append("include_data", "true"); body.append("include_data", "true");
const data = await this.makeAuthedRequest(this.API_BASE + "/ping", { return await this.makeAuthedRequest(this.API_BASE + "/ping", {
method: "POST", method: "POST",
body: body, body: body,
}); });
return data;
} }
/** /**
* Gets the current student's activity * Gets the current student's activity
@ -215,13 +214,12 @@ export class BaseClient {
options?.from && params.append("from", String(options?.from)); options?.from && params.append("from", String(options?.from));
options?.to && params.append("to", String(options?.to)); 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(), this.API_BASE + "/homeworks/" + this.studentId + "?" + params.toString(),
{ {
method: "GET", method: "GET",
}, },
); );
return data;
} }
/** /**
* Gets the current student's lessons for a given date * Gets the current student's lessons for a given date
@ -256,13 +254,11 @@ export class BaseClient {
* @returns Array of announcements * @returns Array of announcements
*/ */
async getAnnouncements(): Promise<AnnouncementsResponse> { async getAnnouncements(): Promise<AnnouncementsResponse> {
return ( return await this.makeAuthedRequest(
await this.makeAuthedRequest( this.API_BASE + "/announcements/" + this.studentId,
this.API_BASE + "/announcements/" + this.studentId, {
{ method: "GET",
method: "GET", },
},
)
); );
} }
/** /**
@ -270,13 +266,11 @@ export class BaseClient {
* @returns Array of detentions * @returns Array of detentions
*/ */
async getDetentions(): Promise<DetentionsResponse> { async getDetentions(): Promise<DetentionsResponse> {
return ( return await this.makeAuthedRequest(
await this.makeAuthedRequest( this.API_BASE + "/detentions/" + this.studentId,
this.API_BASE + "/detentions/" + this.studentId, {
{ method: "GET",
method: "GET", },
},
)
); );
} }
/** /**
@ -290,17 +284,15 @@ export class BaseClient {
const params = new URLSearchParams(); const params = new URLSearchParams();
options?.from && params.append("from", options?.from); options?.from && params.append("from", options?.from);
options?.to && params.append("to", options?.to); options?.to && params.append("to", options?.to);
return ( return await this.makeAuthedRequest(
await this.makeAuthedRequest( this.API_BASE +
this.API_BASE + "/attendance/" +
"/attendance/" + this.studentId +
this.studentId + "?" +
"?" + params.toString(),
params.toString(), {
{ method: "GET",
method: "GET", },
},
)
); );
} }
/** /**
@ -308,13 +300,11 @@ export class BaseClient {
* @returns Array of stats * @returns Array of stats
*/ */
async getPupilFields(): Promise<PupilFieldsResponse> { async getPupilFields(): Promise<PupilFieldsResponse> {
return ( return await this.makeAuthedRequest(
await this.makeAuthedRequest( this.API_BASE + "/customfields/" + this.studentId,
this.API_BASE + "/customfields/" + this.studentId, {
{ method: "GET",
method: "GET", },
},
)
); );
} }
} }

View file

@ -59,8 +59,9 @@ export class StudentClient extends BaseClient {
const user = await this.getStudentInfo(); const user = await this.getStudentInfo();
this.studentId = user.data.user.id; 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 * @returns Array of purchasable items
*/ */
async getRewards(): Promise<RewardsResponse> { async getRewards(): Promise<RewardsResponse> {
@ -73,10 +74,11 @@ export class StudentClient extends BaseClient {
) )
); );
} }
/** /**
* Purchase a reward item from the current student's rewards shop * Purchase a reward item from the current student's rewards shop
* @param itemId number * @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<RewardPurchaseResponse> { async purchaseReward(itemId: number): Promise<RewardPurchaseResponse> {
return ( return (