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

commonMain.org.jellyfin.sdk.api.client.Response.kt Maven / Gradle / Ivy

There is a newer version: 1.6.3
Show newest version
package org.jellyfin.sdk.api.client

import kotlin.jvm.JvmSynthetic
import kotlin.reflect.KProperty

/**
 * Response from a HTTP class in the [ApiClient].
 */
public class Response(
	public val content: T,
	public val status: Int,
	public val headers: Map>,
) {
	/**
	 * Get the response content using property delegation.
	 *
	 * ```kt
	 * val content by response
	 * ```
	 */
	@JvmSynthetic
	public operator fun getValue(thisRef: Any?, property: KProperty<*>): T = content

	/**
	 * Get a header by name. If multiple headers with the name exist the first is returned.
	 * Use [getHeaders] to get all headers with [name].
	 */
	public fun getHeader(name: String): String? = getHeaders(name).firstOrNull()

	/**
	 * Get multiple headers sharing the same name. Use [getHeader] to retrieve the first occurrence.
	 */
	public fun getHeaders(name: String): List = headers[name].orEmpty()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy