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

commonMain.com.bselzer.gw2.v2.client.instance.NoveltyClient.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.novelty.Novelty
import com.bselzer.gw2.v2.model.novelty.NoveltyId
import io.ktor.client.*

/**
 * The novelty client.
 * @see the wiki
 */
class NoveltyClient(httpClient: HttpClient, configuration: Gw2ClientConfiguration) : BaseClient(httpClient, configuration) {
    private companion object {
        const val NOVELTIES = "novelties"
    }

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

    /**
     * @return the novelty associated with the [id]
     * @see the wiki
     */
    suspend fun novelty(id: NoveltyId, language: Language? = null): Novelty = getSingleById(id, NOVELTIES, instance = { Novelty(id = it) }) {
        language(language)
    }

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy