Skip to content

Commit e8be9b7

Browse files
docs: add Kotlin example for API_GetUserGameLeaderboards (#89)
1 parent 8cdfbd9 commit e8be9b7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/v1/get-user-game-leaderboards.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,27 @@ const gameLeaderboards = await getUserGameLeaderboards(authorization, {
5454
});
5555
```
5656

57+
```kotlin [Kotlin]
58+
val credentials = RetroCredentials("<username>", "<web api key>")
59+
val api: RetroInterface = RetroClient(credentials).api
60+
61+
val response: NetworkResponse<GetUserGameLeaderboard.Response, ErrorResponse> = api.getUserGameLeaderboards(
62+
gameId = 14402,
63+
)
64+
65+
if (response is NetworkResponse.Success) {
66+
// handle the data
67+
val leaderboard: GetUserGameLeaderboard.Response = response.body
68+
69+
} else if (response is NetworkResponse.Error) {
70+
// if the server returns an error it be found here
71+
val errorResponse: ErrorResponse? = response.body
72+
73+
// if the api (locally) had an internal error, it'll be found here
74+
val internalError: Throwable? = response.error
75+
}
76+
```
77+
5778
:::
5879

5980
## Response

0 commit comments

Comments
 (0)