Skip to content

Commit

Permalink
feat(getGameInfoAndUserProgress): add new query param for highest awa…
Browse files Browse the repository at this point in the history
…rd metadata
  • Loading branch information
wescopeland committed May 24, 2024
1 parent 3600962 commit 8d8ec97
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/user/getGameInfoAndUserProgress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import type {
* @param payload.userName The user for which to retrieve the
* game progress for.
*
* @param payload.shouldIncludeHighestAwardMetadata Include a "HighestAwardKind"
* and a "HighestAwardDate" for the given user and game ID.
*
* @example
* ```
* const gameInfoAndUserProgress = await getGameInfoAndUserProgress(
Expand Down Expand Up @@ -87,18 +90,27 @@ import type {
*/
export const getGameInfoAndUserProgress = async (
authorization: AuthObject,
payload: { gameId: ID; userName: string }
payload: {
gameId: ID;
userName: string;
shouldIncludeHighestAwardMetadata?: boolean;
}
): Promise<GameInfoAndUserProgress> => {
const { gameId, userName } = payload;
const { gameId, userName, shouldIncludeHighestAwardMetadata } = payload;

const params: Record<string, any> = {
g: gameId,
u: userName,
};
if (shouldIncludeHighestAwardMetadata) {
params.a = 1;
}

const url = buildRequestUrl(
apiBaseUrl,
"/API_GetGameInfoAndUserProgress.php",
authorization,
{
g: gameId,
u: userName,
}
params
);

const rawResponse = await call<GetGameInfoAndUserProgressResponse>({ url });
Expand Down
8 changes: 8 additions & 0 deletions src/user/models/game-info-and-user-progress.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@ export interface GameInfoAndUserProgress extends GameExtended {
numAwardedToUserHardcore: number;
userCompletion: string;
userCompletionHardcore: string;

highestAwardKind?:
| "mastered"
| "completed"
| "beaten-hardcore"
| "beaten-softcore"
| null;
highestAwardDate?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ export interface GetGameInfoAndUserProgressResponse
NumAwardedToUserHardcore: number;
UserCompletion: string;
UserCompletionHardcore: string;

HighestAwardKind?:
| "mastered"
| "completed"
| "beaten-hardcore"
| "beaten-softcore"
| null;
HighestAwardDate?: string;
}

0 comments on commit 8d8ec97

Please sign in to comment.