commonMain.com.bselzer.gw2.v2.client.instance.TitleClient.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of v2-client Show documentation
Show all versions of v2-client Show documentation
Ktor client for v2 endpoints of the Guild Wars 2 API.
The newest version!
package com.bselzer.gw2.v2.client.instance
import com.bselzer.gw2.v2.client.extension.language
import com.bselzer.gw2.v2.client.model.Language
import com.bselzer.gw2.v2.model.title.Title
import com.bselzer.gw2.v2.model.title.TitleId
import io.ktor.client.*
/**
* The title client.
* the wiki
*/
class TitleClient(httpClient: HttpClient, configuration: Gw2ClientConfiguration) : BaseClient(httpClient, configuration) {
private companion object {
const val TITLES = "titles"
}
/**
* @return the ids of the available titles
* @see the wiki
*/
suspend fun ids(): List = getIds(path = TITLES)
/**
* @return the title associated with the [id]
* @see the wiki
*/
suspend fun title(id: TitleId, language: Language? = null): Title = getSingleById(id, TITLES, instance = { Title(id = it) }) {
language(language)
}
/**
* @return the titles associated with the [ids]
* @see the wiki
*/
suspend fun titles(ids: Collection, language: Language? = null): List = chunkedIds(ids, TITLES, instance = { Title(id = it) }) {
language(language)
}
/**
* @return all the titles
* @see the wiki
*/
suspend fun titles(language: Language? = null): List = allIds(TITLES) {
language(language)
}
}