From 340b195ed74ab779d83562e416cee35752f44648 Mon Sep 17 00:00:00 2001 From: Wes Copeland Date: Fri, 24 May 2024 15:38:19 -0400 Subject: [PATCH] feat(getGameInfoAndUserProgress): add new query param for highest award metadata (#96) --- src/user/getGameInfoAndUserProgress.ts | 24 ++++++++++++++----- .../game-info-and-user-progress.model.ts | 8 +++++++ ...e-info-and-user-progress-response.model.ts | 8 +++++++ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/user/getGameInfoAndUserProgress.ts b/src/user/getGameInfoAndUserProgress.ts index d383a0b..c7a7b05 100644 --- a/src/user/getGameInfoAndUserProgress.ts +++ b/src/user/getGameInfoAndUserProgress.ts @@ -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( @@ -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 => { - const { gameId, username } = payload; + const { gameId, username, shouldIncludeHighestAwardMetadata } = payload; + + const params: Record = { + 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({ url }); diff --git a/src/user/models/game-info-and-user-progress.model.ts b/src/user/models/game-info-and-user-progress.model.ts index 4842631..7fbba87 100644 --- a/src/user/models/game-info-and-user-progress.model.ts +++ b/src/user/models/game-info-and-user-progress.model.ts @@ -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; } diff --git a/src/user/models/get-game-info-and-user-progress-response.model.ts b/src/user/models/get-game-info-and-user-progress-response.model.ts index 2f05fdc..11a6ff8 100644 --- a/src/user/models/get-game-info-and-user-progress-response.model.ts +++ b/src/user/models/get-game-info-and-user-progress-response.model.ts @@ -25,4 +25,12 @@ export interface GetGameInfoAndUserProgressResponse NumAwardedToUserHardcore: number; UserCompletion: string; UserCompletionHardcore: string; + + HighestAwardKind?: + | "mastered" + | "completed" + | "beaten-hardcore" + | "beaten-softcore" + | null; + HighestAwardDate?: string; }