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

ru.testit.kotlin.client.infrastructure.ApiResponse.kt Maven / Gradle / Ivy

There is a newer version: 0.2.0
Show newest version
package ru.testit.kotlin.client.infrastructure

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

interface Response

abstract class ApiResponse(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()
): ApiResponse(ResponseType.Success)

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

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy