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.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>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy