@retroachievements/api 1.5.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/achievement/getAchievementUnlocks.d.ts +1 -1
- package/dist/api.cjs +1 -1
- package/dist/api.cjs.map +1 -1
- package/dist/api.modern.js +1 -1
- package/dist/api.modern.js.map +1 -1
- package/dist/api.module.js +1 -1
- package/dist/api.module.js.map +1 -1
- package/dist/api.umd.js +1 -1
- package/dist/api.umd.js.map +1 -1
- package/dist/console/getConsoleIds.d.ts +15 -4
- package/dist/console/getGameList.d.ts +1 -1
- package/dist/console/models/fetched-system.model.d.ts +7 -0
- package/dist/console/models/get-console-ids-response.model.d.ts +2 -0
- package/dist/console/models/index.d.ts +1 -1
- package/dist/feed/getAchievementOfTheWeek.d.ts +1 -1
- package/dist/feed/getActiveClaims.d.ts +1 -1
- package/dist/feed/getTopTenUsers.d.ts +3 -3
- package/dist/feed/models/top-ten-users-entity.model.d.ts +1 -1
- package/dist/game/getAchievementCount.d.ts +1 -1
- package/dist/game/getAchievementDistribution.d.ts +1 -1
- package/dist/game/getGame.d.ts +1 -1
- package/dist/game/getGameExtended.d.ts +1 -1
- package/dist/game/getGameRankAndScore.d.ts +1 -1
- package/dist/game/getGameRating.d.ts +1 -1
- package/dist/ticket/getTicketData.d.ts +9 -9
- package/dist/user/getAchievementsEarnedBetween.d.ts +4 -4
- package/dist/user/getAchievementsEarnedOnDay.d.ts +4 -4
- package/dist/user/getGameInfoAndUserProgress.d.ts +9 -5
- package/dist/user/getUserAwards.d.ts +4 -4
- package/dist/user/getUserClaims.d.ts +4 -4
- package/dist/user/getUserCompletedGames.d.ts +4 -4
- package/dist/user/getUserCompletionProgress.d.ts +4 -4
- package/dist/user/getUserGameRankAndScore.d.ts +4 -4
- package/dist/user/getUserPoints.d.ts +4 -4
- package/dist/user/getUserProfile.d.ts +4 -4
- package/dist/user/getUserProgress.d.ts +4 -4
- package/dist/user/getUserRecentAchievements.d.ts +4 -4
- package/dist/user/getUserRecentlyPlayedGames.d.ts +4 -4
- package/dist/user/getUserSummary.d.ts +4 -4
- package/dist/user/models/game-info-and-user-progress.model.d.ts +2 -0
- package/dist/user/models/get-game-info-and-user-progress-response.model.d.ts +2 -0
- package/dist/utils/public/buildAuthorization.d.ts +1 -1
- package/dist/utils/public/models/auth-object.model.d.ts +2 -2
- package/package.json +6 -12
- package/src/__playground.ts +4 -4
- package/src/achievement/getAchievementUnlocks.test.ts +1 -1
- package/src/achievement/getAchievementUnlocks.ts +1 -1
- package/src/console/getConsoleIds.test.ts +15 -3
- package/src/console/getConsoleIds.ts +28 -6
- package/src/console/getGameList.test.ts +1 -1
- package/src/console/getGameList.ts +1 -1
- package/src/console/models/fetched-system.model.ts +7 -0
- package/src/console/models/get-console-ids-response.model.ts +2 -0
- package/src/console/models/index.ts +1 -1
- package/src/feed/getAchievementOfTheWeek.test.ts +2 -2
- package/src/feed/getAchievementOfTheWeek.ts +1 -1
- package/src/feed/getActiveClaims.test.ts +1 -1
- package/src/feed/getActiveClaims.ts +1 -1
- package/src/feed/getClaims.test.ts +1 -1
- package/src/feed/getTopTenUsers.test.ts +11 -11
- package/src/feed/getTopTenUsers.ts +4 -4
- package/src/feed/models/top-ten-users-entity.model.ts +1 -1
- package/src/game/getAchievementCount.test.ts +1 -1
- package/src/game/getAchievementCount.ts +1 -1
- package/src/game/getAchievementDistribution.test.ts +4 -4
- package/src/game/getAchievementDistribution.ts +1 -1
- package/src/game/getGame.test.ts +1 -1
- package/src/game/getGame.ts +1 -1
- package/src/game/getGameExtended.test.ts +1 -1
- package/src/game/getGameExtended.ts +1 -1
- package/src/game/getGameRankAndScore.test.ts +1 -1
- package/src/game/getGameRankAndScore.ts +1 -1
- package/src/game/getGameRating.test.ts +1 -1
- package/src/game/getGameRating.ts +1 -1
- package/src/ticket/getTicketData.test.ts +7 -7
- package/src/ticket/getTicketData.ts +13 -13
- package/src/user/getAchievementsEarnedBetween.test.ts +2 -2
- package/src/user/getAchievementsEarnedBetween.ts +6 -6
- package/src/user/getAchievementsEarnedOnDay.test.ts +2 -2
- package/src/user/getAchievementsEarnedOnDay.ts +6 -6
- package/src/user/getGameInfoAndUserProgress.test.ts +3 -3
- package/src/user/getGameInfoAndUserProgress.ts +22 -11
- package/src/user/getUserAwards.test.ts +2 -2
- package/src/user/getUserAwards.ts +6 -6
- package/src/user/getUserClaims.test.ts +2 -2
- package/src/user/getUserClaims.ts +6 -6
- package/src/user/getUserCompletedGames.test.ts +2 -2
- package/src/user/getUserCompletedGames.ts +6 -6
- package/src/user/getUserCompletionProgress.test.ts +2 -2
- package/src/user/getUserCompletionProgress.ts +6 -6
- package/src/user/getUserGameRankAndScore.test.ts +2 -2
- package/src/user/getUserGameRankAndScore.ts +6 -6
- package/src/user/getUserPoints.test.ts +2 -2
- package/src/user/getUserPoints.ts +6 -6
- package/src/user/getUserProfile.test.ts +2 -2
- package/src/user/getUserProfile.ts +6 -6
- package/src/user/getUserProgress.test.ts +2 -2
- package/src/user/getUserProgress.ts +6 -6
- package/src/user/getUserRecentAchievements.test.ts +2 -2
- package/src/user/getUserRecentAchievements.ts +6 -6
- package/src/user/getUserRecentlyPlayedGames.test.ts +2 -2
- package/src/user/getUserRecentlyPlayedGames.ts +6 -6
- package/src/user/getUserSummary.test.ts +4 -4
- package/src/user/getUserSummary.ts +6 -6
- package/src/user/models/game-info-and-user-progress.model.ts +8 -0
- package/src/user/models/get-game-info-and-user-progress-response.model.ts +8 -0
- package/src/utils/internal/buildRequestUrl.test.ts +2 -2
- package/src/utils/internal/buildRequestUrl.ts +1 -1
- package/src/utils/public/buildAuthorization.test.ts +3 -3
- package/src/utils/public/buildAuthorization.ts +4 -4
- package/src/utils/public/models/auth-object.model.ts +2 -2
- package/src/console/models/console-id.model.ts +0 -5
|
@@ -11,16 +11,16 @@ import type { GetUserPointsResponse, UserPoints } from "./models";
|
|
|
11
11
|
* A call to this function will retrieve a given user's hardcore
|
|
12
12
|
* and softcore points.
|
|
13
13
|
*
|
|
14
|
-
* @param authorization An object containing your
|
|
14
|
+
* @param authorization An object containing your username and webApiKey.
|
|
15
15
|
* This can be constructed with `buildAuthorization()`.
|
|
16
16
|
*
|
|
17
|
-
* @param payload.
|
|
17
|
+
* @param payload.username The user for which to retrieve the point totals for.
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* ```
|
|
21
21
|
* const userPoints = await getUserPoints(
|
|
22
22
|
* authorization,
|
|
23
|
-
* {
|
|
23
|
+
* { username: "xelnia" }
|
|
24
24
|
* );
|
|
25
25
|
* ```
|
|
26
26
|
*
|
|
@@ -34,15 +34,15 @@ import type { GetUserPointsResponse, UserPoints } from "./models";
|
|
|
34
34
|
*/
|
|
35
35
|
export const getUserPoints = async (
|
|
36
36
|
authorization: AuthObject,
|
|
37
|
-
payload: {
|
|
37
|
+
payload: { username: string }
|
|
38
38
|
): Promise<UserPoints> => {
|
|
39
|
-
const {
|
|
39
|
+
const { username } = payload;
|
|
40
40
|
|
|
41
41
|
const url = buildRequestUrl(
|
|
42
42
|
apiBaseUrl,
|
|
43
43
|
"/API_GetUserPoints.php",
|
|
44
44
|
authorization,
|
|
45
|
-
{ u:
|
|
45
|
+
{ u: username }
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
const rawResponse = await call<GetUserPointsResponse>({ url });
|
|
@@ -22,7 +22,7 @@ describe("Function: getUserProfile", () => {
|
|
|
22
22
|
it("given a username, retrieves minimal user profile information about the user", async () => {
|
|
23
23
|
// ARRANGE
|
|
24
24
|
const authorization = buildAuthorization({
|
|
25
|
-
|
|
25
|
+
username: "mockUserName",
|
|
26
26
|
webApiKey: "mockWebApiKey",
|
|
27
27
|
});
|
|
28
28
|
|
|
@@ -53,7 +53,7 @@ describe("Function: getUserProfile", () => {
|
|
|
53
53
|
|
|
54
54
|
// ACT
|
|
55
55
|
const response = await getUserProfile(authorization, {
|
|
56
|
-
|
|
56
|
+
username: "WCopeland",
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
// ASSERT
|
|
@@ -11,16 +11,16 @@ import type { GetUserProfileResponse, UserProfile } from "./models";
|
|
|
11
11
|
* A call to this function will retrieve summary information about
|
|
12
12
|
* a given user, targeted by username.
|
|
13
13
|
*
|
|
14
|
-
* @param authorization An object containing your
|
|
14
|
+
* @param authorization An object containing your username and webApiKey.
|
|
15
15
|
* This can be constructed with `buildAuthorization()`.
|
|
16
16
|
*
|
|
17
|
-
* @param payload.
|
|
17
|
+
* @param payload.username The user for which to retrieve the summary for.
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* ```
|
|
21
21
|
* const userSummary = await getUserProfile(
|
|
22
22
|
* authorization,
|
|
23
|
-
* {
|
|
23
|
+
* { username: "xelnia" }
|
|
24
24
|
* );
|
|
25
25
|
* ```
|
|
26
26
|
*
|
|
@@ -29,16 +29,16 @@ import type { GetUserProfileResponse, UserProfile } from "./models";
|
|
|
29
29
|
export const getUserProfile = async (
|
|
30
30
|
authorization: AuthObject,
|
|
31
31
|
payload: {
|
|
32
|
-
|
|
32
|
+
username: string;
|
|
33
33
|
}
|
|
34
34
|
): Promise<UserProfile> => {
|
|
35
|
-
const {
|
|
35
|
+
const { username } = payload;
|
|
36
36
|
|
|
37
37
|
const url = buildRequestUrl(
|
|
38
38
|
apiBaseUrl,
|
|
39
39
|
"/API_GetUserProfile.php",
|
|
40
40
|
authorization,
|
|
41
|
-
{ u:
|
|
41
|
+
{ u: username }
|
|
42
42
|
);
|
|
43
43
|
|
|
44
44
|
const rawResponse = await call<GetUserProfileResponse>({ url });
|
|
@@ -22,7 +22,7 @@ describe("Function: getUserProgress", () => {
|
|
|
22
22
|
it(`retrieves a map of a user's progress by game IDs`, async () => {
|
|
23
23
|
// ARRANGE
|
|
24
24
|
const authorization = buildAuthorization({
|
|
25
|
-
|
|
25
|
+
username: "mockUserName",
|
|
26
26
|
webApiKey: "mockWebApiKey",
|
|
27
27
|
});
|
|
28
28
|
|
|
@@ -53,7 +53,7 @@ describe("Function: getUserProgress", () => {
|
|
|
53
53
|
|
|
54
54
|
// ACT
|
|
55
55
|
const response = await getUserProgress(authorization, {
|
|
56
|
-
|
|
56
|
+
username: "xelnia",
|
|
57
57
|
gameIds: [1, 14_402],
|
|
58
58
|
});
|
|
59
59
|
|
|
@@ -12,10 +12,10 @@ import type { GetUserProgressResponse, UserProgress } from "./models";
|
|
|
12
12
|
* A call to this function will retrieve a given user's
|
|
13
13
|
* progress on a given list of games, targeted by game ID.
|
|
14
14
|
*
|
|
15
|
-
* @param authorization An object containing your
|
|
15
|
+
* @param authorization An object containing your username and webApiKey.
|
|
16
16
|
* This can be constructed with `buildAuthorization()`.
|
|
17
17
|
*
|
|
18
|
-
* @param payload.
|
|
18
|
+
* @param payload.username The user for which to retrieve the progress for.
|
|
19
19
|
*
|
|
20
20
|
* @param payload.gameIds An array of RetroAchievements game IDs. If you aren't
|
|
21
21
|
* sure of the game ID, visit the game's page on the website and copy the number
|
|
@@ -25,7 +25,7 @@ import type { GetUserProgressResponse, UserProgress } from "./models";
|
|
|
25
25
|
* ```
|
|
26
26
|
* const userProgress = await getUserProgress(
|
|
27
27
|
* authorization,
|
|
28
|
-
* {
|
|
28
|
+
* { username: "xelnia", gameIds: [1, 14402] }
|
|
29
29
|
* );
|
|
30
30
|
* ```
|
|
31
31
|
*
|
|
@@ -53,15 +53,15 @@ import type { GetUserProgressResponse, UserProgress } from "./models";
|
|
|
53
53
|
*/
|
|
54
54
|
export const getUserProgress = async (
|
|
55
55
|
authorization: AuthObject,
|
|
56
|
-
payload: {
|
|
56
|
+
payload: { username: string; gameIds: ID[] }
|
|
57
57
|
): Promise<UserProgress> => {
|
|
58
|
-
const {
|
|
58
|
+
const { username, gameIds } = payload;
|
|
59
59
|
|
|
60
60
|
const url = buildRequestUrl(
|
|
61
61
|
apiBaseUrl,
|
|
62
62
|
"/API_GetUserProgress.php",
|
|
63
63
|
authorization,
|
|
64
|
-
{ u:
|
|
64
|
+
{ u: username, i: gameIds.join(",") }
|
|
65
65
|
);
|
|
66
66
|
|
|
67
67
|
const rawResponse = await call<GetUserProgressResponse>({ url });
|
|
@@ -22,7 +22,7 @@ describe("Function: getUserRecentAchievements", () => {
|
|
|
22
22
|
it("retrieves a list of recently-earned user achievements", async () => {
|
|
23
23
|
// ARRANGE
|
|
24
24
|
const authorization = buildAuthorization({
|
|
25
|
-
|
|
25
|
+
username: "mockUserName",
|
|
26
26
|
webApiKey: "mockWebApiKey",
|
|
27
27
|
});
|
|
28
28
|
|
|
@@ -54,7 +54,7 @@ describe("Function: getUserRecentAchievements", () => {
|
|
|
54
54
|
|
|
55
55
|
// ACT
|
|
56
56
|
const response = await getUserRecentAchievements(authorization, {
|
|
57
|
-
|
|
57
|
+
username: "xelnia",
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
// ASSERT
|
|
@@ -15,10 +15,10 @@ import type {
|
|
|
15
15
|
* recently earned achievements, via their username. By default, it
|
|
16
16
|
* fetches achievements earned in the last hour.
|
|
17
17
|
*
|
|
18
|
-
* @param authorization An object containing your
|
|
18
|
+
* @param authorization An object containing your username and webApiKey.
|
|
19
19
|
* This can be constructed with `buildAuthorization()`.
|
|
20
20
|
*
|
|
21
|
-
* @param payload.
|
|
21
|
+
* @param payload.username The user for which to retrieve the recent achievements for.
|
|
22
22
|
*
|
|
23
23
|
* @param payload.recentMinutes Optional. Defaults to 60. How many minutes
|
|
24
24
|
* back to fetch for the given user.
|
|
@@ -27,7 +27,7 @@ import type {
|
|
|
27
27
|
* ```
|
|
28
28
|
* const userRecentAchievements = await getUserRecentAchievements(
|
|
29
29
|
* authorization,
|
|
30
|
-
* {
|
|
30
|
+
* { username: "xelnia" }
|
|
31
31
|
* );
|
|
32
32
|
* ```
|
|
33
33
|
*
|
|
@@ -55,11 +55,11 @@ import type {
|
|
|
55
55
|
*/
|
|
56
56
|
export const getUserRecentAchievements = async (
|
|
57
57
|
authorization: AuthObject,
|
|
58
|
-
payload: {
|
|
58
|
+
payload: { username: string; recentMinutes?: number }
|
|
59
59
|
): Promise<UserRecentAchievement[]> => {
|
|
60
|
-
const {
|
|
60
|
+
const { username, recentMinutes } = payload;
|
|
61
61
|
|
|
62
|
-
const queryParams: Record<string, string | number> = { u:
|
|
62
|
+
const queryParams: Record<string, string | number> = { u: username };
|
|
63
63
|
|
|
64
64
|
if (recentMinutes !== undefined) {
|
|
65
65
|
queryParams["m"] = recentMinutes;
|
|
@@ -22,7 +22,7 @@ describe("Function: getUserRecentlyPlayedGames", () => {
|
|
|
22
22
|
it(`retrieves a list of a given user's recently played games`, async () => {
|
|
23
23
|
// ARRANGE
|
|
24
24
|
const authorization = buildAuthorization({
|
|
25
|
-
|
|
25
|
+
username: "mockUserName",
|
|
26
26
|
webApiKey: "mockWebApiKey",
|
|
27
27
|
});
|
|
28
28
|
|
|
@@ -52,7 +52,7 @@ describe("Function: getUserRecentlyPlayedGames", () => {
|
|
|
52
52
|
|
|
53
53
|
// ACT
|
|
54
54
|
const response = await getUserRecentlyPlayedGames(authorization, {
|
|
55
|
-
|
|
55
|
+
username: "xelnia",
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
// ASSERT
|
|
@@ -14,10 +14,10 @@ import type {
|
|
|
14
14
|
* A call to this function will retrieve a list of a target user's
|
|
15
15
|
* recently played games, via their username.
|
|
16
16
|
*
|
|
17
|
-
* @param authorization An object containing your
|
|
17
|
+
* @param authorization An object containing your username and webApiKey.
|
|
18
18
|
* This can be constructed with `buildAuthorization()`.
|
|
19
19
|
*
|
|
20
|
-
* @param payload.
|
|
20
|
+
* @param payload.username The user for which to retrieve the summary for.
|
|
21
21
|
*
|
|
22
22
|
* @param payload.count Optional. Defaults to 10. Max is 50. How many
|
|
23
23
|
* recently played games for the user to retrieve.
|
|
@@ -29,7 +29,7 @@ import type {
|
|
|
29
29
|
* ```
|
|
30
30
|
* const userRecentlyPlayedGames = await getUserRecentlyPlayedGames(
|
|
31
31
|
* authorization,
|
|
32
|
-
* {
|
|
32
|
+
* { username: "xelnia" }
|
|
33
33
|
* );
|
|
34
34
|
* ```
|
|
35
35
|
*
|
|
@@ -55,11 +55,11 @@ import type {
|
|
|
55
55
|
*/
|
|
56
56
|
export const getUserRecentlyPlayedGames = async (
|
|
57
57
|
authorization: AuthObject,
|
|
58
|
-
payload: {
|
|
58
|
+
payload: { username: string; offset?: number; count?: number }
|
|
59
59
|
): Promise<UserRecentlyPlayedGames> => {
|
|
60
|
-
const {
|
|
60
|
+
const { username, offset, count } = payload;
|
|
61
61
|
|
|
62
|
-
const queryParams: Record<string, string | number> = { u:
|
|
62
|
+
const queryParams: Record<string, string | number> = { u: username };
|
|
63
63
|
|
|
64
64
|
if (offset !== undefined) {
|
|
65
65
|
queryParams["o"] = offset;
|
|
@@ -24,7 +24,7 @@ describe("Function: getUserSummary", () => {
|
|
|
24
24
|
it("given a username, retrieves user summary information about the user", async () => {
|
|
25
25
|
// ARRANGE
|
|
26
26
|
const authorization = buildAuthorization({
|
|
27
|
-
|
|
27
|
+
username: "mockUserName",
|
|
28
28
|
webApiKey: "mockWebApiKey",
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -38,7 +38,7 @@ describe("Function: getUserSummary", () => {
|
|
|
38
38
|
|
|
39
39
|
// ACT
|
|
40
40
|
const response = await getUserSummary(authorization, {
|
|
41
|
-
|
|
41
|
+
username: "WCopeland",
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
// ASSERT
|
|
@@ -48,7 +48,7 @@ describe("Function: getUserSummary", () => {
|
|
|
48
48
|
it("given the API returns a 503, throws an error", async () => {
|
|
49
49
|
// ARRANGE
|
|
50
50
|
const authorization = buildAuthorization({
|
|
51
|
-
|
|
51
|
+
username: "mockUserName",
|
|
52
52
|
webApiKey: "mockWebApiKey",
|
|
53
53
|
});
|
|
54
54
|
|
|
@@ -62,7 +62,7 @@ describe("Function: getUserSummary", () => {
|
|
|
62
62
|
|
|
63
63
|
// ASSERT
|
|
64
64
|
await expect(
|
|
65
|
-
getUserSummary(authorization, {
|
|
65
|
+
getUserSummary(authorization, { username: "WCopeland" })
|
|
66
66
|
).rejects.toThrow();
|
|
67
67
|
});
|
|
68
68
|
});
|
|
@@ -11,10 +11,10 @@ import type { GetUserSummaryResponse, UserSummary } from "./models";
|
|
|
11
11
|
* A call to this function will retrieve summary information about
|
|
12
12
|
* a given user, targeted by username.
|
|
13
13
|
*
|
|
14
|
-
* @param authorization An object containing your
|
|
14
|
+
* @param authorization An object containing your username and webApiKey.
|
|
15
15
|
* This can be constructed with `buildAuthorization()`.
|
|
16
16
|
*
|
|
17
|
-
* @param payload.
|
|
17
|
+
* @param payload.username The user for which to retrieve the summary for.
|
|
18
18
|
*
|
|
19
19
|
* @param payload.recentGamesCount Optional. The number of recent games to return.
|
|
20
20
|
* This defaults to 0.
|
|
@@ -26,7 +26,7 @@ import type { GetUserSummaryResponse, UserSummary } from "./models";
|
|
|
26
26
|
* ```
|
|
27
27
|
* const userSummary = await getUserSummary(
|
|
28
28
|
* authorization,
|
|
29
|
-
* {
|
|
29
|
+
* { username: "xelnia" }
|
|
30
30
|
* );
|
|
31
31
|
* ```
|
|
32
32
|
*
|
|
@@ -35,14 +35,14 @@ import type { GetUserSummaryResponse, UserSummary } from "./models";
|
|
|
35
35
|
export const getUserSummary = async (
|
|
36
36
|
authorization: AuthObject,
|
|
37
37
|
payload: {
|
|
38
|
-
|
|
38
|
+
username: string;
|
|
39
39
|
recentGamesCount?: number;
|
|
40
40
|
recentAchievementsCount?: number;
|
|
41
41
|
}
|
|
42
42
|
): Promise<UserSummary> => {
|
|
43
|
-
const {
|
|
43
|
+
const { username, recentGamesCount, recentAchievementsCount } = payload;
|
|
44
44
|
|
|
45
|
-
const queryParams: Record<string, string | number> = { u:
|
|
45
|
+
const queryParams: Record<string, string | number> = { u: username };
|
|
46
46
|
|
|
47
47
|
if (recentGamesCount !== undefined) {
|
|
48
48
|
queryParams["g"] = recentGamesCount;
|
|
@@ -16,4 +16,12 @@ export interface GameInfoAndUserProgress extends GameExtended {
|
|
|
16
16
|
numAwardedToUserHardcore: number;
|
|
17
17
|
userCompletion: string;
|
|
18
18
|
userCompletionHardcore: string;
|
|
19
|
+
|
|
20
|
+
highestAwardKind?:
|
|
21
|
+
| "mastered"
|
|
22
|
+
| "completed"
|
|
23
|
+
| "beaten-hardcore"
|
|
24
|
+
| "beaten-softcore"
|
|
25
|
+
| null;
|
|
26
|
+
highestAwardDate?: string;
|
|
19
27
|
}
|
|
@@ -25,4 +25,12 @@ export interface GetGameInfoAndUserProgressResponse
|
|
|
25
25
|
NumAwardedToUserHardcore: number;
|
|
26
26
|
UserCompletion: string;
|
|
27
27
|
UserCompletionHardcore: string;
|
|
28
|
+
|
|
29
|
+
HighestAwardKind?:
|
|
30
|
+
| "mastered"
|
|
31
|
+
| "completed"
|
|
32
|
+
| "beaten-hardcore"
|
|
33
|
+
| "beaten-softcore"
|
|
34
|
+
| null;
|
|
35
|
+
HighestAwardDate?: string;
|
|
28
36
|
}
|
|
@@ -22,7 +22,7 @@ describe("Util: buildRequestUrl", () => {
|
|
|
22
22
|
const requestUrl = buildRequestUrl(
|
|
23
23
|
baseUrl,
|
|
24
24
|
endpointUrl,
|
|
25
|
-
{
|
|
25
|
+
{ username: "TestUser", webApiKey: "mockWebApiKey" },
|
|
26
26
|
args as any
|
|
27
27
|
);
|
|
28
28
|
|
|
@@ -39,7 +39,7 @@ describe("Util: buildRequestUrl", () => {
|
|
|
39
39
|
|
|
40
40
|
// ACT
|
|
41
41
|
const requestUrl = buildRequestUrl(baseUrl, endpointUrl, {
|
|
42
|
-
|
|
42
|
+
username: "TestUser",
|
|
43
43
|
webApiKey: "mockWebApiKey",
|
|
44
44
|
});
|
|
45
45
|
|
|
@@ -14,7 +14,7 @@ export const buildRequestUrl = (
|
|
|
14
14
|
// `z` and `y` are expected query params from the RA API.
|
|
15
15
|
// Authentication is handled purely by query params.
|
|
16
16
|
const queryParamValues: Record<string, string> = {
|
|
17
|
-
z: authObject.
|
|
17
|
+
z: authObject.username,
|
|
18
18
|
y: authObject.webApiKey,
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -9,7 +9,7 @@ describe("Util: buildAuthorization", () => {
|
|
|
9
9
|
it("returns the same object it is given", () => {
|
|
10
10
|
// ARRANGE
|
|
11
11
|
const myAuth = {
|
|
12
|
-
|
|
12
|
+
username: "myUserName",
|
|
13
13
|
webApiKey: "myWebApiKey",
|
|
14
14
|
};
|
|
15
15
|
|
|
@@ -20,7 +20,7 @@ describe("Util: buildAuthorization", () => {
|
|
|
20
20
|
expect(authorization).toEqual(myAuth);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
it("throws an error if missing a
|
|
23
|
+
it("throws an error if missing a username", () => {
|
|
24
24
|
// ASSERT
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
26
26
|
// @ts-ignore - We're assuming the user is not using a TypeScript project.
|
|
@@ -31,6 +31,6 @@ describe("Util: buildAuthorization", () => {
|
|
|
31
31
|
// ASSERT
|
|
32
32
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
33
33
|
// @ts-ignore - We're assuming the user is not using a TypeScript project.
|
|
34
|
-
expect(() => buildAuthorization({
|
|
34
|
+
expect(() => buildAuthorization({ username: "mockUserName" })).toThrow();
|
|
35
35
|
});
|
|
36
36
|
});
|
|
@@ -15,19 +15,19 @@ import type { AuthObject } from "./models";
|
|
|
15
15
|
* @example
|
|
16
16
|
* ```
|
|
17
17
|
* const authorization = buildAuthorization({
|
|
18
|
-
*
|
|
18
|
+
* username: "Scott",
|
|
19
19
|
* webApiKey: "LtjCwW16nJI7cqOyPIQtXk8v1cfF0tmO"
|
|
20
20
|
* });
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
export const buildAuthorization = (options: AuthObject): AuthObject => {
|
|
24
|
-
if (!options.
|
|
24
|
+
if (!options.username || !options.webApiKey) {
|
|
25
25
|
throw new Error(`
|
|
26
26
|
buildAuthorization() requires an object containing a
|
|
27
|
-
|
|
27
|
+
username and webApiKey. eg:
|
|
28
28
|
|
|
29
29
|
const authorization = buildAuthorization({
|
|
30
|
-
|
|
30
|
+
username: "myUserName",
|
|
31
31
|
webApiKey: "myWebApiKey"
|
|
32
32
|
})
|
|
33
33
|
`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Each RetroAchievements API call is uniquely authenticated
|
|
3
|
-
* using a
|
|
3
|
+
* using a username + API key combination. Your account's personal
|
|
4
4
|
* Web API Key can be found on the Settings page.
|
|
5
5
|
*/
|
|
6
6
|
export interface AuthObject {
|
|
@@ -9,7 +9,7 @@ export interface AuthObject {
|
|
|
9
9
|
* For example, https://retroachievements.org/user/Scott would have a value
|
|
10
10
|
* of "Scott".
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
username: string;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* This can be found in the "Keys" section of your Settings page on the
|