diff --git a/src/core/studentClient.ts b/src/core/studentClient.ts index 464a22d..2be301d 100644 --- a/src/core/studentClient.ts +++ b/src/core/studentClient.ts @@ -1,6 +1,7 @@ import { API_BASE_STUDENT, BASE_URL } from "../utils/consts.ts"; import { BaseClient } from "./baseClient.ts"; import { parseCookies } from "../utils/utils.ts"; +import { RewardPurchaseResponse, RewardsResponse } from "../types.ts" /** * Student Client @@ -58,4 +59,34 @@ export class StudentClient extends BaseClient { const user = await this.getStudentInfo(); this.studentId = user.data.user.id; } + /** + * Gets the current student's rewards shop + * @returns Array of purchasable items + */ + async getRewards(): Promise { + return ( + await this.makeAuthedRequest( + this.API_BASE + "/rewards/" + this.studentId, + { + method: "GET", + }, + ) + ); + } + /** + * Purchase a reward item from the current student's rewards shop + * @param itemId number + * @returns An object containg balence and id + */ + async postRewardPurchase(itemId: number): Promise { + return ( + await this.makeAuthedRequest( + this.API_BASE + "/purchase/" + itemId, + { + method: "POST", + body: `pupil_id=${this.studentId}` + } + ) + ) + } }