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

commonMain.com.bselzer.gw2.v2.client.instance.MasteryClient.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.mastery.Mastery
import com.bselzer.gw2.v2.model.mastery.MasteryId
import io.ktor.client.*

/**
 * The mastery client.
 * @see the wiki
 */
class MasteryClient(httpClient: HttpClient, configuration: Gw2ClientConfiguration) : BaseClient(httpClient, configuration) {
    private companion object {
        const val MASTERIES = "masteries"
    }

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

    /**
     * @return the mastery associated with the [id]
     * @see the wiki
     */
    suspend fun mastery(id: MasteryId, language: Language? = null): Mastery = getSingleById(id, MASTERIES, instance = { Mastery(id = it) }) {
        language(language)
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy