fix(api): fix api integration for quest map and adjacent components
This commit is contained in:
@ -1,5 +1,11 @@
|
||||
import type { Leaderboard, PredictedScore } from "../types/leaderboard";
|
||||
import type { Lesson, LessonsResponse } from "../types/lesson";
|
||||
import type {
|
||||
ClaimedRewardResponse,
|
||||
QuestArc,
|
||||
UserInventory,
|
||||
UserTitle,
|
||||
} from "../types/quest";
|
||||
import type {
|
||||
SessionAnswerResponse,
|
||||
SessionQuestionsResponse,
|
||||
@ -242,5 +248,46 @@ class ApiClient {
|
||||
async fetchPredictedScore(token: string): Promise<PredictedScore> {
|
||||
return this.authenticatedRequest<PredictedScore>(`/prediction/`, token);
|
||||
}
|
||||
|
||||
/*------------QUEST JOURNEY-------------- */
|
||||
async fetchUserJourney(token: string): Promise<QuestArc[]> {
|
||||
return this.authenticatedRequest<QuestArc[]>(`/journey/`, token);
|
||||
}
|
||||
async claimReward(
|
||||
token: string,
|
||||
node_id: string,
|
||||
): Promise<ClaimedRewardResponse> {
|
||||
return this.authenticatedRequest<ClaimedRewardResponse>(
|
||||
`/journey/claim/${node_id}`,
|
||||
token,
|
||||
{
|
||||
method: "POST",
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/*------------INVENTORY-------------- */
|
||||
async fetchUserInventory(token: string): Promise<UserInventory> {
|
||||
return this.authenticatedRequest<UserInventory>(`/inventory/`, token);
|
||||
}
|
||||
async activateItem(token: string, itemId: string): Promise<UserInventory> {
|
||||
return this.authenticatedRequest<UserInventory>(
|
||||
`/inventory/use/${itemId}`,
|
||||
token,
|
||||
);
|
||||
}
|
||||
/*------------TITLES-------------- */
|
||||
async fetchUserTitles(token: string): Promise<UserTitle[]> {
|
||||
return this.authenticatedRequest<UserTitle[]>(`/inventory/titles/`, token);
|
||||
}
|
||||
async equipTitle(
|
||||
token: string,
|
||||
titleData: { title_id: string },
|
||||
): Promise<string> {
|
||||
return this.authenticatedRequest<string>(`/inventory/titles/equip`, token, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(titleData),
|
||||
});
|
||||
}
|
||||
}
|
||||
export const api = new ApiClient(API_URL);
|
||||
|
||||
Reference in New Issue
Block a user