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

commonMain.com.bselzer.gw2.v2.client.instance.CurrencyClient.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.currency.Currency
import com.bselzer.gw2.v2.model.currency.CurrencyId
import io.ktor.client.*

/**
 * The currency client.
 * @see the wiki
 */
class CurrencyClient(httpClient: HttpClient, configuration: Gw2ClientConfiguration) : BaseClient(httpClient, configuration) {
    private companion object {
        const val CURRENCIES = "currencies"
    }

    /**
     * @return the ids of the available currencies
     * @see the wiki
     */
    suspend fun ids(): List = getIds(path = CURRENCIES)

    /**
     * @return the currency associated with the [id]
     * @see the wiki
     */
    suspend fun currency(id: CurrencyId, language: Language? = null): Currency = getSingleById(id, CURRENCIES, { Currency(id = it) }) {
        language(language)
    }

    /**
     * @return the currencies associated with the [ids]
     * @see the wiki
     */
    suspend fun currencies(ids: Collection, language: Language? = null): List = chunkedIds(ids, CURRENCIES, instance = { Currency(id = it) }) {
        language(language)
    }

    /**
     * @return all the currencies
     * @see the wiki
     */
    suspend fun currencies(language: Language? = null): List = allIds(CURRENCIES) {
        language(language)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy