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

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

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

import com.bselzer.gw2.v2.model.emblem.Emblem
import com.bselzer.gw2.v2.model.emblem.EmblemId
import io.ktor.client.*

/**
 * The emblem client.
 * @see the wiki
 */
class EmblemClient(httpClient: HttpClient, configuration: Gw2ClientConfiguration) : BaseClient(httpClient, configuration) {
    private companion object {
        const val EMBLEM = "emblem"
        const val FOREGROUNDS = "foregrounds"
        const val BACKGROUNDS = "backgrounds"
    }

    /**
     * @return the ids of the available foreground emblems
     * @see the wiki
     */
    suspend fun foregroundEmblemIds(): List = getIds(path = "${EMBLEM}/${FOREGROUNDS}")

    /**
     * @return the foreground emblem associated with the [id]
     * @see the wiki
     */
    suspend fun foregroundEmblem(id: EmblemId): Emblem = getSingleById(id, "${EMBLEM}/${FOREGROUNDS}", instance = { Emblem(id = it) })

    /**
     * @return the foreground emblems associated with the [ids]
     * @see the wiki
     */
    suspend fun foregroundEmblems(ids: Collection): List = chunkedIds(ids, "${EMBLEM}/${FOREGROUNDS}", instance = { Emblem(id = it) })

    /**
     * @return all the foreground emblems
     * @see the wiki
     */
    suspend fun foregroundEmblems(): List = allIds("${EMBLEM}/${FOREGROUNDS}")

    /**
     * @return the ids of the available background emblems
     * @see the wiki
     */
    suspend fun backgroundEmblemIds(): List = getIds(path = "${EMBLEM}/${BACKGROUNDS}")

    /**
     * @return the background emblem associated with the [id]
     * @see the wiki
     */
    suspend fun backgroundEmblem(id: EmblemId): Emblem = getSingleById(id, "${EMBLEM}/${BACKGROUNDS}", instance = { Emblem(id = it) })

    /**
     * @return the background emblems associated with the [ids]
     * @see the wiki
     */
    suspend fun backgroundEmblems(ids: Collection): List = chunkedIds(ids, "${EMBLEM}/${BACKGROUNDS}", instance = { Emblem(id = it) })

    /**
     * @return all the background emblems
     * @see the wiki
     */
    suspend fun backgroundEmblems(): List = allIds("${EMBLEM}/${BACKGROUNDS}")
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy