Skip to content

Commit de69d4b

Browse files
Feat: add missing endpoints & features (#45)
* chore: Change Version * chore: Change Version * chore: Change Version * feat: add richPresenceMsgDate * feat: add GetGameProgression * feat: add UserTotalPlaytime * feat: add includeUserAward to getGameInfoAndUserProgress * feat: add ReleasedAtGranularity * feat: add offset & count for API_GetGameList * chore: format * chore: format * feat: add GetUserSetRequests * feat: add GetUserSetRequests * feat: add GetUserGameLeaderboard * fix: getUserSetRequests response * feat: add getUserSetRequests & getUserGameLeaderboards tests * feat: add releasedAtGranularity * feat: add sort to API_GetComments * feat: add Author and AuthorULID * feat: add trueRatio * chore: version change * chore: make userId optional for getUserGameLeaderboards * docs: update version change
1 parent 407748c commit de69d4b

23 files changed

+440
-127
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Then add this `api-kotlin` dependency to your `pom.xml` project!
2626
<dependency>
2727
<groupId>com.github.RetroAchievements</groupId>
2828
<artifactId>api-kotlin</artifactId>
29-
<version>1.0.18</version>
29+
<version>1.1.0</version>
3030
</dependency>
3131
```
3232

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.retroachievements</groupId>
88
<artifactId>api-kotlin</artifactId>
9-
<version>1.0.18</version>
9+
<version>1.1.0</version>
1010

1111
<dependencyManagement>
1212
<dependencies>

src/main/kotlin/org/retroachivements/api/RetroInterface.kt

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,20 @@ interface RetroInterface {
8080
@POST("/API/API_GetGameInfoAndUserProgress.php")
8181
suspend fun getGameInfoAndUserProgress(
8282
@Query("u") username: String,
83-
@Query("g") gameId: Long
83+
@Query("g") gameId: Long,
84+
@Query("a") includeUserAward: Int = 0
8485
): NetworkResponse<GetGameInfoAndUserProgress.Response, ErrorResponse>
8586

87+
/**
88+
* A call to this endpoint will retrieve information about the average time to unlock achievements in a game, targeted via its unique ID.
89+
*/
90+
@Mock @MockResponse(body = "/v1/game/GetGameProgression.json")
91+
@POST("/API/API_GetGameProgression.php")
92+
suspend fun getGameProgression(
93+
@Query("i") gameId: Long,
94+
@Query("h") hardcore: Int = 0
95+
): NetworkResponse<GetGameProgression.Response, ErrorResponse>
96+
8697
/**
8798
* A call to this function will retrieve a giver user's completion progress, targeted by their username.
8899
*/
@@ -205,6 +216,16 @@ interface RetroInterface {
205216
@Query("c") count: Int = 100
206217
): NetworkResponse<GetUsersFollowingMe.Response, ErrorResponse>
207218

219+
/**
220+
* A call to this endpoint will retrieve a given user's set requests, maximum total requests and points until next request.
221+
*/
222+
@Mock @MockResponse(body = "/v1/user/GetUserSetRequests.json")
223+
@POST("/API/API_GetUserSetRequests.php")
224+
suspend fun getUserSetRequests(
225+
@Query("u") userId: String,
226+
@Query("t") all: Int = 0
227+
): NetworkResponse<GetUserSetRequests.Response, ErrorResponse>
228+
208229
/**
209230
* A call to this function will retrieve basic metadata about a game, targeted via its unique ID.
210231
*/
@@ -291,6 +312,18 @@ interface RetroInterface {
291312
@Query("c") count: Int = 100
292313
): NetworkResponse<GetLeaderboardEntries.Response, ErrorResponse>
293314

315+
/**
316+
* A call to this function will retrieve a given leaderboard's entries, targeted by its ID.
317+
*/
318+
@Mock @MockResponse(body = "/v1/game/GetUserGameLeaderboards.json")
319+
@POST("/API/API_GetUserGameLeaderboards.php")
320+
suspend fun getUserGameLeaderboards(
321+
@Query("i") gameId: Long,
322+
@Query("u") userId: String? = null,
323+
@Query("o") offset: Int = 0,
324+
@Query("c") count: Int = 100
325+
): NetworkResponse<GetUserGameLeaderboard.Response, ErrorResponse>
326+
294327
/**
295328
* A call to this function will retrieve the complete list of all system ID and name pairs on the site.
296329
*
@@ -315,7 +348,9 @@ interface RetroInterface {
315348
suspend fun getGameList(
316349
@Query("i") consoleId: Long,
317350
@Query("f") shouldOnlyRetrieveGamesWithAchievements: Int = 0,
318-
@Query("h") shouldRetrieveGameHashes: Int = 0
351+
@Query("h") shouldRetrieveGameHashes: Int = 0,
352+
@Query("o") offset: Int = 0,
353+
@Query("c") count: Int = 0
319354
): NetworkResponse<GetGameList.Response, ErrorResponse>
320355

321356
/**
@@ -438,7 +473,8 @@ interface RetroInterface {
438473
@Query("i") username: String,
439474
@Query("c") count: Int = 10,
440475
@Query("o") offset: Int = 0,
441-
@Query("t") type: Int = 3
476+
@Query("t") type: Int = 3,
477+
@Query("sort") sort: String = "submitted"
442478
): NetworkResponse<GetComments.Response, ErrorResponse>
443479

444480
/**
@@ -450,7 +486,8 @@ interface RetroInterface {
450486
@Query("i") gameId: Long,
451487
@Query("c") count: Int = 10,
452488
@Query("o") offset: Int = 0,
453-
@Query("t") type: Int = 1
489+
@Query("t") type: Int = 1,
490+
@Query("sort") sort: String = "submitted"
454491
): NetworkResponse<GetComments.Response, ErrorResponse>
455492

456493
/**
@@ -462,6 +499,7 @@ interface RetroInterface {
462499
@Query("i") achievementId: Long,
463500
@Query("c") count: Int = 10,
464501
@Query("o") offset: Int = 0,
465-
@Query("t") type: Int = 2
502+
@Query("t") type: Int = 2,
503+
@Query("sort") sort: String = "submitted"
466504
): NetworkResponse<GetComments.Response, ErrorResponse>
467505
}

src/main/kotlin/org/retroachivements/api/data/pojo/game/GetGame.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ class GetGame {
5050
@SerializedName("Released")
5151
val released: String?,
5252

53+
@SerializedName("ReleasedAtGranularity")
54+
val releasedAtGranularity: String?,
55+
5356
@SerializedName("GameTitle")
5457
val gameTitle: String,
5558

src/main/kotlin/org/retroachivements/api/data/pojo/game/GetGameExtended.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class GetGameExtended {
4444
@SerializedName("Released")
4545
val released: String?,
4646

47+
@SerializedName("ReleasedAtGranularity")
48+
val releasedAtGranularity: String?,
49+
4750
@SerializedName("IsFinal")
4851
val isFinal: Boolean,
4952

src/main/kotlin/org/retroachivements/api/data/pojo/game/GetGameHashes.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ class GetGameHashes {
1111
data class Result(
1212
@SerializedName("Name")
1313
val name: String,
14+
1415
@SerializedName("MD5")
1516
val md5: String,
17+
1618
@SerializedName("Labels")
1719
val labels: List<String>,
20+
1821
@SerializedName("PatchUrl")
1922
val patchUrl: String?,
2023
)

src/main/kotlin/org/retroachivements/api/data/pojo/game/GetGameInfoAndUserProgress.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ class GetGameInfoAndUserProgress {
5656
@SerializedName("PlayersTotal")
5757
val playersTotal: Int,
5858

59+
@SerializedName("UserTotalPlaytime")
60+
val userTotalPlaytime: Int,
61+
5962
@SerializedName("GuideURL")
6063
val guideUrl: String?,
6164

src/main/kotlin/org/retroachivements/api/data/pojo/game/GetGameLeaderboards.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,54 @@ package org.retroachivements.api.data.pojo.game
33
import com.google.gson.annotations.SerializedName
44

55
class GetGameLeaderboards {
6+
67
data class Response(
78
@SerializedName("Count")
89
val count: Long,
10+
911
@SerializedName("Total")
1012
val total: Long,
13+
1114
@SerializedName("Results")
1215
val results: List<Leaderboard>,
1316
)
1417

1518
data class Leaderboard(
1619
@SerializedName("ID")
1720
val id: Long,
21+
1822
@SerializedName("RankAsc")
1923
val rankAsc: Boolean,
24+
2025
@SerializedName("Title")
2126
val title: String,
27+
2228
@SerializedName("Description")
2329
val description: String,
30+
2431
@SerializedName("Format")
2532
val format: String,
33+
2634
@SerializedName("TopEntry")
2735
val topEntry: TopEntry,
36+
37+
@SerializedName("Author")
38+
val author: String,
39+
40+
@SerializedName("AuthorULID")
41+
val authorUlid: String
2842
)
2943

3044
data class TopEntry(
3145
@SerializedName("User")
3246
val user: String,
47+
48+
@SerializedName("ULID")
49+
val ulid: String,
50+
3351
@SerializedName("Score")
3452
val score: Long,
53+
3554
@SerializedName("FormattedScore")
3655
val formattedScore: String,
3756
)
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
package org.retroachivements.api.data.pojo.game
2+
3+
import com.google.gson.annotations.SerializedName
4+
5+
class GetGameProgression {
6+
7+
data class Response(
8+
9+
@SerializedName("ID")
10+
val id: Int,
11+
12+
@SerializedName("Title")
13+
val title: String,
14+
15+
@SerializedName("ConsoleID")
16+
val consoleId: Int,
17+
18+
@SerializedName("ConsoleName")
19+
val consoleName: String,
20+
21+
@SerializedName("ImageIcon")
22+
val imageIcon: String,
23+
24+
@SerializedName("NumDistinctPlayers")
25+
val numDistinctPlayers: Int,
26+
27+
@SerializedName("TimesUsedInBeatMedian")
28+
val timesUsedInBeatMedian: Int,
29+
30+
@SerializedName("TimesUsedInHardcoreBeatMedian")
31+
val timesUsedInHardcoreBeatMedia: Int,
32+
33+
@SerializedName("MedianTimeToBeat")
34+
val medianTimeToBeat: Int,
35+
36+
@SerializedName("MedianTimeToBeatHardcore")
37+
val medianTimeToBeatHardcore: Int,
38+
39+
@SerializedName("TimesUsedInCompletionMedian")
40+
val timesUsedInCompletionMedian: Int,
41+
42+
@SerializedName("TimesUsedInMasteryMedian")
43+
val timesUsedInMasteryMedian: Int,
44+
45+
@SerializedName("MedianTimeToComplete")
46+
val mediaTimeToComplete: Int,
47+
48+
@SerializedName("MedianTimeToMaster")
49+
val medianTimeToMaster: Int,
50+
51+
@SerializedName("NumAchievements")
52+
val numAchievements: Int,
53+
54+
@SerializedName("Achievements")
55+
val achievements: List<Achievement>
56+
) {
57+
data class Achievement(
58+
59+
@SerializedName("ID")
60+
val id: Int,
61+
62+
@SerializedName("Title")
63+
val title: String,
64+
65+
@SerializedName("Description")
66+
val description: String,
67+
68+
@SerializedName("Points")
69+
val points: Int,
70+
71+
@SerializedName("TrueRatio")
72+
val trueRatio: Int,
73+
74+
@SerializedName("Type")
75+
val type: String?,
76+
77+
@SerializedName("BadgeName")
78+
val badgeName: String,
79+
80+
@SerializedName("NumAwarded")
81+
val numAwarded: Int,
82+
83+
@SerializedName("NumAwardedHardcore")
84+
val numAwardedHardcore: Int,
85+
86+
@SerializedName("TimesUsedInUnlockMedian")
87+
val timesUsedInUnlockMedian: Int,
88+
89+
@SerializedName("TimesUsedInHardcoreUnlockMedian")
90+
val timesUsedInHardcoreUnlockMedian: Int,
91+
92+
@SerializedName("MedianTimeToUnlock")
93+
val medianTimeToUnlock: Int,
94+
95+
@SerializedName("MedianTimeToUnlockHardcore")
96+
val medianTimeToUnlockHardcore: Int
97+
)
98+
}
99+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package org.retroachivements.api.data.pojo.game
2+
3+
import com.google.gson.annotations.SerializedName
4+
5+
class GetUserGameLeaderboard {
6+
7+
data class Response(
8+
9+
@SerializedName("Count")
10+
val count: Int,
11+
12+
@SerializedName("Total")
13+
val total: Int,
14+
15+
@SerializedName("Results")
16+
val results: List<Result>
17+
) {
18+
data class Result(
19+
20+
@SerializedName("ID")
21+
val id: Int,
22+
23+
@SerializedName("RankAsc")
24+
val rankAsc: Boolean,
25+
26+
@SerializedName("Title")
27+
val title: String,
28+
29+
@SerializedName("Description")
30+
val description: String,
31+
32+
@SerializedName("Format")
33+
val format: String,
34+
35+
@SerializedName("UserEntry")
36+
val userEntry: UserEntry
37+
) {
38+
data class UserEntry(
39+
40+
@SerializedName("User")
41+
val user: String,
42+
43+
@SerializedName("ULID")
44+
val ulid: String,
45+
46+
@SerializedName("Score")
47+
val score: Int,
48+
49+
@SerializedName("FormattedScore")
50+
val formattedScore: String,
51+
52+
@SerializedName("Rank")
53+
val rank: Int,
54+
55+
@SerializedName("DateUpdated")
56+
val dateUpdated: String
57+
)
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)