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