commonMain.com.bselzer.gw2.v2.client.instance.FileClient.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of v2-client Show documentation
Show all versions of v2-client Show documentation
Ktor client for v2 endpoints of the Guild Wars 2 API.
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)
}