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

commonMain.com.javiersc.resources.networkResponse.NetworkResponse.kt Maven / Gradle / Ivy

There is a newer version: 0.7.1
Show newest version
package com.javiersc.resources.networkResponse

import kotlinx.serialization.ContextualSerialization
import kotlinx.serialization.Serializable

@Serializable
sealed class NetworkResponse {

    @Serializable
    data class Info(
        val code: Int,
        val headers: Headers,
    ) : NetworkResponse<@ContextualSerialization Nothing, @ContextualSerialization Nothing>()

    @Serializable
    data class Success(
        val data: NR,
        val code: Int,
        val headers: Headers,
    ) : NetworkResponse()

    @Serializable
    data class Redirection(
        val code: Int,
        val headers: Headers,
    ) : NetworkResponse<@ContextualSerialization Nothing, @ContextualSerialization Nothing>()

    @Serializable
    data class ClientError(
        val error: E? = null,
        val code: Int,
        val headers: Headers,
    ) : NetworkResponse<@ContextualSerialization Nothing, E>()

    @Serializable
    data class ServerError(
        val error: E? = null,
        val code: Int,
        val headers: Headers,
    ) : NetworkResponse<@ContextualSerialization Nothing, E>()

    @Serializable
    data class InternetNotAvailable(
        val error: String
    ) : NetworkResponse<@ContextualSerialization Nothing, @ContextualSerialization Nothing>()
}

typealias Headers = Map>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy