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

commonMain.com.bselzer.gw2.v2.client.instance.MailCarrierClient.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.mailcarrier.MailCarrier
import com.bselzer.gw2.v2.model.mailcarrier.MailCarrierId
import io.ktor.client.*

/**
 * The mail carrier client.
 * @see the wiki
 */
class MailCarrierClient(httpClient: HttpClient, configuration: Gw2ClientConfiguration) : BaseClient(httpClient, configuration) {
    private companion object {
        const val MAIL_CARRIERS = "mailcarriers"
    }

    /**
     * @return the ids of the available mail carriers
     * @see the wiki
     */
    suspend fun ids(): List = getIds(path = MAIL_CARRIERS)

    /**
     * @return the mail carrier associated with the [id]
     * @see the wiki
     */
    suspend fun mailCarrier(id: MailCarrierId, language: Language? = null): MailCarrier = getSingleById(id, MAIL_CARRIERS, instance = { MailCarrier(id = it) }) {
        language(language)
    }

    /**
     * @return the mail carriers associated with the [ids]
     * @see the wiki
     */
    suspend fun mailCarriers(ids: Collection, language: Language? = null): List =
        chunkedIds(ids, MAIL_CARRIERS, instance = { MailCarrier(id = it) }) {
            language(language)
        }

    /**
     * @return all the mail carriers
     * @see the wiki
     */
    suspend fun mailCarriers(language: Language? = null): List = allIds(MAIL_CARRIERS) {
        language(language)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy