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

commonMain.com.bselzer.gw2.v2.client.instance.FileClient.kt Maven / Gradle / Ivy

The newest version!
package com.bselzer.gw2.v2.client.instance

import com.bselzer.gw2.v2.model.file.Asset
import com.bselzer.gw2.v2.model.file.AssetId
import io.ktor.client.*

/**
 * The file client for commonly requests in-game assets.
 * @see the wiki
 */
class FileClient(httpClient: HttpClient, configuration: Gw2ClientConfiguration) : BaseClient(httpClient, configuration) {
    private companion object {
        const val FILES = "files"
    }

    /**
     * @return the ids of the commonly requested assets
     * @see the wiki
     */
    suspend fun ids(): List = getIds(path = FILES)

    /**
     * @return the commonly requested asset associated with the [id]
     * @see the wiki
     */
    suspend fun asset(id: AssetId): Asset = getSingleById(id, FILES, instance = { Asset(id = it) })

    /**
     * @return the commonly requested assets associated with the [ids]
     * @see the wiki
     */
    suspend fun assets(ids: Collection): List = chunkedIds(ids, FILES, instance = { Asset(id = it) })

    /**
     * @return all the commonly requests assets
     * @see the wiki
     */
    suspend fun assets(): List = allIds(FILES)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy