diff --git a/docs/v1/get-comments.md b/docs/v1/get-comments.md index 74386a3..3e03c0a 100644 --- a/docs/v1/get-comments.md +++ b/docs/v1/get-comments.md @@ -27,56 +27,56 @@ A call to this endpoint returns comments of a specified kind: game, achievement, ::: code-group -```Kotlin [User] -val credentials = RetroCredentials("", "") -val api: RetroInterface = RetroClient(credentials).api +```ts [NodeJS] +import { buildAuthorization, getComments } from "@retroachievements/api"; -val response: NetworkResponse = api.getCommentsOnUserWall( - username = "MaxMilyin", -) +// First, build your authorization object. +const username = ""; +const webApiKey = ""; -if (response is NetworkResponse.Success) { - // handle the data - val comments: GetComments.Response = response.body +const authorization = buildAuthorization({ username, webApiKey }); -} else if (response is NetworkResponse.Error) { - // if the server returns an error it be found here - val errorResponse: ErrorResponse? = response.body - - // if the api (locally) had an internal error, it'll be found here - val internalError: Throwable? = response.error -} -``` - -```Kotlin [Game] -val credentials = RetroCredentials("", "") -val api: RetroInterface = RetroClient(credentials).api - -val response: NetworkResponse = api.getCommentsOnGameWall( - gameId = 14402, -) +// Then, make the API call depending on what kind of comments you want. -if (response is NetworkResponse.Success) { - // handle the data - val comments: GetComments.Response = response.body +// For comments on a user's wall, call the following: +const userWallComments = await getComments(authorization, { + identifier: "MaxMilyin", +}); -} else if (response is NetworkResponse.Error) { - // if the server returns an error it be found here - val errorResponse: ErrorResponse? = response.body +// For comments on a game's wall, call the following: +const gameWallComments = await getComments(authorization, { + identifier: 14402, + kind: "game", +}); - // if the api (locally) had an internal error, it'll be found here - val internalError: Throwable? = response.error -} +// For comments on an achievement's wall, call the following: +const achievementWallComments = await getComments(authorization, { + identifier: 14402, + kind: "achievement", +}); ``` -```Kotlin [Achievement] +```Kotlin val credentials = RetroCredentials("", "") val api: RetroInterface = RetroClient(credentials).api -val response: NetworkResponse = api.getCommentsOnAchievementWall( - achievementId = 14402, +// get comments currently on user's wall +val response: NetworkResponse = api.getCommentsOnUserWall( + username = "MaxMilyin", ) +// to get comments from a game's wall, use the following: +// +// val response: NetworkResponse = api.getCommentsOnGameWall( +// gameId = 14402, +// ) + +// to get comments from an achievement's wall, use the following: +// +// val response: NetworkResponse = api.getCommentsOnAchievementWall( +// achievementId = 14402, +// ) + if (response is NetworkResponse.Success) { // handle the data val comments: GetComments.Response = response.body @@ -112,6 +112,22 @@ if (response is NetworkResponse.Success) { ] ``` +```json [NodeJS] +[ + "count": 4, + "total": 4, + "results": [ + { + "user": "PlayTester", + "ulid": "00003EMFWR7XB8SDPEHB3K56ZQ", + "submitted": "2024-07-31T11:22:23.000000Z", + "commentText": "Comment 1" + }, + // ... + ] +] +``` + ::: ## Source @@ -119,4 +135,5 @@ if (response is NetworkResponse.Success) { | Repo | URL | | :--------- | :------------------------------------------------------------------------------------------------------------------- | | RAWeb | https://github.com/RetroAchievements/RAWeb/blob/master/public/API/API_GetComments.php | +| api-js | https://github.com/RetroAchievements/api-js/blob/main/src/comment/getComments.ts | | api-kotlin | https://github.com/RetroAchievements/api-kotlin/blob/main/src/main/kotlin/org/retroachivements/api/RetroInterface.kt |