1+ @file:OptIn(ExperimentalSerializationApi ::class )
2+
13package org.sinytra.probe.base
24
35import kotlinx.datetime.LocalDateTime
6+ import kotlinx.serialization.ExperimentalSerializationApi
7+ import kotlinx.serialization.SerialName
48import kotlinx.serialization.Serializable
9+ import kotlinx.serialization.json.JsonClassDiscriminator
510import org.sinytra.probe.base.db.ProjectPlatform
611
12+
713@Serializable
814data class TestRequestBody (
915 val platform : ProjectPlatform ,
1016 val id : String ,
1117 val gameVersion : String
1218)
1319
14- interface ResponseBase {
20+ @Serializable
21+ @JsonClassDiscriminator(" type" )
22+ sealed interface TestResponseBody {
1523 val project: TestProjectDTO
1624 val type: ResultType
25+
26+ @Serializable
27+ data class Tested (
28+ val modid : String? ,
29+ val versionNumber : String? ,
30+ val versionId : String? ,
31+ val passing : Boolean ,
32+
33+ val environment : TestEnvironmentDTO ,
34+ val createdAt : LocalDateTime ,
35+
36+ override val project : TestProjectDTO ,
37+ override val type : ResultType = ResultType .TESTED
38+ ) : TestResponseBody
39+
40+ @Serializable
41+ data class Unavailable (
42+ val loader : String ,
43+ val gameVersion : String ,
44+
45+ override val project : TestProjectDTO ,
46+ override val type : ResultType = ResultType .UNAVAILABLE
47+ ) : TestResponseBody
48+
49+ @Serializable
50+ data class Skipped (
51+ val gameVersion : String ,
52+
53+ override val project : TestProjectDTO ,
54+ override val type : ResultType = ResultType .NATIVE
55+ ) : TestResponseBody
1756}
1857
1958@Serializable
2059enum class ResultType {
60+ @SerialName(" tested" )
2161 TESTED ,
62+ @SerialName(" native" )
2263 NATIVE ,
64+ @SerialName(" unavailable" )
2365 UNAVAILABLE
2466}
2567
@@ -34,40 +76,9 @@ data class TestProjectDTO(
3476 val platform : ProjectPlatform
3577)
3678
37- @Serializable
38- data class UnavailableResponseBody (
39- val loader : String ,
40- val gameVersion : String ,
41-
42- override val project : TestProjectDTO ,
43- override val type : ResultType
44- ) : ResponseBase
45-
4679@Serializable
4780data class TestEnvironmentDTO (
4881 val connectorVersion : String ,
4982 val gameVersion : String ,
5083 val neoforgeVersion : String
51- )
52-
53- @Serializable
54- data class TestResponseBody (
55- val modid : String? ,
56- val versionNumber : String? ,
57- val versionId : String? ,
58- val passing : Boolean ,
59-
60- val environment : TestEnvironmentDTO ,
61- val createdAt : LocalDateTime ,
62-
63- override val project : TestProjectDTO ,
64- override val type : ResultType
65- ) : ResponseBase
66-
67- @Serializable
68- data class SkippedResponseBody (
69- val gameVersion : String ,
70-
71- override val project : TestProjectDTO ,
72- override val type : ResultType
73- ) : ResponseBase
84+ )
0 commit comments