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

commonMain.com.bselzer.gw2.v2.client.instance.DungeonClient.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.dungeon.Dungeon
import com.bselzer.gw2.v2.model.dungeon.DungeonId
import io.ktor.client.*

/**
 * The dungeon client.
 * @see the wiki
 */
class DungeonClient(httpClient: HttpClient, configuration: Gw2ClientConfiguration) : BaseClient(httpClient, configuration) {
    private companion object {
        const val DUNGEONS = "dungeons"
    }

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

    /**
     * @return the dungeon associated with the [id]
     * @see the wiki
     */
    suspend fun dungeon(id: DungeonId, language: Language? = null): Dungeon = getSingleById(id, DUNGEONS, instance = { Dungeon(id = it) }) {
        language(language)
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy