@retroachievements/api 1.5.3 → 2.1.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 +3 -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/getRecentGameAwards.d.ts +50 -0
- package/dist/feed/getRecentGameAwards.test.d.ts +1 -0
- package/dist/feed/getTopTenUsers.d.ts +3 -3
- package/dist/feed/index.d.ts +1 -0
- package/dist/feed/models/get-recent-game-awards-response.model.d.ts +14 -0
- package/dist/feed/models/index.d.ts +2 -0
- package/dist/feed/models/recent-game-awards.model.d.ts +14 -0
- 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 +3 -0
- package/dist/user/models/get-game-info-and-user-progress-response.model.d.ts +3 -0
- package/dist/user/models/get-user-completion-progress-response.model.d.ts +2 -1
- package/dist/user/models/user-completion-progress-entity.model.d.ts +2 -1
- package/dist/utils/public/buildAuthorization.d.ts +1 -1
- package/dist/utils/public/models/auth-object.model.d.ts +2 -2
- package/dist/utils/public/models/award-kind.model.d.ts +1 -0
- package/dist/utils/public/models/index.d.ts +1 -0
- 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/getRecentGameAwards.test.ts +73 -0
- package/src/feed/getRecentGameAwards.ts +85 -0
- package/src/feed/getTopTenUsers.test.ts +11 -11
- package/src/feed/getTopTenUsers.ts +4 -4
- package/src/feed/index.ts +1 -0
- package/src/feed/models/get-recent-game-awards-response.model.ts +15 -0
- package/src/feed/models/index.ts +2 -0
- package/src/feed/models/recent-game-awards.model.ts +15 -0
- 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 +4 -0
- package/src/user/models/get-game-info-and-user-progress-response.model.ts +4 -0
- package/src/user/models/get-user-completion-progress-response.model.ts +3 -6
- package/src/user/models/user-completion-progress-entity.model.ts +3 -6
- 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/utils/public/models/award-kind.model.ts +5 -0
- package/src/utils/public/models/index.ts +1 -0
- package/src/console/models/console-id.model.ts +0 -5
|
@@ -10,7 +10,7 @@ import type {
|
|
|
10
10
|
* A call to this function will retrieve the current top ten users
|
|
11
11
|
* on the site.
|
|
12
12
|
*
|
|
13
|
-
* @param authorization An object containing your
|
|
13
|
+
* @param authorization An object containing your username and webApiKey.
|
|
14
14
|
* This can be constructed with `buildAuthorization()`.
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
@@ -21,8 +21,8 @@ import type {
|
|
|
21
21
|
* @returns An array containing the list of top ten users.
|
|
22
22
|
* ```json
|
|
23
23
|
* [
|
|
24
|
-
* {
|
|
25
|
-
* {
|
|
24
|
+
* { username: "MockUser", totalPoints: 350000, totalRatioPoints: 995000 },
|
|
25
|
+
* { username: "MockUser2", totalPoints: 345000, totalRatioPoints: 994000 },
|
|
26
26
|
* // ...
|
|
27
27
|
* ]
|
|
28
28
|
* ```
|
|
@@ -41,7 +41,7 @@ export const getTopTenUsers = async (
|
|
|
41
41
|
const sanitizedTopTenUsers: TopTenUsersEntity[] = [];
|
|
42
42
|
for (const rawUser of rawTopTenUsers) {
|
|
43
43
|
sanitizedTopTenUsers.push({
|
|
44
|
-
|
|
44
|
+
username: rawUser["1"],
|
|
45
45
|
totalPoints: Number(rawUser["2"]),
|
|
46
46
|
totalRatioPoints: Number(rawUser["3"]),
|
|
47
47
|
});
|
package/src/feed/index.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AwardKind } from "../../utils/public";
|
|
2
|
+
|
|
3
|
+
export interface GetRecentGameAwardsResponse {
|
|
4
|
+
Count: number;
|
|
5
|
+
Total: number;
|
|
6
|
+
Results: Array<{
|
|
7
|
+
User: string;
|
|
8
|
+
AwardKind: AwardKind;
|
|
9
|
+
AwardDate: string;
|
|
10
|
+
GameID: number;
|
|
11
|
+
GameTitle: string;
|
|
12
|
+
ConsoleID: number;
|
|
13
|
+
ConsoleName: string;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
package/src/feed/models/index.ts
CHANGED
|
@@ -3,8 +3,10 @@ export * from "./claim-set-type.enum";
|
|
|
3
3
|
export * from "./claim-status.enum";
|
|
4
4
|
export * from "./claim-type.enum";
|
|
5
5
|
export * from "./get-achievement-of-the-week-response.model";
|
|
6
|
+
export * from "./get-recent-game-awards-response.model";
|
|
6
7
|
export * from "./get-set-claims-response.model";
|
|
7
8
|
export * from "./get-top-ten-users-response.model";
|
|
9
|
+
export * from "./recent-game-awards.model";
|
|
8
10
|
export * from "./set-claim.model";
|
|
9
11
|
export * from "./top-ten-users.model";
|
|
10
12
|
export * from "./top-ten-users-entity.model";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AwardKind } from "../../utils/public";
|
|
2
|
+
|
|
3
|
+
export interface RecentGameAwards {
|
|
4
|
+
count: number;
|
|
5
|
+
total: number;
|
|
6
|
+
results: Array<{
|
|
7
|
+
user: string;
|
|
8
|
+
awardKind: AwardKind;
|
|
9
|
+
awardDate: string;
|
|
10
|
+
gameId: number;
|
|
11
|
+
gameTitle: string;
|
|
12
|
+
consoleId: number;
|
|
13
|
+
consoleName: string;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
@@ -22,7 +22,7 @@ describe("Function: getAchievementCount", () => {
|
|
|
22
22
|
it("given a game ID, retrieves the list of achievement IDs associated with the game and cleans properties", async () => {
|
|
23
23
|
// ARRANGE
|
|
24
24
|
const authorization = buildAuthorization({
|
|
25
|
-
|
|
25
|
+
username: "mockUserName",
|
|
26
26
|
webApiKey: "mockWebApiKey",
|
|
27
27
|
});
|
|
28
28
|
|
|
@@ -12,7 +12,7 @@ import type { AchievementCount, GetAchievementCountResponse } from "./models";
|
|
|
12
12
|
* A call to this function will retrieve the list of
|
|
13
13
|
* achievement IDs for a game, 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
18
|
* @param payload.gameId The unique game ID. If you are unsure, open the
|
|
@@ -23,7 +23,7 @@ describe("Function: getAchievementDistribution", () => {
|
|
|
23
23
|
it("given a game ID, retrieves the achievement distribution associated with the game", async () => {
|
|
24
24
|
// ARRANGE
|
|
25
25
|
const authorization = buildAuthorization({
|
|
26
|
-
|
|
26
|
+
username: "mockUserName",
|
|
27
27
|
webApiKey: "mockWebApiKey",
|
|
28
28
|
});
|
|
29
29
|
|
|
@@ -61,7 +61,7 @@ describe("Function: getAchievementDistribution", () => {
|
|
|
61
61
|
it("given flags, successfully attaches the option to the call", async () => {
|
|
62
62
|
// ARRANGE
|
|
63
63
|
const authorization = buildAuthorization({
|
|
64
|
-
|
|
64
|
+
username: "mockUserName",
|
|
65
65
|
webApiKey: "mockWebApiKey",
|
|
66
66
|
});
|
|
67
67
|
|
|
@@ -101,7 +101,7 @@ describe("Function: getAchievementDistribution", () => {
|
|
|
101
101
|
it("given a truthy hardcore value, successfully attaches the option to the call", async () => {
|
|
102
102
|
// ARRANGE
|
|
103
103
|
const authorization = buildAuthorization({
|
|
104
|
-
|
|
104
|
+
username: "mockUserName",
|
|
105
105
|
webApiKey: "mockWebApiKey",
|
|
106
106
|
});
|
|
107
107
|
|
|
@@ -138,7 +138,7 @@ describe("Function: getAchievementDistribution", () => {
|
|
|
138
138
|
it("given a falsy hardcore value, successfully attaches the option to the call", async () => {
|
|
139
139
|
// ARRANGE
|
|
140
140
|
const authorization = buildAuthorization({
|
|
141
|
-
|
|
141
|
+
username: "mockUserName",
|
|
142
142
|
webApiKey: "mockWebApiKey",
|
|
143
143
|
});
|
|
144
144
|
|
|
@@ -11,7 +11,7 @@ import type {
|
|
|
11
11
|
* of the number of players who have earned a specific
|
|
12
12
|
* number of achievements for a given game ID.
|
|
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
17
|
* @param payload.gameId The unique game ID. If you are unsure, open the
|
package/src/game/getGame.test.ts
CHANGED
|
@@ -24,7 +24,7 @@ describe("Function: getGame", () => {
|
|
|
24
24
|
it("given a game ID, retrieves basic metadata about the game", async () => {
|
|
25
25
|
// ARRANGE
|
|
26
26
|
const authorization = buildAuthorization({
|
|
27
|
-
|
|
27
|
+
username: "mockUserName",
|
|
28
28
|
webApiKey: "mockWebApiKey",
|
|
29
29
|
});
|
|
30
30
|
|
package/src/game/getGame.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type { Game, GetGameResponse } from "./models";
|
|
|
12
12
|
* A call to this function will retrieve basic metadata about
|
|
13
13
|
* a game, targeted via its unique 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
18
|
* @param payload.gameId The unique game ID. If you are unsure, open the
|
|
@@ -24,7 +24,7 @@ describe("Function: getGameExtended", () => {
|
|
|
24
24
|
it("given a game ID, retrieves extended metadata about the game", async () => {
|
|
25
25
|
// ARRANGE
|
|
26
26
|
const authorization = buildAuthorization({
|
|
27
|
-
|
|
27
|
+
username: "mockUserName",
|
|
28
28
|
webApiKey: "mockWebApiKey",
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -12,7 +12,7 @@ import type { GameExtended, GetGameExtendedResponse } from "./models";
|
|
|
12
12
|
* A call to this function will retrieve extended metadata
|
|
13
13
|
* about a game, targeted via its unique 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
18
|
* @param payload.gameId The unique game ID. If you are unsure, open the
|
|
@@ -24,7 +24,7 @@ describe("Function: getGameRankAndScore", () => {
|
|
|
24
24
|
it("given a game ID, retrieves metadata about latest masteries for a game", async () => {
|
|
25
25
|
// ARRANGE
|
|
26
26
|
const authorization = buildAuthorization({
|
|
27
|
-
|
|
27
|
+
username: "mockUserName",
|
|
28
28
|
webApiKey: "mockWebApiKey",
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -17,7 +17,7 @@ import type {
|
|
|
17
17
|
* points earners for a game. The game is targeted via
|
|
18
18
|
* its unique ID.
|
|
19
19
|
*
|
|
20
|
-
* @param authorization An object containing your
|
|
20
|
+
* @param authorization An object containing your username and webApiKey.
|
|
21
21
|
* This can be constructed with `buildAuthorization()`.
|
|
22
22
|
*
|
|
23
23
|
* @param payload.gameId The unique game ID. If you are unsure, open the
|
|
@@ -22,7 +22,7 @@ describe("Function: getGameRating", () => {
|
|
|
22
22
|
it("given a game ID, retrieves metadata about how users have rated it", async () => {
|
|
23
23
|
// ARRANGE
|
|
24
24
|
const authorization = buildAuthorization({
|
|
25
|
-
|
|
25
|
+
username: "mockUserName",
|
|
26
26
|
webApiKey: "mockWebApiKey",
|
|
27
27
|
});
|
|
28
28
|
|
|
@@ -12,7 +12,7 @@ import type { GameRating, GetGameRatingResponse } from "./models";
|
|
|
12
12
|
* A call to this function will retrieve metadata about
|
|
13
13
|
* how users have rated the game and its set.
|
|
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
18
|
* @param payload.gameId The unique game ID. If you are unsure, open the
|
|
@@ -28,7 +28,7 @@ describe("Function: getTicketData", () => {
|
|
|
28
28
|
it("given only a ticket ID, retrieves ticket data", async () => {
|
|
29
29
|
// ARRANGE
|
|
30
30
|
const authorization = buildAuthorization({
|
|
31
|
-
|
|
31
|
+
username: "mockUserName",
|
|
32
32
|
webApiKey: "mockWebApiKey",
|
|
33
33
|
});
|
|
34
34
|
|
|
@@ -96,7 +96,7 @@ describe("Function: getTicketData", () => {
|
|
|
96
96
|
it("given no IDs, retrieves a list of recent tickets", async () => {
|
|
97
97
|
// ARRANGE
|
|
98
98
|
const authorization = buildAuthorization({
|
|
99
|
-
|
|
99
|
+
username: "mockUserName",
|
|
100
100
|
webApiKey: "mockWebApiKey",
|
|
101
101
|
});
|
|
102
102
|
|
|
@@ -184,7 +184,7 @@ describe("Function: getTicketData", () => {
|
|
|
184
184
|
it("can retrieve a list of the most ticketed games", async () => {
|
|
185
185
|
// ARRANGE
|
|
186
186
|
const authorization = buildAuthorization({
|
|
187
|
-
|
|
187
|
+
username: "mockUserName",
|
|
188
188
|
webApiKey: "mockWebApiKey",
|
|
189
189
|
});
|
|
190
190
|
|
|
@@ -244,7 +244,7 @@ describe("Function: getTicketData", () => {
|
|
|
244
244
|
it("can retrieve metadata about a user's tickets", async () => {
|
|
245
245
|
// ARRANGE
|
|
246
246
|
const authorization = buildAuthorization({
|
|
247
|
-
|
|
247
|
+
username: "mockUserName",
|
|
248
248
|
webApiKey: "mockWebApiKey",
|
|
249
249
|
});
|
|
250
250
|
|
|
@@ -264,7 +264,7 @@ describe("Function: getTicketData", () => {
|
|
|
264
264
|
);
|
|
265
265
|
|
|
266
266
|
// ACT
|
|
267
|
-
const response = await getTicketData(authorization, {
|
|
267
|
+
const response = await getTicketData(authorization, { username: "xelnia" });
|
|
268
268
|
|
|
269
269
|
// ASSERT
|
|
270
270
|
expect(response).toEqual({
|
|
@@ -280,7 +280,7 @@ describe("Function: getTicketData", () => {
|
|
|
280
280
|
it("can retrieve metadata about a game's tickets", async () => {
|
|
281
281
|
// ARRANGE
|
|
282
282
|
const authorization = buildAuthorization({
|
|
283
|
-
|
|
283
|
+
username: "mockUserName",
|
|
284
284
|
webApiKey: "mockWebApiKey",
|
|
285
285
|
});
|
|
286
286
|
|
|
@@ -314,7 +314,7 @@ describe("Function: getTicketData", () => {
|
|
|
314
314
|
it("can retrieve metadata about an achievement's tickets", async () => {
|
|
315
315
|
// ARRANGE
|
|
316
316
|
const authorization = buildAuthorization({
|
|
317
|
-
|
|
317
|
+
username: "mockUserName",
|
|
318
318
|
webApiKey: "mockWebApiKey",
|
|
319
319
|
});
|
|
320
320
|
|
|
@@ -20,7 +20,7 @@ interface GetTicketDataAllPayloadValues {
|
|
|
20
20
|
offset?: number;
|
|
21
21
|
count?: number;
|
|
22
22
|
isGettingMostTicketedGames?: true;
|
|
23
|
-
|
|
23
|
+
username?: string;
|
|
24
24
|
gameId?: string | number;
|
|
25
25
|
isGettingTicketsForUnofficialAchievements?: true;
|
|
26
26
|
shouldReturnTicketsList?: true;
|
|
@@ -35,7 +35,7 @@ interface GetTicketDataAllPayloadValues {
|
|
|
35
35
|
* A call to this function will retrieve ticket metadata information
|
|
36
36
|
* about a single achievement ticket, targeted by its ticket ID.
|
|
37
37
|
*
|
|
38
|
-
* @param authorization An object containing your
|
|
38
|
+
* @param authorization An object containing your username and webApiKey.
|
|
39
39
|
* This can be constructed with `buildAuthorization()`.
|
|
40
40
|
*
|
|
41
41
|
* @param payload.ticketId The ID of the ticket to get information about.
|
|
@@ -59,7 +59,7 @@ export function getTicketData(
|
|
|
59
59
|
* A call to this function will retrieve ticket metadata information
|
|
60
60
|
* about the latest opened achievement tickets on RetroAchievements.
|
|
61
61
|
*
|
|
62
|
-
* @param authorization An object containing your
|
|
62
|
+
* @param authorization An object containing your username and webApiKey.
|
|
63
63
|
* This can be constructed with `buildAuthorization()`.
|
|
64
64
|
*
|
|
65
65
|
* @param payload.count Optional. Defaults to 10. Max is 100.
|
|
@@ -84,7 +84,7 @@ export function getTicketData(
|
|
|
84
84
|
* A call to this function will retrieve the games on the site with
|
|
85
85
|
* the highest count of opened achievement tickets.
|
|
86
86
|
*
|
|
87
|
-
* @param authorization An object containing your
|
|
87
|
+
* @param authorization An object containing your username and webApiKey.
|
|
88
88
|
* This can be constructed with `buildAuthorization()`.
|
|
89
89
|
*
|
|
90
90
|
* @param payload.count Optional. Defaults to 10. Max is 100.
|
|
@@ -112,17 +112,17 @@ export function getTicketData(
|
|
|
112
112
|
* A call to this function will retrieve an achievement developer's
|
|
113
113
|
* ticket stats, targeted by that developer's username.
|
|
114
114
|
*
|
|
115
|
-
* @param authorization An object containing your
|
|
115
|
+
* @param authorization An object containing your username and webApiKey.
|
|
116
116
|
* This can be constructed with `buildAuthorization()`.
|
|
117
117
|
*
|
|
118
|
-
* @param payload.
|
|
118
|
+
* @param payload.username The developer's account username to retrieve
|
|
119
119
|
* ticket stats for.
|
|
120
120
|
*
|
|
121
121
|
* @example
|
|
122
122
|
* ```
|
|
123
123
|
* const ticketData = await getTicketData(
|
|
124
124
|
* authorization,
|
|
125
|
-
* {
|
|
125
|
+
* { username: "xelnia" }
|
|
126
126
|
* );
|
|
127
127
|
* ```
|
|
128
128
|
*
|
|
@@ -130,7 +130,7 @@ export function getTicketData(
|
|
|
130
130
|
*/
|
|
131
131
|
export function getTicketData(
|
|
132
132
|
authorization: AuthObject,
|
|
133
|
-
payload: {
|
|
133
|
+
payload: { username: string }
|
|
134
134
|
): Promise<UserTicketStats>;
|
|
135
135
|
|
|
136
136
|
/**
|
|
@@ -138,7 +138,7 @@ export function getTicketData(
|
|
|
138
138
|
* by the game's ID. If you are unsure of a game's ID, visit its page
|
|
139
139
|
* on the RetroAchievements website and copy the number at the end of the URL.
|
|
140
140
|
*
|
|
141
|
-
* @param authorization An object containing your
|
|
141
|
+
* @param authorization An object containing your username and webApiKey.
|
|
142
142
|
* This can be constructed with `buildAuthorization()`.
|
|
143
143
|
*
|
|
144
144
|
* @param payload.gameId The game ID to fetch ticket stats for.
|
|
@@ -174,7 +174,7 @@ export function getTicketData(
|
|
|
174
174
|
* of an achievement's ID, open its page on the RetroAchievements
|
|
175
175
|
* website and copy the number at the end of the URL.
|
|
176
176
|
*
|
|
177
|
-
* @param authorization An object containing your
|
|
177
|
+
* @param authorization An object containing your username and webApiKey.
|
|
178
178
|
* This can be constructed with `buildAuthorization()`.
|
|
179
179
|
*
|
|
180
180
|
* @param payload.achievementId The ID of the achievement to fetch ticket
|
|
@@ -234,7 +234,7 @@ const buildGetTicketDataQueryParams = (
|
|
|
234
234
|
const {
|
|
235
235
|
ticketId,
|
|
236
236
|
isGettingMostTicketedGames,
|
|
237
|
-
|
|
237
|
+
username,
|
|
238
238
|
gameId,
|
|
239
239
|
isGettingTicketsForUnofficialAchievements,
|
|
240
240
|
shouldReturnTicketsList,
|
|
@@ -248,8 +248,8 @@ const buildGetTicketDataQueryParams = (
|
|
|
248
248
|
} else if (isGettingMostTicketedGames) {
|
|
249
249
|
queryParams["f"] = "1";
|
|
250
250
|
queryParams = applyPaginationQueryParams(queryParams, payload);
|
|
251
|
-
} else if (
|
|
252
|
-
queryParams["u"] =
|
|
251
|
+
} else if (username) {
|
|
252
|
+
queryParams["u"] = username;
|
|
253
253
|
} else if (gameId) {
|
|
254
254
|
queryParams["g"] = gameId;
|
|
255
255
|
|
|
@@ -25,7 +25,7 @@ describe("Function: getAchievementsEarnedBetween", () => {
|
|
|
25
25
|
it("retrieves a list of user achievements earned between a set of dates", async () => {
|
|
26
26
|
// ARRANGE
|
|
27
27
|
const authorization = buildAuthorization({
|
|
28
|
-
|
|
28
|
+
username: "mockUserName",
|
|
29
29
|
webApiKey: "mockWebApiKey",
|
|
30
30
|
});
|
|
31
31
|
|
|
@@ -58,7 +58,7 @@ describe("Function: getAchievementsEarnedBetween", () => {
|
|
|
58
58
|
|
|
59
59
|
// ACT
|
|
60
60
|
const response = await getAchievementsEarnedBetween(authorization, {
|
|
61
|
-
|
|
61
|
+
username: "xelnia",
|
|
62
62
|
fromDate: new Date("2022-10-12"),
|
|
63
63
|
toDate: new Date("2022-10-13"),
|
|
64
64
|
});
|
|
@@ -14,10 +14,10 @@ import type {
|
|
|
14
14
|
* A call to this function will retrieve a list of achievements
|
|
15
15
|
* earned by a given user between two provided dates.
|
|
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
|
|
21
21
|
* list of achievements for.
|
|
22
22
|
*
|
|
23
23
|
* @param payload.fromDate A Date object specifying when
|
|
@@ -31,7 +31,7 @@ import type {
|
|
|
31
31
|
* const achievementsEarnedBetween = await getAchievementsEarnedBetween(
|
|
32
32
|
* authorization,
|
|
33
33
|
* {
|
|
34
|
-
*
|
|
34
|
+
* username: "xelnia",
|
|
35
35
|
* fromDate: new Date("2022-10-12"),
|
|
36
36
|
* toDate: new Date("2022-10-13")
|
|
37
37
|
* }
|
|
@@ -65,16 +65,16 @@ import type {
|
|
|
65
65
|
*/
|
|
66
66
|
export const getAchievementsEarnedBetween = async (
|
|
67
67
|
authorization: AuthObject,
|
|
68
|
-
payload: {
|
|
68
|
+
payload: { username: string; fromDate: Date; toDate: Date }
|
|
69
69
|
): Promise<DatedUserAchievement[]> => {
|
|
70
|
-
const {
|
|
70
|
+
const { username, fromDate, toDate } = payload;
|
|
71
71
|
|
|
72
72
|
const url = buildRequestUrl(
|
|
73
73
|
apiBaseUrl,
|
|
74
74
|
"/API_GetAchievementsEarnedBetween.php",
|
|
75
75
|
authorization,
|
|
76
76
|
{
|
|
77
|
-
u:
|
|
77
|
+
u: username,
|
|
78
78
|
f: (fromDate.getTime() / 1000).toFixed(0),
|
|
79
79
|
t: (toDate.getTime() / 1000).toFixed(0),
|
|
80
80
|
}
|
|
@@ -25,7 +25,7 @@ describe("Function: getAchievementsEarnedOnDay", () => {
|
|
|
25
25
|
it("retrieves a list of user achievements earned on a specified date", async () => {
|
|
26
26
|
// ARRANGE
|
|
27
27
|
const authorization = buildAuthorization({
|
|
28
|
-
|
|
28
|
+
username: "mockUserName",
|
|
29
29
|
webApiKey: "mockWebApiKey",
|
|
30
30
|
});
|
|
31
31
|
|
|
@@ -58,7 +58,7 @@ describe("Function: getAchievementsEarnedOnDay", () => {
|
|
|
58
58
|
|
|
59
59
|
// ACT
|
|
60
60
|
const response = await getAchievementsEarnedOnDay(authorization, {
|
|
61
|
-
|
|
61
|
+
username: "xelnia",
|
|
62
62
|
onDate: new Date("2022-10-12"),
|
|
63
63
|
});
|
|
64
64
|
|
|
@@ -14,10 +14,10 @@ import type {
|
|
|
14
14
|
* A call to this function will retrieve a list of achievements
|
|
15
15
|
* earned by a given user on a specified date.
|
|
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
|
|
21
21
|
* list of achievements for.
|
|
22
22
|
*
|
|
23
23
|
* @param payload.fromDate A Date object specifying when
|
|
@@ -31,7 +31,7 @@ import type {
|
|
|
31
31
|
* const achievementsEarnedOnDay = await getAchievementsEarnedOnDay(
|
|
32
32
|
* authorization,
|
|
33
33
|
* {
|
|
34
|
-
*
|
|
34
|
+
* username: "xelnia",
|
|
35
35
|
* onDate: new Date("2022-10-13")
|
|
36
36
|
* }
|
|
37
37
|
* );
|
|
@@ -64,16 +64,16 @@ import type {
|
|
|
64
64
|
*/
|
|
65
65
|
export const getAchievementsEarnedOnDay = async (
|
|
66
66
|
authorization: AuthObject,
|
|
67
|
-
payload: {
|
|
67
|
+
payload: { username: string; onDate: Date }
|
|
68
68
|
): Promise<DatedUserAchievement[]> => {
|
|
69
|
-
const {
|
|
69
|
+
const { username, onDate } = payload;
|
|
70
70
|
|
|
71
71
|
const url = buildRequestUrl(
|
|
72
72
|
apiBaseUrl,
|
|
73
73
|
"/API_GetAchievementsEarnedOnDay.php",
|
|
74
74
|
authorization,
|
|
75
75
|
{
|
|
76
|
-
u:
|
|
76
|
+
u: username,
|
|
77
77
|
// YYYY-MM-DD
|
|
78
78
|
d: `${onDate.getFullYear()}-${onDate.getMonth() + 1}-${onDate.getDate()}`,
|
|
79
79
|
}
|
|
@@ -24,7 +24,7 @@ describe("Function: getGameInfoAndUserProgress", () => {
|
|
|
24
24
|
it("given a game ID and a username, retrieves extended metadata about the game and that user`s progress", async () => {
|
|
25
25
|
// ARRANGE
|
|
26
26
|
const authorization = buildAuthorization({
|
|
27
|
-
|
|
27
|
+
username: "mockUserName",
|
|
28
28
|
webApiKey: "mockWebApiKey",
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -82,7 +82,7 @@ describe("Function: getGameInfoAndUserProgress", () => {
|
|
|
82
82
|
// ACT
|
|
83
83
|
const response = await getGameInfoAndUserProgress(authorization, {
|
|
84
84
|
gameId: 14_402,
|
|
85
|
-
|
|
85
|
+
username: "xelnia",
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
// ASSERT
|
|
@@ -99,7 +99,7 @@ describe("Function: getGameInfoAndUserProgress", () => {
|
|
|
99
99
|
publisher: "Activision ",
|
|
100
100
|
developer: "David Crane",
|
|
101
101
|
genre: "Racing",
|
|
102
|
-
released: 1980,
|
|
102
|
+
released: "1980",
|
|
103
103
|
isFinal: false,
|
|
104
104
|
consoleName: "Atari 2600",
|
|
105
105
|
richPresencePatch: "2b92fa1bf9635c303b3b7f8feea3ed3c",
|
|
@@ -16,7 +16,7 @@ import type {
|
|
|
16
16
|
* about a game, in addition to a user's progress about a game.
|
|
17
17
|
* This is targeted via a game's unique ID and a given username.
|
|
18
18
|
*
|
|
19
|
-
* @param authorization An object containing your
|
|
19
|
+
* @param authorization An object containing your username and webApiKey.
|
|
20
20
|
* This can be constructed with `buildAuthorization()`.
|
|
21
21
|
*
|
|
22
22
|
* @param payload.gameId The unique game ID. If you are unsure, open the
|
|
@@ -24,14 +24,17 @@ import type {
|
|
|
24
24
|
* URL is https://retroachievements.org/game/14402. We can see from the
|
|
25
25
|
* URL that the game ID is "14402".
|
|
26
26
|
*
|
|
27
|
-
* @param payload.
|
|
27
|
+
* @param payload.username The user for which to retrieve the
|
|
28
28
|
* game progress for.
|
|
29
29
|
*
|
|
30
|
+
* @param payload.shouldIncludeHighestAwardMetadata Include a "HighestAwardKind"
|
|
31
|
+
* and a "HighestAwardDate" for the given user and game ID.
|
|
32
|
+
*
|
|
30
33
|
* @example
|
|
31
34
|
* ```
|
|
32
35
|
* const gameInfoAndUserProgress = await getGameInfoAndUserProgress(
|
|
33
36
|
* authorization,
|
|
34
|
-
* { gameId: 14402,
|
|
37
|
+
* { gameId: 14402, username: "wv_pinball" }
|
|
35
38
|
* );
|
|
36
39
|
* ```
|
|
37
40
|
*
|
|
@@ -51,7 +54,7 @@ import type {
|
|
|
51
54
|
* publisher: "Activision",
|
|
52
55
|
* developer: "David Crane",
|
|
53
56
|
* genre: "Racing",
|
|
54
|
-
* released: 1980,
|
|
57
|
+
* released: "1980",
|
|
55
58
|
* isFinal: false,
|
|
56
59
|
* consoleName: "Atari 2600",
|
|
57
60
|
* richPresencePatch: "2b92fa1bf9635c303b3b7f8feea3ed3c",
|
|
@@ -87,18 +90,27 @@ import type {
|
|
|
87
90
|
*/
|
|
88
91
|
export const getGameInfoAndUserProgress = async (
|
|
89
92
|
authorization: AuthObject,
|
|
90
|
-
payload: {
|
|
93
|
+
payload: {
|
|
94
|
+
gameId: ID;
|
|
95
|
+
username: string;
|
|
96
|
+
shouldIncludeHighestAwardMetadata?: boolean;
|
|
97
|
+
}
|
|
91
98
|
): Promise<GameInfoAndUserProgress> => {
|
|
92
|
-
const { gameId,
|
|
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
|
+
}
|
|
93
108
|
|
|
94
109
|
const url = buildRequestUrl(
|
|
95
110
|
apiBaseUrl,
|
|
96
111
|
"/API_GetGameInfoAndUserProgress.php",
|
|
97
112
|
authorization,
|
|
98
|
-
|
|
99
|
-
g: gameId,
|
|
100
|
-
u: userName,
|
|
101
|
-
}
|
|
113
|
+
params
|
|
102
114
|
);
|
|
103
115
|
|
|
104
116
|
const rawResponse = await call<GetGameInfoAndUserProgressResponse>({ url });
|
|
@@ -113,7 +125,6 @@ export const getGameInfoAndUserProgress = async (
|
|
|
113
125
|
"DisplayOrder",
|
|
114
126
|
"NumDistinctPlayersCasual",
|
|
115
127
|
"NumDistinctPlayersHardcore",
|
|
116
|
-
"Released",
|
|
117
128
|
],
|
|
118
129
|
});
|
|
119
130
|
};
|
|
@@ -22,7 +22,7 @@ describe("Function: getUserAwards", () => {
|
|
|
22
22
|
it("retrieves a list of a target user awards", async () => {
|
|
23
23
|
// ARRANGE
|
|
24
24
|
const authorization = buildAuthorization({
|
|
25
|
-
|
|
25
|
+
username: "mockUserName",
|
|
26
26
|
webApiKey: "mockWebApiKey",
|
|
27
27
|
});
|
|
28
28
|
|
|
@@ -57,7 +57,7 @@ describe("Function: getUserAwards", () => {
|
|
|
57
57
|
);
|
|
58
58
|
|
|
59
59
|
// ACT
|
|
60
|
-
const response = await getUserAwards(authorization, {
|
|
60
|
+
const response = await getUserAwards(authorization, { username: "xelnia" });
|
|
61
61
|
|
|
62
62
|
// ASSERT
|
|
63
63
|
expect(response).toEqual({
|