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

commonMain.com.bselzer.gw2.v2.client.instance.QuestClient.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.quest.Quest
import com.bselzer.gw2.v2.model.quest.QuestId
import io.ktor.client.*

/**
 * The quest client.
 * @see the wiki
 */
class QuestClient(httpClient: HttpClient, configuration: Gw2ClientConfiguration) : BaseClient(httpClient, configuration) {
    private companion object {
        const val QUESTS = "quests"
    }

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

    /**
     * @return the quest associated with the [id]
     * @see the wiki
     */
    suspend fun quest(id: QuestId, language: Language? = null): Quest = getSingleById(id, QUESTS, instance = { Quest(id = it) }) {
        language(language)
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy