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

commonMain.com.bselzer.gw2.v2.client.instance.ProfessionClient.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.profession.Profession
import com.bselzer.gw2.v2.model.profession.ProfessionId
import io.ktor.client.*

/**
 * The profession client.
 * @see the wiki
 */
class ProfessionClient(httpClient: HttpClient, configuration: Gw2ClientConfiguration) : BaseClient(httpClient, configuration) {
    private companion object {
        const val PROFESSIONS = "professions"

    }

    /**
     * @return the ids of the available professions
     * @see the wiki
     */
    suspend fun ids(): List = getList(path = PROFESSIONS)

    /**
     * @return the profession associated with the [id]
     * @see the wiki
     */
    suspend fun profession(id: ProfessionId, language: Language? = null): Profession = getSingleById(id, PROFESSIONS, instance = { Profession(id = it) }) {
        language(language)
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy