Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: rename userName to username #97

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pnpm install
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:

```ts
const userName = "myUserName";
const username = "myUsername";
const webApiKey = "myWebApiKey";
```

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ To use any endpoint function in the API, you must first be authorized by RetroAc
```ts
import { buildAuthorization } from "@retroachievements/api";

const userName = "<your username on RA>";
const username = "<your username on RA>";
const webApiKey = "<your web API key>";

const authorization = buildAuthorization({ userName, webApiKey });
const authorization = buildAuthorization({ username, webApiKey });
```

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:
Expand Down
8 changes: 4 additions & 4 deletions src/__playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
import { buildAuthorization, getAchievementCount } from "./index";

// MODIFY THESE VALUES.
const userName = "myUserName";
const username = "myUsername";
const webApiKey = "myWebApiKey";

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

// -- Start testing stuff here --

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

const authorization = buildAuthorization({ userName, webApiKey });
const authorization = buildAuthorization({ username, webApiKey });

const achievementCount = await getAchievementCount(authorization, {
gameId: 14_402,
Expand Down
2 changes: 1 addition & 1 deletion src/achievement/getAchievementUnlocks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("Function: getAchievementUnlocks", () => {
it("retrieves metadata about unlocks for a target achievement", async () => {
// ARRANGE
const authorization = buildAuthorization({
userName: "mockUserName",
username: "mockUserName",
webApiKey: "mockWebApiKey",
});

Expand Down
2 changes: 1 addition & 1 deletion src/achievement/getAchievementUnlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {
* A call to this function will retrieve a list of users who
* have earned a given achievement, targeted by the achievement's ID.
*
* @param authorization An object containing your userName and webApiKey.
* @param authorization An object containing your username and webApiKey.
* This can be constructed with `buildAuthorization()`.
*
* @param payload.achievementId The target achievement we want to
Expand Down
2 changes: 1 addition & 1 deletion src/console/getConsoleIds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("Function: getConsoleIds", () => {
it("retrieves a list of console IDs and their names and cleans properties", async () => {
// ARRANGE
const authorization = buildAuthorization({
userName: "mockUserName",
username: "mockUserName",
webApiKey: "mockWebApiKey",
});

Expand Down
2 changes: 1 addition & 1 deletion src/console/getConsoleIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { ConsoleId, GetConsoleIdsResponse } from "./models";
* of console ID and name pairs on the RetroAchievements.org
* platform.
*
* @param authorization An object containing your userName and webApiKey.
* @param authorization An object containing your username and webApiKey.
* This can be constructed with `buildAuthorization()`.
*
* @example
Expand Down
2 changes: 1 addition & 1 deletion src/console/getGameList.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("Function: getGameList", () => {
it("retrieves a list of games and cleans their properties", async () => {
// ARRANGE
const authorization = buildAuthorization({
userName: "mockUserName",
username: "mockUserName",
webApiKey: "mockWebApiKey",
});

Expand Down
2 changes: 1 addition & 1 deletion src/console/getGameList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { GameList, GetGameListResponse } from "./models";
* of games for a specified console on the RetroAchievements.org
* platform.
*
* @param authorization An object containing your userName and webApiKey.
* @param authorization An object containing your username and webApiKey.
* This can be constructed with `buildAuthorization()`.
*
* @param payload.consoleId The unique console ID to retrieve a list of
Expand Down
4 changes: 2 additions & 2 deletions src/feed/getAchievementOfTheWeek.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("Function: getAchievementOfTheWeek", () => {
it("retrieves metadata about the current achievement of the week and cleans properties", async () => {
// ARRANGE
const authorization = buildAuthorization({
userName: "mockUserName",
username: "mockUserName",
webApiKey: "mockWebApiKey",
});

Expand Down Expand Up @@ -105,7 +105,7 @@ describe("Function: getAchievementOfTheWeek", () => {
it("properly sets the hardcore boolean value when cleaning properties", async () => {
// ARRANGE
const authorization = buildAuthorization({
userName: "mockUserName",
username: "mockUserName",
webApiKey: "mockWebApiKey",
});

Expand Down
2 changes: 1 addition & 1 deletion src/feed/getAchievementOfTheWeek.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
* A call to this function will retrieve comprehensive
* metadata about the current Achievement of the Week.
*
* @param authorization An object containing your userName and webApiKey.
* @param authorization An object containing your username and webApiKey.
* This can be constructed with `buildAuthorization()`.
*
* @example
Expand Down
2 changes: 1 addition & 1 deletion src/feed/getActiveClaims.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("Function: getActiveClaims", () => {
it("retrieves metadata about current active claims", async () => {
// ARRANGE
const authorization = buildAuthorization({
userName: "mockUserName",
username: "mockUserName",
webApiKey: "mockWebApiKey",
});

Expand Down
2 changes: 1 addition & 1 deletion src/feed/getActiveClaims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { GetSetClaimsResponse, SetClaim } from "./models";
* A call to this function returns information about all
* (1000 max) active set claims.
*
* @param authorization An object containing your userName and webApiKey.
* @param authorization An object containing your username and webApiKey.
* This can be constructed with `buildAuthorization()`.
*
* @example
Expand Down
2 changes: 1 addition & 1 deletion src/feed/getClaims.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("Function: getClaims", () => {
it("retrieves metadata about a requested kind of claims", async () => {
// ARRANGE
const authorization = buildAuthorization({
userName: "mockUserName",
username: "mockUserName",
webApiKey: "mockWebApiKey",
});

Expand Down
22 changes: 11 additions & 11 deletions src/feed/getTopTenUsers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("Function: getTopTenUsers", () => {
it("retrieves metadata about the current top ten users on the site", async () => {
// ARRANGE
const authorization = buildAuthorization({
userName: "mockUserName",
username: "mockUserName",
webApiKey: "mockWebApiKey",
});

Expand Down Expand Up @@ -51,48 +51,48 @@ describe("Function: getTopTenUsers", () => {
// ASSERT
expect(response).toEqual([
{
userName: "MaxMilyin",
username: "MaxMilyin",
totalPoints: 346_289,
totalRatioPoints: 995_092,
},
{
userName: "HippopotamusRex",
username: "HippopotamusRex",
totalPoints: 312_118,
totalRatioPoints: 1_151_351,
},
{
userName: "Sarconius",
username: "Sarconius",
totalPoints: 257_862,
totalRatioPoints: 1_181_770,
},
{ userName: "guineu", totalPoints: 241_623, totalRatioPoints: 672_597 },
{ username: "guineu", totalPoints: 241_623, totalRatioPoints: 672_597 },
{
userName: "Andrey199650",
username: "Andrey199650",
totalPoints: 240_101,
totalRatioPoints: 567_522,
},
{
userName: "Wendigo",
username: "Wendigo",
totalPoints: 227_903,
totalRatioPoints: 1_099_685,
},
{
userName: "donutweegee",
username: "donutweegee",
totalPoints: 204_701,
totalRatioPoints: 587_221,
},
{
userName: "AmericanNinja",
username: "AmericanNinja",
totalPoints: 202_980,
totalRatioPoints: 567_618,
},
{
userName: "Infernum",
username: "Infernum",
totalPoints: 202_171,
totalRatioPoints: 689_967,
},
{
userName: "FabricioPrie",
username: "FabricioPrie",
totalPoints: 196_974,
totalRatioPoints: 450_436,
},
Expand Down
8 changes: 4 additions & 4 deletions src/feed/getTopTenUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
* A call to this function will retrieve the current top ten users
* on the site.
*
* @param authorization An object containing your userName and webApiKey.
* @param authorization An object containing your username and webApiKey.
* This can be constructed with `buildAuthorization()`.
*
* @example
Expand All @@ -21,8 +21,8 @@ import type {
* @returns An array containing the list of top ten users.
* ```json
* [
* { userName: "MockUser", totalPoints: 350000, totalRatioPoints: 995000 },
* { userName: "MockUser2", totalPoints: 345000, totalRatioPoints: 994000 },
* { username: "MockUser", totalPoints: 350000, totalRatioPoints: 995000 },
* { username: "MockUser2", totalPoints: 345000, totalRatioPoints: 994000 },
* // ...
* ]
* ```
Expand All @@ -41,7 +41,7 @@ export const getTopTenUsers = async (
const sanitizedTopTenUsers: TopTenUsersEntity[] = [];
for (const rawUser of rawTopTenUsers) {
sanitizedTopTenUsers.push({
userName: rawUser["1"],
username: rawUser["1"],
totalPoints: Number(rawUser["2"]),
totalRatioPoints: Number(rawUser["3"]),
});
Expand Down
2 changes: 1 addition & 1 deletion src/feed/models/top-ten-users-entity.model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface TopTenUsersEntity {
userName: string;
username: string;
totalPoints: number;
totalRatioPoints: number;
}
2 changes: 1 addition & 1 deletion src/game/getAchievementCount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("Function: getAchievementCount", () => {
it("given a game ID, retrieves the list of achievement IDs associated with the game and cleans properties", async () => {
// ARRANGE
const authorization = buildAuthorization({
userName: "mockUserName",
username: "mockUserName",
webApiKey: "mockWebApiKey",
});

Expand Down
2 changes: 1 addition & 1 deletion src/game/getAchievementCount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { AchievementCount, GetAchievementCountResponse } from "./models";
* A call to this function will retrieve the list of
* achievement IDs for a game, targeted by game ID.
*
* @param authorization An object containing your userName and webApiKey.
* @param authorization An object containing your username and webApiKey.
* This can be constructed with `buildAuthorization()`.
*
* @param payload.gameId The unique game ID. If you are unsure, open the
Expand Down
8 changes: 4 additions & 4 deletions src/game/getAchievementDistribution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("Function: getAchievementDistribution", () => {
it("given a game ID, retrieves the achievement distribution associated with the game", async () => {
// ARRANGE
const authorization = buildAuthorization({
userName: "mockUserName",
username: "mockUserName",
webApiKey: "mockWebApiKey",
});

Expand Down Expand Up @@ -61,7 +61,7 @@ describe("Function: getAchievementDistribution", () => {
it("given flags, successfully attaches the option to the call", async () => {
// ARRANGE
const authorization = buildAuthorization({
userName: "mockUserName",
username: "mockUserName",
webApiKey: "mockWebApiKey",
});

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/game/getAchievementDistribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
* of the number of players who have earned a specific
* number of achievements for a given game ID.
*
* @param authorization An object containing your userName and webApiKey.
* @param authorization An object containing your username and webApiKey.
* This can be constructed with `buildAuthorization()`.
*
* @param payload.gameId The unique game ID. If you are unsure, open the
Expand Down
2 changes: 1 addition & 1 deletion src/game/getGame.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("Function: getGame", () => {
it("given a game ID, retrieves basic metadata about the game", async () => {
// ARRANGE
const authorization = buildAuthorization({
userName: "mockUserName",
username: "mockUserName",
webApiKey: "mockWebApiKey",
});

Expand Down
2 changes: 1 addition & 1 deletion src/game/getGame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { Game, GetGameResponse } from "./models";
* A call to this function will retrieve basic metadata about
* a game, targeted via its unique ID.
*
* @param authorization An object containing your userName and webApiKey.
* @param authorization An object containing your username and webApiKey.
* This can be constructed with `buildAuthorization()`.
*
* @param payload.gameId The unique game ID. If you are unsure, open the
Expand Down
2 changes: 1 addition & 1 deletion src/game/getGameExtended.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("Function: getGameExtended", () => {
it("given a game ID, retrieves extended metadata about the game", async () => {
// ARRANGE
const authorization = buildAuthorization({
userName: "mockUserName",
username: "mockUserName",
webApiKey: "mockWebApiKey",
});

Expand Down
2 changes: 1 addition & 1 deletion src/game/getGameExtended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { GameExtended, GetGameExtendedResponse } from "./models";
* A call to this function will retrieve extended metadata
* about a game, targeted via its unique ID.
*
* @param authorization An object containing your userName and webApiKey.
* @param authorization An object containing your username and webApiKey.
* This can be constructed with `buildAuthorization()`.
*
* @param payload.gameId The unique game ID. If you are unsure, open the
Expand Down
2 changes: 1 addition & 1 deletion src/game/getGameRankAndScore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("Function: getGameRankAndScore", () => {
it("given a game ID, retrieves metadata about latest masteries for a game", async () => {
// ARRANGE
const authorization = buildAuthorization({
userName: "mockUserName",
username: "mockUserName",
webApiKey: "mockWebApiKey",
});

Expand Down
2 changes: 1 addition & 1 deletion src/game/getGameRankAndScore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {
* points earners for a game. The game is targeted via
* its unique ID.
*
* @param authorization An object containing your userName and webApiKey.
* @param authorization An object containing your username and webApiKey.
* This can be constructed with `buildAuthorization()`.
*
* @param payload.gameId The unique game ID. If you are unsure, open the
Expand Down
2 changes: 1 addition & 1 deletion src/game/getGameRating.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("Function: getGameRating", () => {
it("given a game ID, retrieves metadata about how users have rated it", async () => {
// ARRANGE
const authorization = buildAuthorization({
userName: "mockUserName",
username: "mockUserName",
webApiKey: "mockWebApiKey",
});

Expand Down
2 changes: 1 addition & 1 deletion src/game/getGameRating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { GameRating, GetGameRatingResponse } from "./models";
* A call to this function will retrieve metadata about
* how users have rated the game and its set.
*
* @param authorization An object containing your userName and webApiKey.
* @param authorization An object containing your username and webApiKey.
* This can be constructed with `buildAuthorization()`.
*
* @param payload.gameId The unique game ID. If you are unsure, open the
Expand Down
Loading