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

commonMain.com.bselzer.gw2.v2.client.instance.WorldClient.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.world.World
import com.bselzer.gw2.v2.model.world.WorldId
import io.ktor.client.*

/**
 * The world client.
 * @see the wiki
 */
class WorldClient(httpClient: HttpClient, configuration: Gw2ClientConfiguration) : BaseClient(httpClient, configuration) {
    private companion object {
        const val WORLDS = "worlds"
    }

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

    /**
     * @return the world associated with the [id]
     * @see the wiki
     */
    suspend fun world(id: WorldId, language: Language? = null): World = getSingleById(id, WORLDS, instance = { World(id = it) }) {
        language(language)
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy