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

commonMain.com.bselzer.gw2.v2.client.instance.GliderClient.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.glider.Glider
import com.bselzer.gw2.v2.model.glider.GliderId
import io.ktor.client.*

/**
 * The glider client.
 * @see the wiki
 */
class GliderClient(httpClient: HttpClient, configuration: Gw2ClientConfiguration) : BaseClient(httpClient, configuration) {
    private companion object {
        const val GLIDERS = "gliders"
    }

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

    /**
     * @return the glider associated with the [id]
     * @see the wiki
     */
    suspend fun glider(id: GliderId, language: Language? = null): Glider = getSingleById(id, GLIDERS, instance = { Glider(id = it) }) {
        language(language)
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy