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

commonMain.com.bselzer.gw2.v2.client.instance.MaterialClient.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.material.Material
import com.bselzer.gw2.v2.model.material.MaterialId
import io.ktor.client.*

/**
 * The material client.
 * @see the wiki
 */
class MaterialClient(httpClient: HttpClient, configuration: Gw2ClientConfiguration) : BaseClient(httpClient, configuration) {
    private companion object {
        const val MATERIALS = "materials"
    }

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

    /**
     * @return the material associated with the [id]
     * @see the wiki
     */
    suspend fun material(id: MaterialId, language: Language? = null): Material = getSingleById(id, MATERIALS, instance = { Material(id = it) }) {
        language(language)
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy