Skip to content

Commit 340b195

Browse files
authored
feat(getGameInfoAndUserProgress): add new query param for highest award metadata (#96)
1 parent f7427fa commit 340b195

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

src/user/getGameInfoAndUserProgress.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ import type {
2727
* @param payload.username The user for which to retrieve the
2828
* game progress for.
2929
*
30+
* @param payload.shouldIncludeHighestAwardMetadata Include a "HighestAwardKind"
31+
* and a "HighestAwardDate" for the given user and game ID.
32+
*
3033
* @example
3134
* ```
3235
* const gameInfoAndUserProgress = await getGameInfoAndUserProgress(
@@ -87,18 +90,27 @@ import type {
8790
*/
8891
export const getGameInfoAndUserProgress = async (
8992
authorization: AuthObject,
90-
payload: { gameId: ID; username: string }
93+
payload: {
94+
gameId: ID;
95+
username: string;
96+
shouldIncludeHighestAwardMetadata?: boolean;
97+
}
9198
): Promise<GameInfoAndUserProgress> => {
92-
const { gameId, username } = payload;
99+
const { gameId, username, shouldIncludeHighestAwardMetadata } = payload;
100+
101+
const params: Record<string, any> = {
102+
g: gameId,
103+
u: username,
104+
};
105+
if (shouldIncludeHighestAwardMetadata) {
106+
params.a = 1;
107+
}
93108

94109
const url = buildRequestUrl(
95110
apiBaseUrl,
96111
"/API_GetGameInfoAndUserProgress.php",
97112
authorization,
98-
{
99-
g: gameId,
100-
u: username,
101-
}
113+
params
102114
);
103115

104116
const rawResponse = await call<GetGameInfoAndUserProgressResponse>({ url });

src/user/models/game-info-and-user-progress.model.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,12 @@ export interface GameInfoAndUserProgress extends GameExtended {
1616
numAwardedToUserHardcore: number;
1717
userCompletion: string;
1818
userCompletionHardcore: string;
19+
20+
highestAwardKind?:
21+
| "mastered"
22+
| "completed"
23+
| "beaten-hardcore"
24+
| "beaten-softcore"
25+
| null;
26+
highestAwardDate?: string;
1927
}

src/user/models/get-game-info-and-user-progress-response.model.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,12 @@ export interface GetGameInfoAndUserProgressResponse
2525
NumAwardedToUserHardcore: number;
2626
UserCompletion: string;
2727
UserCompletionHardcore: string;
28+
29+
HighestAwardKind?:
30+
| "mastered"
31+
| "completed"
32+
| "beaten-hardcore"
33+
| "beaten-softcore"
34+
| null;
35+
HighestAwardDate?: string;
2836
}

0 commit comments

Comments
 (0)