commonMain.com.bselzer.gw2.v2.emblem.extension.HttpRequestBuilder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of v2-emblem-jvm Show documentation
Show all versions of v2-emblem-jvm Show documentation
Guild emblem image fetching from https://emblem.werdes.net/
The newest version!
package com.bselzer.gw2.v2.emblem.extension
import com.bselzer.gw2.v2.emblem.constant.Parameters
import com.bselzer.gw2.v2.emblem.request.EmblemRequestOptions
import io.ktor.client.request.*
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
/**
* Sets the options if the [options] are not empty.
*/
internal fun HttpRequestBuilder.options(options: Collection) {
if (options.isNotEmpty()) {
parameter(Parameters.OPTIONS, options.encodeOptions())
}
}
/**
* Encodes the enum options into a comma separated list of strings.
*/
internal fun Collection.encodeOptions(): String = joinToString(separator = ",") { option -> Json.encodeToString(option) }