Skip to content

Commit 76edcfb

Browse files
authored
API underpinnings for Image Recommendations, part 2. (#3992)
1 parent 0b0bf5d commit 76edcfb

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

app/src/main/java/org/wikipedia/dataclient/Service.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,11 @@ interface Service {
581581
@Query("pageids") pageIds: String? = null
582582
): MwQueryResponse
583583

584+
@GET(MW_API_PREFIX + "action=paraminfo")
585+
suspend fun getParamInfo(
586+
@Query("modules") modules: String
587+
): ParamInfoResponse
588+
584589
companion object {
585590
const val WIKIPEDIA_URL = "https://wikipedia.org/"
586591
const val WIKIDATA_URL = "https://www.wikidata.org/"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package org.wikipedia.dataclient.mwapi
2+
3+
import kotlinx.serialization.Serializable
4+
import kotlinx.serialization.json.JsonElement
5+
import kotlinx.serialization.json.jsonArray
6+
import kotlinx.serialization.json.jsonPrimitive
7+
8+
@Suppress("unused")
9+
@Serializable
10+
class ParamInfoResponse : MwResponse() {
11+
12+
val paraminfo: ParamInfo? = null
13+
14+
@Serializable
15+
class ParamInfo {
16+
val modules: List<Module> = emptyList()
17+
}
18+
19+
@Serializable
20+
class Module {
21+
val name = ""
22+
val classname = ""
23+
val path = ""
24+
val source = ""
25+
val parameters: List<Parameter> = emptyList()
26+
}
27+
28+
@Serializable
29+
class Parameter {
30+
val index = 0
31+
val name = ""
32+
val required = false
33+
val multi = false
34+
val type: JsonElement? = null
35+
36+
val typeAsString get() = type?.jsonPrimitive?.content.orEmpty()
37+
val typeAsEnum get() = type?.jsonArray?.map { it.jsonPrimitive.content } ?: emptyList()
38+
}
39+
}

0 commit comments

Comments
 (0)