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

com.svix.kotlin.internal.infrastructure.ApiInfrastructureResponse.kt Maven / Gradle / Ivy

package com.svix.kotlin.internal.infrastructure

enum class ResponseType {
    Success, Informational, Redirection, ClientError, ServerError
}

interface Response

abstract class ApiInfrastructureResponse(val responseType: ResponseType): Response {
    abstract val statusCode: Int
    abstract val headers: Map>
}

class Success(
    val data: T,
    override val statusCode: Int = -1,
    override val headers: Map> = mapOf()
): ApiInfrastructureResponse(ResponseType.Success)

class Informational(
    val statusText: String,
    override val statusCode: Int = -1,
    override val headers: Map> = mapOf()
) : ApiInfrastructureResponse(ResponseType.Informational)

class Redirection(
    override val statusCode: Int = -1,
    override val headers: Map> = mapOf()
) : ApiInfrastructureResponse(ResponseType.Redirection)

class ClientError(
    val message: String? = null,
    val body: Any? = null,
    override val statusCode: Int = -1,
    override val headers: Map> = mapOf()
) : ApiInfrastructureResponse(ResponseType.ClientError)

class ServerError(
    val message: String? = null,
    val body: Any? = null,
    override val statusCode: Int = -1,
    override val headers: Map>
): ApiInfrastructureResponse(ResponseType.ServerError)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy