@retroachievements/api 1.0.0-rc.0 → 1.0.0-rc.2
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/dist/__playground.d.ts +2 -1
- package/dist/achievement/getAchievementUnlocks.d.ts +2 -1
- package/dist/achievement/models/achievement-unlock-entity.model.d.ts +23 -0
- package/dist/achievement/models/get-achievement-unlocks-response.model.d.ts +23 -1
- package/dist/api.cjs.development.js +597 -853
- package/dist/api.cjs.development.js.map +1 -1
- package/dist/api.cjs.production.min.js +1 -1
- package/dist/api.cjs.production.min.js.map +1 -1
- package/dist/api.esm.js +597 -853
- package/dist/api.esm.js.map +1 -1
- package/dist/console/getGameList.d.ts +2 -1
- package/dist/console/models/game-list.model.d.ts +1 -1
- package/dist/console/models/get-console-ids-response.model.d.ts +1 -1
- package/dist/console/models/get-game-list-response.model.d.ts +1 -1
- package/dist/feed/getTicketData.d.ts +4 -3
- package/dist/feed/models/get-active-claims-response.model.d.ts +1 -1
- package/dist/feed/models/get-top-ten-users-response.model.d.ts +1 -1
- package/dist/feed/models/most-ticketed-games.model.d.ts +1 -2
- package/dist/feed/models/top-ten-users.model.d.ts +1 -1
- package/dist/game/getAchievementCount.d.ts +2 -1
- package/dist/game/getAchievementDistribution.d.ts +2 -1
- package/dist/game/getGame.d.ts +2 -1
- package/dist/game/getGameExtended.d.ts +2 -1
- package/dist/game/getGameRankAndScore.d.ts +2 -1
- package/dist/game/getGameRating.d.ts +2 -1
- package/dist/game/models/get-achievement-distribution-response.model.d.ts +1 -1
- package/dist/game/models/get-game-rank-and-score-response.model.d.ts +1 -1
- package/dist/user/getAchievementsEarnedBetween.d.ts +19 -19
- package/dist/user/getGameInfoAndUserProgress.d.ts +2 -1
- package/dist/user/getUserClaims.d.ts +1 -1
- package/dist/user/getUserCompletedGames.d.ts +1 -1
- package/dist/user/getUserGameRankAndScore.d.ts +2 -1
- package/dist/user/getUserPoints.d.ts +1 -1
- package/dist/user/getUserProgress.d.ts +5 -4
- package/dist/user/models/dated-user-achievement.model.d.ts +1 -1
- package/dist/user/models/dated-user-achievements-response.model.d.ts +1 -1
- package/dist/user/models/game-info-and-user-progress.model.d.ts +1 -1
- package/dist/user/models/get-game-info-and-user-progress-response.model.d.ts +2 -2
- package/dist/user/models/get-user-completed-games-response.model.d.ts +1 -1
- package/dist/user/models/get-user-game-rank-and-score-response.model.d.ts +1 -1
- package/dist/user/models/get-user-progress-response.model.d.ts +1 -1
- package/dist/user/models/get-user-recently-played-games-response.model.d.ts +2 -1
- package/dist/user/models/user-claims-response.model.d.ts +1 -1
- package/dist/user/models/user-claims.model.d.ts +1 -1
- package/dist/user/models/user-completed-games.model.d.ts +2 -3
- package/dist/user/models/user-game-rank-and-score.model.d.ts +2 -3
- package/dist/user/models/user-progress.model.d.ts +2 -3
- package/dist/user/models/user-recently-played-games.model.d.ts +3 -3
- package/dist/user/models/user-summary.model.d.ts +5 -6
- package/dist/utils/internal/id.model.d.ts +1 -0
- package/dist/utils/internal/index.d.ts +1 -0
- package/package.json +32 -27
- package/src/__playground.ts +25 -12
- package/src/achievement/getAchievementUnlocks.test.ts +48 -16
- package/src/achievement/getAchievementUnlocks.ts +4 -3
- package/src/achievement/models/achievement-unlock-entity.model.ts +19 -0
- package/src/achievement/models/get-achievement-unlocks-response.model.ts +17 -1
- package/src/console/getGameList.ts +2 -2
- package/src/feed/getTicketData.ts +4 -3
- package/src/feed/models/most-ticketed-games.model.ts +1 -1
- package/src/game/getAchievementCount.ts +2 -1
- package/src/game/getAchievementDistribution.test.ts +2 -4
- package/src/game/getAchievementDistribution.ts +2 -1
- package/src/game/getGame.ts +2 -1
- package/src/game/getGameExtended.ts +2 -1
- package/src/game/getGameRankAndScore.ts +2 -1
- package/src/game/getGameRating.ts +2 -1
- package/src/user/getAchievementsEarnedBetween.ts +19 -19
- package/src/user/getGameInfoAndUserProgress.ts +2 -1
- package/src/user/getUserClaims.ts +1 -1
- package/src/user/getUserCompletedGames.ts +1 -1
- package/src/user/getUserGameRankAndScore.ts +2 -1
- package/src/user/getUserPoints.ts +1 -1
- package/src/user/getUserProgress.ts +5 -4
- package/src/user/getUserRecentlyPlayedGames.test.ts +4 -2
- package/src/user/getUserRecentlyPlayedGames.ts +2 -1
- package/src/user/models/get-user-recently-played-games-response.model.ts +1 -0
- package/src/user/models/user-completed-games.model.ts +1 -1
- package/src/user/models/user-game-rank-and-score.model.ts +1 -1
- package/src/user/models/user-progress.model.ts +1 -1
- package/src/user/models/user-recently-played-games.model.ts +2 -1
- package/src/user/models/user-summary.model.ts +5 -5
- package/src/utils/internal/id.model.ts +1 -0
- package/src/utils/internal/index.ts +1 -0
- package/src/utils/internal/serializeProperties.ts +1 -1
|
@@ -26,14 +26,30 @@ describe("Function: getAchievementUnlocks", () => {
|
|
|
26
26
|
webApiKey: "mockWebApiKey"
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
const mockResponse: GetAchievementUnlocksResponse =
|
|
30
|
-
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
const mockResponse: GetAchievementUnlocksResponse = {
|
|
30
|
+
Achievement: {
|
|
31
|
+
ID: "1",
|
|
32
|
+
Title: "Ring Collector",
|
|
33
|
+
Description: "Collect 100 Rings!",
|
|
34
|
+
Points: "5",
|
|
35
|
+
TrueRatio: "6",
|
|
36
|
+
Author: "Scott",
|
|
37
|
+
DateCreated: "2012-11-02 00:03:12",
|
|
38
|
+
DateModified: "2022-06-11 16:52:35"
|
|
39
|
+
},
|
|
40
|
+
Console: { ID: "1", Title: "Mega Drive" },
|
|
41
|
+
Game: { ID: "1", Title: "Sonic the Hedgehog" },
|
|
42
|
+
UnlocksCount: 9524,
|
|
43
|
+
TotalPlayers: 21_710,
|
|
44
|
+
Unlocks: [
|
|
45
|
+
{
|
|
46
|
+
User: "Tiotroll2022",
|
|
47
|
+
RAPoints: "348",
|
|
48
|
+
DateAwarded: "2023-01-29 21:45:41",
|
|
49
|
+
HardcoreMode: "0"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
};
|
|
37
53
|
|
|
38
54
|
let searchParams = "";
|
|
39
55
|
|
|
@@ -59,13 +75,29 @@ describe("Function: getAchievementUnlocks", () => {
|
|
|
59
75
|
expect(searchParams).toContain("o=1");
|
|
60
76
|
expect(searchParams).toContain("c=1");
|
|
61
77
|
|
|
62
|
-
expect(response).toEqual(
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
78
|
+
expect(response).toEqual({
|
|
79
|
+
achievement: {
|
|
80
|
+
id: 1,
|
|
81
|
+
title: "Ring Collector",
|
|
82
|
+
description: "Collect 100 Rings!",
|
|
83
|
+
points: 5,
|
|
84
|
+
trueRatio: 6,
|
|
85
|
+
author: "Scott",
|
|
86
|
+
dateCreated: "2012-11-02 00:03:12",
|
|
87
|
+
dateModified: "2022-06-11 16:52:35"
|
|
88
|
+
},
|
|
89
|
+
console: { id: 1, title: "Mega Drive" },
|
|
90
|
+
game: { id: 1, title: "Sonic the Hedgehog" },
|
|
91
|
+
unlocksCount: 9524,
|
|
92
|
+
totalPlayers: 21_710,
|
|
93
|
+
unlocks: [
|
|
94
|
+
{
|
|
95
|
+
user: "Tiotroll2022",
|
|
96
|
+
raPoints: 348,
|
|
97
|
+
dateAwarded: "2023-01-29 21:45:41",
|
|
98
|
+
hardcoreMode: false
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
});
|
|
70
102
|
});
|
|
71
103
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ID } from "../utils/internal";
|
|
1
2
|
import {
|
|
2
3
|
apiBaseUrl,
|
|
3
4
|
buildRequestUrl,
|
|
@@ -50,11 +51,11 @@ import type {
|
|
|
50
51
|
*/
|
|
51
52
|
export const getAchievementUnlocks = async (
|
|
52
53
|
authorization: AuthObject,
|
|
53
|
-
payload: { achievementId:
|
|
54
|
+
payload: { achievementId: ID; offset?: number; count?: number }
|
|
54
55
|
): Promise<AchievementUnlockEntity[]> => {
|
|
55
56
|
const { achievementId, offset, count } = payload;
|
|
56
57
|
|
|
57
|
-
const queryParams: Record<string, number> = { a: achievementId };
|
|
58
|
+
const queryParams: Record<string, number | string> = { a: achievementId };
|
|
58
59
|
|
|
59
60
|
if (offset) {
|
|
60
61
|
queryParams.o = offset;
|
|
@@ -74,7 +75,7 @@ export const getAchievementUnlocks = async (
|
|
|
74
75
|
const rawResponse = await call<GetAchievementUnlocksResponse>({ url });
|
|
75
76
|
|
|
76
77
|
return serializeProperties(rawResponse, {
|
|
77
|
-
shouldCastToNumbers: ["RAPoints"],
|
|
78
|
+
shouldCastToNumbers: ["ID", "Points", "TrueRatio", "RAPoints"],
|
|
78
79
|
shouldMapToBooleans: ["HardcoreMode"]
|
|
79
80
|
});
|
|
80
81
|
};
|
|
@@ -4,3 +4,22 @@ export interface AchievementUnlockEntity {
|
|
|
4
4
|
dateAwarded: string;
|
|
5
5
|
hardcoreMode: boolean;
|
|
6
6
|
}
|
|
7
|
+
|
|
8
|
+
export interface AchievementUnlocksMetadata {
|
|
9
|
+
achievement: {
|
|
10
|
+
id: number;
|
|
11
|
+
title: string;
|
|
12
|
+
description: string;
|
|
13
|
+
points: number;
|
|
14
|
+
trueRatio: number;
|
|
15
|
+
author: string;
|
|
16
|
+
dateCreated: string;
|
|
17
|
+
dateModified: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
console: { id: number; title: string };
|
|
21
|
+
game: { id: number; title: string };
|
|
22
|
+
unlocksCount: number;
|
|
23
|
+
totalPlayers: number;
|
|
24
|
+
unlocks: AchievementUnlockEntity[];
|
|
25
|
+
}
|
|
@@ -5,4 +5,20 @@ interface AchievementUnlocksResponseEntity {
|
|
|
5
5
|
HardcoreMode: string;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export
|
|
8
|
+
export interface GetAchievementUnlocksResponse {
|
|
9
|
+
Achievement: {
|
|
10
|
+
ID: string;
|
|
11
|
+
Title: string;
|
|
12
|
+
Description: string;
|
|
13
|
+
Points: string;
|
|
14
|
+
TrueRatio: string;
|
|
15
|
+
Author: string;
|
|
16
|
+
DateCreated: string;
|
|
17
|
+
DateModified: string;
|
|
18
|
+
};
|
|
19
|
+
Console: { ID: string; Title: string };
|
|
20
|
+
Game: { ID: string; Title: string };
|
|
21
|
+
UnlocksCount: number;
|
|
22
|
+
TotalPlayers: number;
|
|
23
|
+
Unlocks: AchievementUnlocksResponseEntity[];
|
|
24
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ID } from "../utils/internal";
|
|
1
2
|
import {
|
|
2
3
|
apiBaseUrl,
|
|
3
4
|
buildRequestUrl,
|
|
@@ -6,7 +7,6 @@ import {
|
|
|
6
7
|
} from "../utils/internal";
|
|
7
8
|
import type { AuthObject } from "../utils/public";
|
|
8
9
|
import type { GameList, GetGameListResponse } from "./models";
|
|
9
|
-
|
|
10
10
|
/**
|
|
11
11
|
* A call to this function will retrieve the complete list
|
|
12
12
|
* of games for a specified console on the RetroAchievements.org
|
|
@@ -55,7 +55,7 @@ import type { GameList, GetGameListResponse } from "./models";
|
|
|
55
55
|
export const getGameList = async (
|
|
56
56
|
authorization: AuthObject,
|
|
57
57
|
payload: {
|
|
58
|
-
consoleId:
|
|
58
|
+
consoleId: ID;
|
|
59
59
|
shouldOnlyRetrieveGamesWithAchievements?: boolean;
|
|
60
60
|
shouldRetrieveGameHashes?: boolean;
|
|
61
61
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ID } from "../utils/internal";
|
|
1
2
|
import {
|
|
2
3
|
apiBaseUrl,
|
|
3
4
|
buildRequestUrl,
|
|
@@ -51,7 +52,7 @@ interface GetTicketDataAllPayloadValues {
|
|
|
51
52
|
*/
|
|
52
53
|
export function getTicketData(
|
|
53
54
|
authorization: AuthObject,
|
|
54
|
-
payload: { ticketId:
|
|
55
|
+
payload: { ticketId: ID }
|
|
55
56
|
): Promise<TicketEntity>;
|
|
56
57
|
|
|
57
58
|
/**
|
|
@@ -161,7 +162,7 @@ export function getTicketData(
|
|
|
161
162
|
export function getTicketData(
|
|
162
163
|
authorization: AuthObject,
|
|
163
164
|
payload: {
|
|
164
|
-
gameId:
|
|
165
|
+
gameId: ID;
|
|
165
166
|
isGettingTicketsForUnofficialAchievements?: true;
|
|
166
167
|
shouldReturnTicketsList?: true;
|
|
167
168
|
}
|
|
@@ -191,7 +192,7 @@ export function getTicketData(
|
|
|
191
192
|
*/
|
|
192
193
|
export function getTicketData(
|
|
193
194
|
authorization: AuthObject,
|
|
194
|
-
payload: { achievementId:
|
|
195
|
+
payload: { achievementId: ID }
|
|
195
196
|
): Promise<AchievementTicketStats>;
|
|
196
197
|
|
|
197
198
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ID } from "../utils/internal";
|
|
1
2
|
import {
|
|
2
3
|
apiBaseUrl,
|
|
3
4
|
buildRequestUrl,
|
|
@@ -35,7 +36,7 @@ import type { AchievementCount, GetAchievementCountResponse } from "./models";
|
|
|
35
36
|
*/
|
|
36
37
|
export const getAchievementCount = async (
|
|
37
38
|
authorization: AuthObject,
|
|
38
|
-
payload: { gameId:
|
|
39
|
+
payload: { gameId: ID }
|
|
39
40
|
): Promise<AchievementCount> => {
|
|
40
41
|
const { gameId } = payload;
|
|
41
42
|
|
|
@@ -4,10 +4,8 @@ import { setupServer } from "msw/node";
|
|
|
4
4
|
import { apiBaseUrl } from "../utils/internal";
|
|
5
5
|
import { buildAuthorization } from "../utils/public";
|
|
6
6
|
import { getAchievementDistribution } from "./getAchievementDistribution";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
AchievementDistributionFlags
|
|
10
|
-
} from "./models";
|
|
7
|
+
import type { GetAchievementDistributionResponse } from "./models";
|
|
8
|
+
import { AchievementDistributionFlags } from "./models";
|
|
11
9
|
|
|
12
10
|
const server = setupServer();
|
|
13
11
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ID } from "../utils/internal";
|
|
1
2
|
import { apiBaseUrl, buildRequestUrl, call } from "../utils/internal";
|
|
2
3
|
import type { AuthObject } from "../utils/public";
|
|
3
4
|
import type {
|
|
@@ -58,7 +59,7 @@ import type {
|
|
|
58
59
|
export const getAchievementDistribution = async (
|
|
59
60
|
authorization: AuthObject,
|
|
60
61
|
payload: {
|
|
61
|
-
gameId:
|
|
62
|
+
gameId: ID;
|
|
62
63
|
flags?: AchievementDistributionFlags;
|
|
63
64
|
hardcore?: boolean;
|
|
64
65
|
}
|
package/src/game/getGame.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ID } from "../utils/internal";
|
|
1
2
|
import {
|
|
2
3
|
apiBaseUrl,
|
|
3
4
|
buildRequestUrl,
|
|
@@ -52,7 +53,7 @@ import type { Game, GetGameResponse } from "./models";
|
|
|
52
53
|
*/
|
|
53
54
|
export const getGame = async (
|
|
54
55
|
authorization: AuthObject,
|
|
55
|
-
payload: { gameId:
|
|
56
|
+
payload: { gameId: ID }
|
|
56
57
|
): Promise<Game> => {
|
|
57
58
|
const { gameId } = payload;
|
|
58
59
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ID } from "../utils/internal";
|
|
1
2
|
import {
|
|
2
3
|
apiBaseUrl,
|
|
3
4
|
buildRequestUrl,
|
|
@@ -72,7 +73,7 @@ import type { GameExtended, GetGameExtendedResponse } from "./models";
|
|
|
72
73
|
*/
|
|
73
74
|
export const getGameExtended = async (
|
|
74
75
|
authorization: AuthObject,
|
|
75
|
-
payload: { gameId:
|
|
76
|
+
payload: { gameId: ID }
|
|
76
77
|
): Promise<GameExtended> => {
|
|
77
78
|
const { gameId } = payload;
|
|
78
79
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ID } from "../utils/internal";
|
|
1
2
|
import {
|
|
2
3
|
apiBaseUrl,
|
|
3
4
|
buildRequestUrl,
|
|
@@ -44,7 +45,7 @@ import type {
|
|
|
44
45
|
*/
|
|
45
46
|
export const getGameRankAndScore = async (
|
|
46
47
|
authorization: AuthObject,
|
|
47
|
-
payload: { gameId:
|
|
48
|
+
payload: { gameId: ID; type: "latest-masters" | "high-scores" }
|
|
48
49
|
): Promise<GameRankAndScoreEntity[]> => {
|
|
49
50
|
const { gameId, type } = payload;
|
|
50
51
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ID } from "../utils/internal";
|
|
1
2
|
import {
|
|
2
3
|
apiBaseUrl,
|
|
3
4
|
buildRequestUrl,
|
|
@@ -42,7 +43,7 @@ import type { GameRating, GetGameRatingResponse } from "./models";
|
|
|
42
43
|
*/
|
|
43
44
|
export const getGameRating = async (
|
|
44
45
|
authorization: AuthObject,
|
|
45
|
-
payload: { gameId:
|
|
46
|
+
payload: { gameId: ID }
|
|
46
47
|
): Promise<GameRating> => {
|
|
47
48
|
const { gameId } = payload;
|
|
48
49
|
|
|
@@ -41,25 +41,25 @@ import type {
|
|
|
41
41
|
* @returns An array containing metadata about the user
|
|
42
42
|
* achievements earned during the specified date range.
|
|
43
43
|
* ```
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
44
|
+
* [
|
|
45
|
+
* {
|
|
46
|
+
* date: '2022-10-12 07:58:05',
|
|
47
|
+
* hardcoreMode: true,
|
|
48
|
+
* achievementId: 173315,
|
|
49
|
+
* title: 'Your Puny Human Weapons',
|
|
50
|
+
* description: 'Collect all objects in the Weapons Category.',
|
|
51
|
+
* badgeName: '193756',
|
|
52
|
+
* points: 10,
|
|
53
|
+
* author: 'blendedsea',
|
|
54
|
+
* gameTitle: 'Me & My Katamari',
|
|
55
|
+
* gameIcon: '/Images/047357.png',
|
|
56
|
+
* gameId: 3571,
|
|
57
|
+
* consoleName: 'PlayStation Portable',
|
|
58
|
+
* cumulScore: 120,
|
|
59
|
+
* badgeUrl: '/Badge/193756.png',
|
|
60
|
+
* gameUrl: '/game/3571'
|
|
61
|
+
* }
|
|
62
|
+
* ]
|
|
63
63
|
* ```
|
|
64
64
|
*/
|
|
65
65
|
export const getAchievementsEarnedBetween = async (
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ID } from "../utils/internal";
|
|
1
2
|
import {
|
|
2
3
|
apiBaseUrl,
|
|
3
4
|
buildRequestUrl,
|
|
@@ -86,7 +87,7 @@ import type {
|
|
|
86
87
|
*/
|
|
87
88
|
export const getGameInfoAndUserProgress = async (
|
|
88
89
|
authorization: AuthObject,
|
|
89
|
-
payload: { gameId:
|
|
90
|
+
payload: { gameId: ID; userName: string }
|
|
90
91
|
): Promise<GameInfoAndUserProgress> => {
|
|
91
92
|
const { gameId, userName } = payload;
|
|
92
93
|
|
|
@@ -15,7 +15,7 @@ import type {
|
|
|
15
15
|
* about the games a given user has played. It returns two
|
|
16
16
|
* entries per each game: one for the softcore completion and
|
|
17
17
|
* one for the hardcore completion. These are designated by
|
|
18
|
-
* the `hardcoreMode` property on
|
|
18
|
+
* the `hardcoreMode` property on each completion object.
|
|
19
19
|
*
|
|
20
20
|
* @param authorization An object containing your userName and webApiKey.
|
|
21
21
|
* This can be constructed with `buildAuthorization()`.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ID } from "../utils/internal";
|
|
1
2
|
import {
|
|
2
3
|
apiBaseUrl,
|
|
3
4
|
buildRequestUrl,
|
|
@@ -50,7 +51,7 @@ import type {
|
|
|
50
51
|
*/
|
|
51
52
|
export const getUserGameRankAndScore = async (
|
|
52
53
|
authorization: AuthObject,
|
|
53
|
-
payload: { gameId:
|
|
54
|
+
payload: { gameId: ID; userName: string }
|
|
54
55
|
): Promise<UserGameRankAndScore> => {
|
|
55
56
|
const { gameId, userName } = payload;
|
|
56
57
|
|
|
@@ -14,7 +14,7 @@ import type { GetUserPointsResponse, UserPoints } from "./models";
|
|
|
14
14
|
* @param authorization An object containing your userName and webApiKey.
|
|
15
15
|
* This can be constructed with `buildAuthorization()`.
|
|
16
16
|
*
|
|
17
|
-
* @param payload.userName The user for which to retrieve the
|
|
17
|
+
* @param payload.userName The user for which to retrieve the point totals for.
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* ```
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ID } from "../utils/internal";
|
|
1
2
|
import {
|
|
2
3
|
apiBaseUrl,
|
|
3
4
|
buildRequestUrl,
|
|
@@ -9,14 +10,14 @@ import type { GetUserProgressResponse, UserProgress } from "./models";
|
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* A call to this function will retrieve a given user's
|
|
12
|
-
* progress on a given
|
|
13
|
+
* progress on a given list of games, targeted by game ID.
|
|
13
14
|
*
|
|
14
15
|
* @param authorization An object containing your userName and webApiKey.
|
|
15
16
|
* This can be constructed with `buildAuthorization()`.
|
|
16
17
|
*
|
|
17
18
|
* @param payload.userName The user for which to retrieve the progress for.
|
|
18
19
|
*
|
|
19
|
-
* @param payload.gameIds An array of RetroAchievements
|
|
20
|
+
* @param payload.gameIds An array of RetroAchievements game IDs. If you aren't
|
|
20
21
|
* sure of the game ID, visit the game's page on the website and copy the number
|
|
21
22
|
* at the end of the URL.
|
|
22
23
|
*
|
|
@@ -24,7 +25,7 @@ import type { GetUserProgressResponse, UserProgress } from "./models";
|
|
|
24
25
|
* ```
|
|
25
26
|
* const userProgress = await getUserProgress(
|
|
26
27
|
* authorization,
|
|
27
|
-
* { userName: "xelnia", gameIds: [
|
|
28
|
+
* { userName: "xelnia", gameIds: [1, 14402] }
|
|
28
29
|
* );
|
|
29
30
|
* ```
|
|
30
31
|
*
|
|
@@ -52,7 +53,7 @@ import type { GetUserProgressResponse, UserProgress } from "./models";
|
|
|
52
53
|
*/
|
|
53
54
|
export const getUserProgress = async (
|
|
54
55
|
authorization: AuthObject,
|
|
55
|
-
payload: { userName: string; gameIds:
|
|
56
|
+
payload: { userName: string; gameIds: ID[] }
|
|
56
57
|
): Promise<UserProgress> => {
|
|
57
58
|
const { userName, gameIds } = payload;
|
|
58
59
|
|
|
@@ -39,7 +39,8 @@ describe("Function: getUserRecentlyPlayedGames", () => {
|
|
|
39
39
|
NumAchieved: 0,
|
|
40
40
|
ScoreAchieved: 0,
|
|
41
41
|
NumAchievedHardcore: 0,
|
|
42
|
-
ScoreAchievedHardcore: 0
|
|
42
|
+
ScoreAchievedHardcore: 0,
|
|
43
|
+
MyVote: "2"
|
|
43
44
|
}
|
|
44
45
|
];
|
|
45
46
|
|
|
@@ -69,7 +70,8 @@ describe("Function: getUserRecentlyPlayedGames", () => {
|
|
|
69
70
|
numAchieved: 0,
|
|
70
71
|
scoreAchieved: 0,
|
|
71
72
|
numAchievedHardcore: 0,
|
|
72
|
-
scoreAchievedHardcore: 0
|
|
73
|
+
scoreAchievedHardcore: 0,
|
|
74
|
+
myVote: 2
|
|
73
75
|
}
|
|
74
76
|
]);
|
|
75
77
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
interface UserRecentlyPlayedGameEntity {
|
|
1
|
+
export interface UserRecentlyPlayedGameEntity {
|
|
2
2
|
gameId: number;
|
|
3
3
|
consoleId: number;
|
|
4
4
|
consoleName: string;
|
|
5
5
|
title: string;
|
|
6
6
|
imageIcon: string;
|
|
7
7
|
lastPlayed: string;
|
|
8
|
+
myVote: 1 | 2 | 3 | 4 | 5 | null;
|
|
8
9
|
numPossibleAchievements: number;
|
|
9
10
|
possibleScore: number;
|
|
10
11
|
numAchieved: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface RecentlyPlayedGameEntity {
|
|
1
|
+
export interface RecentlyPlayedGameEntity {
|
|
2
2
|
gameId: number;
|
|
3
3
|
consoleId: number;
|
|
4
4
|
consoleName: string;
|
|
@@ -7,7 +7,7 @@ interface RecentlyPlayedGameEntity {
|
|
|
7
7
|
lastPlayed: string;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
interface LastActivityEntity {
|
|
10
|
+
export interface LastActivityEntity {
|
|
11
11
|
id: number;
|
|
12
12
|
timestamp: string;
|
|
13
13
|
lastupdate: string;
|
|
@@ -17,7 +17,7 @@ interface LastActivityEntity {
|
|
|
17
17
|
data2: string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
interface LastGameEntity {
|
|
20
|
+
export interface LastGameEntity {
|
|
21
21
|
id: number;
|
|
22
22
|
title: string;
|
|
23
23
|
consoleId: number;
|
|
@@ -36,7 +36,7 @@ interface LastGameEntity {
|
|
|
36
36
|
richPresencePatch: string;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
interface AwardedGameEntity {
|
|
39
|
+
export interface AwardedGameEntity {
|
|
40
40
|
numPossibleAchievements: number;
|
|
41
41
|
possibleScore: number;
|
|
42
42
|
numAchieved: number;
|
|
@@ -45,7 +45,7 @@ interface AwardedGameEntity {
|
|
|
45
45
|
scoreAchievedHardcore: number;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
interface ExtendedRecentAchievementEntity {
|
|
48
|
+
export interface ExtendedRecentAchievementEntity {
|
|
49
49
|
id: number;
|
|
50
50
|
gameId: number;
|
|
51
51
|
gameTitle: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ID = string | number;
|
|
@@ -26,7 +26,7 @@ export const serializeProperties = (
|
|
|
26
26
|
for (const [originalKey, originalValue] of Object.entries(originalData)) {
|
|
27
27
|
let sanitizedValue = originalValue;
|
|
28
28
|
if (shouldCastToNumbers?.includes(originalKey)) {
|
|
29
|
-
sanitizedValue = Number(originalValue);
|
|
29
|
+
sanitizedValue = originalValue === null ? null : Number(originalValue);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
if (shouldMapToBooleans?.includes(originalKey)) {
|