commonMain.com.javiersc.resources.networkResponse.NetworkResponse.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of network-response-jvm Show documentation
Show all versions of network-response-jvm Show documentation
NetworkResponse multiplatform
package com.javiersc.resources.networkResponse
import kotlinx.serialization.Serializable
import kotlinx.serialization.ContextualSerialization as CS
@Serializable
sealed class NetworkResponse {
@Serializable
data class Info(
val code: Int,
val headers: Headers,
) : NetworkResponse<@CS Nothing, @CS Nothing>()
@Serializable
data class Success(
val data: NR,
val code: Int,
val headers: Headers,
) : NetworkResponse() {
data class Empty(
val code: Int,
val headers: Headers,
) : NetworkResponse<@CS Nothing, @CS Nothing>()
}
@Serializable
data class Redirection(
val code: Int,
val headers: Headers,
) : NetworkResponse<@CS Nothing, @CS Nothing>()
@Serializable
data class ClientError(
val error: E? = null,
val code: Int,
val headers: Headers,
) : NetworkResponse<@CS Nothing, E>()
@Serializable
data class ServerError(
val error: E? = null,
val code: Int,
val headers: Headers,
) : NetworkResponse<@CS Nothing, E>()
@Serializable
data class InternetNotAvailable(val error: String) : NetworkResponse<@CS Nothing, @CS Nothing>()
}
typealias Headers = Map>