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

commonMain.com.bselzer.gw2.v2.client.instance.ItemStatClient.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.itemstat.ItemStat
import com.bselzer.gw2.v2.model.itemstat.ItemStatId
import io.ktor.client.*

/**
 * The item stat client.
 * the wiki
 */
class ItemStatClient(httpClient: HttpClient, configuration: Gw2ClientConfiguration) : BaseClient(httpClient, configuration) {
    private companion object {
        const val ITEM_STATS = "itemstats"
    }

    /**
     * @return the ids of the available item stats
     * @see the wiki
     */
    suspend fun ids(): List = getIds(path = ITEM_STATS)

    /**
     * @return the item stat associated with the [id]
     * @see the wiki
     */
    suspend fun itemStat(id: ItemStatId, language: Language? = null): ItemStat = getSingleById(id, ITEM_STATS, instance = { ItemStat(id = it) }) {
        language(language)
    }

    /**
     * @return the item stats associated with the [ids]
     * @see the wiki
     */
    suspend fun itemStats(ids: Collection, language: Language? = null): List = chunkedIds(ids, ITEM_STATS, instance = { ItemStat(id = it) }) {
        language(language)
    }

    /**
     * @return all the item stats
     * @see the wiki
     */
    suspend fun itemStats(language: Language? = null): List = allIds(ITEM_STATS) {
        language(language)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy