Add page specifier
This commit is contained in:
parent
c01752b5d9
commit
dc9124cd2e
2 changed files with 38 additions and 2 deletions
|
@ -4,10 +4,11 @@ import de.pheerai.rcdbquery.dataMappings.*
|
|||
import de.pheerai.rcdbquery.dsl.*
|
||||
|
||||
fun main() {
|
||||
print(generateQueryUrl())
|
||||
println(generateNameQueryUrl())
|
||||
println(generatePageQueryUrl())
|
||||
}
|
||||
|
||||
fun generateQueryUrl() = rcdbQuery {
|
||||
fun generateNameQueryUrl() = rcdbQuery {
|
||||
searchType(SearchType.COASTER)
|
||||
searchTerm("Dragon")
|
||||
vendors {
|
||||
|
@ -21,3 +22,11 @@ fun generateQueryUrl() = rcdbQuery {
|
|||
inversion()
|
||||
}
|
||||
}
|
||||
|
||||
fun generatePageQueryUrl() = rcdbQuery {
|
||||
page(3)
|
||||
searchType(SearchType.COASTER)
|
||||
vendors {
|
||||
intamin()
|
||||
}
|
||||
}
|
||||
|
|
27
src/main/kotlin/de/pheerai/rcdbquery/dataMappings/Page.kt
Normal file
27
src/main/kotlin/de/pheerai/rcdbquery/dataMappings/Page.kt
Normal file
|
@ -0,0 +1,27 @@
|
|||
package de.pheerai.rcdbquery.dataMappings
|
||||
|
||||
import de.pheerai.rcdbquery.dsl.RcdbQueryParamsBuilder
|
||||
|
||||
class Page(override val paramValue: Int) : RcdbParamOption<Int> {
|
||||
override val fullName: String
|
||||
get() = "The page to show"
|
||||
override val prettyName: String
|
||||
get() = "Page"
|
||||
|
||||
companion object {
|
||||
const val staticParamName = "page"
|
||||
}
|
||||
}
|
||||
|
||||
fun RcdbQueryParamsBuilder.page(page: Int) {
|
||||
if (Page.staticParamName !in this.keys()) {
|
||||
this[Page.staticParamName] = listOf(Page(page))
|
||||
} else {
|
||||
error(
|
||||
"""Only one page must be given!
|
||||
| Old page: ${this[Page.staticParamName]!![0].paramValue}
|
||||
| New page: $page
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue