All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.bselzer.gw2.v2.client.instance.TraitClient.kt Maven / Gradle / Ivy

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)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy