Skip to content

Commit f7427fa

Browse files
authored
refactor!: rename userName to username (#97)
1 parent d107d4c commit f7427fa

File tree

64 files changed

+196
-196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+196
-196
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pnpm install
1818
This project includes a `__playground.ts` file for testing any local changes. To get started, open the file and replace these lines with values pertinent to your user account on RetroAchievements:
1919

2020
```ts
21-
const userName = "myUserName";
21+
const username = "myUsername";
2222
const webApiKey = "myWebApiKey";
2323
```
2424

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ To use any endpoint function in the API, you must first be authorized by RetroAc
5454
```ts
5555
import { buildAuthorization } from "@retroachievements/api";
5656

57-
const userName = "<your username on RA>";
57+
const username = "<your username on RA>";
5858
const webApiKey = "<your web API key>";
5959

60-
const authorization = buildAuthorization({ userName, webApiKey });
60+
const authorization = buildAuthorization({ username, webApiKey });
6161
```
6262

6363
4. You now have all you need to use any function in the API. Each function takes this authorization object as its first argument. Here's an example:

src/__playground.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@
1717
import { buildAuthorization, getAchievementCount } from "./index";
1818

1919
// MODIFY THESE VALUES.
20-
const userName = "myUserName";
20+
const username = "myUsername";
2121
const webApiKey = "myWebApiKey";
2222

2323
const main = async () => {
2424
console.log("🚀 @retroachievements/api playground is running.\n");
2525

2626
// -- Start testing stuff here --
2727

28-
if (userName === "myUserName" || webApiKey === "myWebApiKey") {
28+
if (username === "myUsername" || webApiKey === "myWebApiKey") {
2929
console.error(
30-
"⛔️ ERROR: In __playground.ts, modify the userName and webApiKey variables to match your RA credentials.\n"
30+
"⛔️ ERROR: In __playground.ts, modify the username and webApiKey variables to match your RA credentials.\n"
3131
);
3232
}
3333

34-
const authorization = buildAuthorization({ userName, webApiKey });
34+
const authorization = buildAuthorization({ username, webApiKey });
3535

3636
const achievementCount = await getAchievementCount(authorization, {
3737
gameId: 14_402,

src/achievement/getAchievementUnlocks.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe("Function: getAchievementUnlocks", () => {
2222
it("retrieves metadata about unlocks for a target achievement", async () => {
2323
// ARRANGE
2424
const authorization = buildAuthorization({
25-
userName: "mockUserName",
25+
username: "mockUserName",
2626
webApiKey: "mockWebApiKey",
2727
});
2828

src/achievement/getAchievementUnlocks.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type {
1515
* A call to this function will retrieve a list of users who
1616
* have earned a given achievement, targeted by the achievement's ID.
1717
*
18-
* @param authorization An object containing your userName and webApiKey.
18+
* @param authorization An object containing your username and webApiKey.
1919
* This can be constructed with `buildAuthorization()`.
2020
*
2121
* @param payload.achievementId The target achievement we want to

src/console/getConsoleIds.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("Function: getConsoleIds", () => {
2424
it("retrieves a list of console IDs and their names and cleans properties", async () => {
2525
// ARRANGE
2626
const authorization = buildAuthorization({
27-
userName: "mockUserName",
27+
username: "mockUserName",
2828
webApiKey: "mockWebApiKey",
2929
});
3030

src/console/getConsoleIds.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { FetchedSystem, GetConsoleIdsResponse } from "./models";
1212
* of console ID and name pairs on the RetroAchievements.org
1313
* platform.
1414
*
15-
* @param authorization An object containing your userName and webApiKey.
15+
* @param authorization An object containing your username and webApiKey.
1616
* This can be constructed with `buildAuthorization()`.
1717
*
1818
* @param payload.shouldOnlyRetrieveActiveSystems If true, only systems that

src/console/getGameList.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("Function: getGameList", () => {
2424
it("retrieves a list of games and cleans their properties", async () => {
2525
// ARRANGE
2626
const authorization = buildAuthorization({
27-
userName: "mockUserName",
27+
username: "mockUserName",
2828
webApiKey: "mockWebApiKey",
2929
});
3030

src/console/getGameList.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { GameList, GetGameListResponse } from "./models";
1212
* of games for a specified console on the RetroAchievements.org
1313
* platform.
1414
*
15-
* @param authorization An object containing your userName and webApiKey.
15+
* @param authorization An object containing your username and webApiKey.
1616
* This can be constructed with `buildAuthorization()`.
1717
*
1818
* @param payload.consoleId The unique console ID to retrieve a list of

src/feed/getAchievementOfTheWeek.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe("Function: getAchievementOfTheWeek", () => {
2727
it("retrieves metadata about the current achievement of the week and cleans properties", async () => {
2828
// ARRANGE
2929
const authorization = buildAuthorization({
30-
userName: "mockUserName",
30+
username: "mockUserName",
3131
webApiKey: "mockWebApiKey",
3232
});
3333

@@ -105,7 +105,7 @@ describe("Function: getAchievementOfTheWeek", () => {
105105
it("properly sets the hardcore boolean value when cleaning properties", async () => {
106106
// ARRANGE
107107
const authorization = buildAuthorization({
108-
userName: "mockUserName",
108+
username: "mockUserName",
109109
webApiKey: "mockWebApiKey",
110110
});
111111

src/feed/getAchievementOfTheWeek.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
* A call to this function will retrieve comprehensive
1515
* metadata about the current Achievement of the Week.
1616
*
17-
* @param authorization An object containing your userName and webApiKey.
17+
* @param authorization An object containing your username and webApiKey.
1818
* This can be constructed with `buildAuthorization()`.
1919
*
2020
* @example

src/feed/getActiveClaims.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("Function: getActiveClaims", () => {
2424
it("retrieves metadata about current active claims", async () => {
2525
// ARRANGE
2626
const authorization = buildAuthorization({
27-
userName: "mockUserName",
27+
username: "mockUserName",
2828
webApiKey: "mockWebApiKey",
2929
});
3030

src/feed/getActiveClaims.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { GetSetClaimsResponse, SetClaim } from "./models";
1111
* A call to this function returns information about all
1212
* (1000 max) active set claims.
1313
*
14-
* @param authorization An object containing your userName and webApiKey.
14+
* @param authorization An object containing your username and webApiKey.
1515
* This can be constructed with `buildAuthorization()`.
1616
*
1717
* @example

src/feed/getClaims.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("Function: getClaims", () => {
2424
it("retrieves metadata about a requested kind of claims", async () => {
2525
// ARRANGE
2626
const authorization = buildAuthorization({
27-
userName: "mockUserName",
27+
username: "mockUserName",
2828
webApiKey: "mockWebApiKey",
2929
});
3030

src/feed/getTopTenUsers.test.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe("Function: getTopTenUsers", () => {
2222
it("retrieves metadata about the current top ten users on the site", async () => {
2323
// ARRANGE
2424
const authorization = buildAuthorization({
25-
userName: "mockUserName",
25+
username: "mockUserName",
2626
webApiKey: "mockWebApiKey",
2727
});
2828

@@ -51,48 +51,48 @@ describe("Function: getTopTenUsers", () => {
5151
// ASSERT
5252
expect(response).toEqual([
5353
{
54-
userName: "MaxMilyin",
54+
username: "MaxMilyin",
5555
totalPoints: 346_289,
5656
totalRatioPoints: 995_092,
5757
},
5858
{
59-
userName: "HippopotamusRex",
59+
username: "HippopotamusRex",
6060
totalPoints: 312_118,
6161
totalRatioPoints: 1_151_351,
6262
},
6363
{
64-
userName: "Sarconius",
64+
username: "Sarconius",
6565
totalPoints: 257_862,
6666
totalRatioPoints: 1_181_770,
6767
},
68-
{ userName: "guineu", totalPoints: 241_623, totalRatioPoints: 672_597 },
68+
{ username: "guineu", totalPoints: 241_623, totalRatioPoints: 672_597 },
6969
{
70-
userName: "Andrey199650",
70+
username: "Andrey199650",
7171
totalPoints: 240_101,
7272
totalRatioPoints: 567_522,
7373
},
7474
{
75-
userName: "Wendigo",
75+
username: "Wendigo",
7676
totalPoints: 227_903,
7777
totalRatioPoints: 1_099_685,
7878
},
7979
{
80-
userName: "donutweegee",
80+
username: "donutweegee",
8181
totalPoints: 204_701,
8282
totalRatioPoints: 587_221,
8383
},
8484
{
85-
userName: "AmericanNinja",
85+
username: "AmericanNinja",
8686
totalPoints: 202_980,
8787
totalRatioPoints: 567_618,
8888
},
8989
{
90-
userName: "Infernum",
90+
username: "Infernum",
9191
totalPoints: 202_171,
9292
totalRatioPoints: 689_967,
9393
},
9494
{
95-
userName: "FabricioPrie",
95+
username: "FabricioPrie",
9696
totalPoints: 196_974,
9797
totalRatioPoints: 450_436,
9898
},

src/feed/getTopTenUsers.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
* A call to this function will retrieve the current top ten users
1111
* on the site.
1212
*
13-
* @param authorization An object containing your userName and webApiKey.
13+
* @param authorization An object containing your username and webApiKey.
1414
* This can be constructed with `buildAuthorization()`.
1515
*
1616
* @example
@@ -21,8 +21,8 @@ import type {
2121
* @returns An array containing the list of top ten users.
2222
* ```json
2323
* [
24-
* { userName: "MockUser", totalPoints: 350000, totalRatioPoints: 995000 },
25-
* { userName: "MockUser2", totalPoints: 345000, totalRatioPoints: 994000 },
24+
* { username: "MockUser", totalPoints: 350000, totalRatioPoints: 995000 },
25+
* { username: "MockUser2", totalPoints: 345000, totalRatioPoints: 994000 },
2626
* // ...
2727
* ]
2828
* ```
@@ -41,7 +41,7 @@ export const getTopTenUsers = async (
4141
const sanitizedTopTenUsers: TopTenUsersEntity[] = [];
4242
for (const rawUser of rawTopTenUsers) {
4343
sanitizedTopTenUsers.push({
44-
userName: rawUser["1"],
44+
username: rawUser["1"],
4545
totalPoints: Number(rawUser["2"]),
4646
totalRatioPoints: Number(rawUser["3"]),
4747
});
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export interface TopTenUsersEntity {
2-
userName: string;
2+
username: string;
33
totalPoints: number;
44
totalRatioPoints: number;
55
}

src/game/getAchievementCount.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe("Function: getAchievementCount", () => {
2222
it("given a game ID, retrieves the list of achievement IDs associated with the game and cleans properties", async () => {
2323
// ARRANGE
2424
const authorization = buildAuthorization({
25-
userName: "mockUserName",
25+
username: "mockUserName",
2626
webApiKey: "mockWebApiKey",
2727
});
2828

src/game/getAchievementCount.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { AchievementCount, GetAchievementCountResponse } from "./models";
1212
* A call to this function will retrieve the list of
1313
* achievement IDs for a game, targeted by game ID.
1414
*
15-
* @param authorization An object containing your userName and webApiKey.
15+
* @param authorization An object containing your username and webApiKey.
1616
* This can be constructed with `buildAuthorization()`.
1717
*
1818
* @param payload.gameId The unique game ID. If you are unsure, open the

src/game/getAchievementDistribution.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe("Function: getAchievementDistribution", () => {
2323
it("given a game ID, retrieves the achievement distribution associated with the game", async () => {
2424
// ARRANGE
2525
const authorization = buildAuthorization({
26-
userName: "mockUserName",
26+
username: "mockUserName",
2727
webApiKey: "mockWebApiKey",
2828
});
2929

@@ -61,7 +61,7 @@ describe("Function: getAchievementDistribution", () => {
6161
it("given flags, successfully attaches the option to the call", async () => {
6262
// ARRANGE
6363
const authorization = buildAuthorization({
64-
userName: "mockUserName",
64+
username: "mockUserName",
6565
webApiKey: "mockWebApiKey",
6666
});
6767

@@ -101,7 +101,7 @@ describe("Function: getAchievementDistribution", () => {
101101
it("given a truthy hardcore value, successfully attaches the option to the call", async () => {
102102
// ARRANGE
103103
const authorization = buildAuthorization({
104-
userName: "mockUserName",
104+
username: "mockUserName",
105105
webApiKey: "mockWebApiKey",
106106
});
107107

@@ -138,7 +138,7 @@ describe("Function: getAchievementDistribution", () => {
138138
it("given a falsy hardcore value, successfully attaches the option to the call", async () => {
139139
// ARRANGE
140140
const authorization = buildAuthorization({
141-
userName: "mockUserName",
141+
username: "mockUserName",
142142
webApiKey: "mockWebApiKey",
143143
});
144144

src/game/getAchievementDistribution.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type {
1111
* of the number of players who have earned a specific
1212
* number of achievements for a given game ID.
1313
*
14-
* @param authorization An object containing your userName and webApiKey.
14+
* @param authorization An object containing your username and webApiKey.
1515
* This can be constructed with `buildAuthorization()`.
1616
*
1717
* @param payload.gameId The unique game ID. If you are unsure, open the

src/game/getGame.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("Function: getGame", () => {
2424
it("given a game ID, retrieves basic metadata about the game", async () => {
2525
// ARRANGE
2626
const authorization = buildAuthorization({
27-
userName: "mockUserName",
27+
username: "mockUserName",
2828
webApiKey: "mockWebApiKey",
2929
});
3030

src/game/getGame.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { Game, GetGameResponse } from "./models";
1212
* A call to this function will retrieve basic metadata about
1313
* a game, targeted via its unique ID.
1414
*
15-
* @param authorization An object containing your userName and webApiKey.
15+
* @param authorization An object containing your username and webApiKey.
1616
* This can be constructed with `buildAuthorization()`.
1717
*
1818
* @param payload.gameId The unique game ID. If you are unsure, open the

src/game/getGameExtended.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("Function: getGameExtended", () => {
2424
it("given a game ID, retrieves extended metadata about the game", async () => {
2525
// ARRANGE
2626
const authorization = buildAuthorization({
27-
userName: "mockUserName",
27+
username: "mockUserName",
2828
webApiKey: "mockWebApiKey",
2929
});
3030

src/game/getGameExtended.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { GameExtended, GetGameExtendedResponse } from "./models";
1212
* A call to this function will retrieve extended metadata
1313
* about a game, targeted via its unique ID.
1414
*
15-
* @param authorization An object containing your userName and webApiKey.
15+
* @param authorization An object containing your username and webApiKey.
1616
* This can be constructed with `buildAuthorization()`.
1717
*
1818
* @param payload.gameId The unique game ID. If you are unsure, open the

src/game/getGameRankAndScore.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("Function: getGameRankAndScore", () => {
2424
it("given a game ID, retrieves metadata about latest masteries for a game", async () => {
2525
// ARRANGE
2626
const authorization = buildAuthorization({
27-
userName: "mockUserName",
27+
username: "mockUserName",
2828
webApiKey: "mockWebApiKey",
2929
});
3030

src/game/getGameRankAndScore.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import type {
1717
* points earners for a game. The game is targeted via
1818
* its unique ID.
1919
*
20-
* @param authorization An object containing your userName and webApiKey.
20+
* @param authorization An object containing your username and webApiKey.
2121
* This can be constructed with `buildAuthorization()`.
2222
*
2323
* @param payload.gameId The unique game ID. If you are unsure, open the

src/game/getGameRating.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe("Function: getGameRating", () => {
2222
it("given a game ID, retrieves metadata about how users have rated it", async () => {
2323
// ARRANGE
2424
const authorization = buildAuthorization({
25-
userName: "mockUserName",
25+
username: "mockUserName",
2626
webApiKey: "mockWebApiKey",
2727
});
2828

src/game/getGameRating.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { GameRating, GetGameRatingResponse } from "./models";
1212
* A call to this function will retrieve metadata about
1313
* how users have rated the game and its set.
1414
*
15-
* @param authorization An object containing your userName and webApiKey.
15+
* @param authorization An object containing your username and webApiKey.
1616
* This can be constructed with `buildAuthorization()`.
1717
*
1818
* @param payload.gameId The unique game ID. If you are unsure, open the

0 commit comments

Comments
 (0)