commonMain.com.bselzer.gw2.v2.client.instance.MailCarrierClient.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.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)
}
}