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

commonMain.com.bselzer.gw2.v2.client.instance.LegendClient.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.legend.Legend
import com.bselzer.gw2.v2.model.legend.LegendId
import io.ktor.client.*

/**
 * The legend client. For Revenants.
 * @see the wiki
 */
class LegendClient(httpClient: HttpClient, configuration: Gw2ClientConfiguration) : BaseClient(httpClient, configuration) {
    private companion object {
        const val LEGENDS = "legends"
    }

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

    /**
     * @return the legend associated with the [id]
     * @see the wiki
     */
    suspend fun legend(id: LegendId, language: Language? = null): Legend = getSingleById(id, LEGENDS, instance = { Legend(id = it) }) {
        language(language)
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy