commonMain.com.bselzer.gw2.v2.client.instance.TraitClient.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.trait.Trait
import com.bselzer.gw2.v2.model.trait.TraitId
import io.ktor.client.*
/**
* The trait client.
* the wiki
*/
class TraitClient(httpClient: HttpClient, configuration: Gw2ClientConfiguration) : BaseClient(httpClient, configuration) {
private companion object {
const val TRAITS = "traits"
}
/**
* @return the ids of the available traits
* @see the wiki
*/
suspend fun ids(): List = getIds(path = TRAITS)
/**
* @return the trait associated with the [id]
* @see the wiki
*/
suspend fun trait(id: TraitId, language: Language? = null): Trait = getSingleById(id, TRAITS, instance = { Trait(id = it) }) {
language(language)
}
/**
* @return the traits associated with the [ids]
* @see the wiki
*/
suspend fun traits(ids: Collection, language: Language? = null): List = chunkedIds(ids, TRAITS, instance = { Trait(id = it) }) {
language(language)
}
/**
* @return all the traits
* @see the wiki
*/
suspend fun traits(language: Language? = null): List = allIds(TRAITS) {
language(language)
}
}