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

kotlin-client.libraries.jvm-okhttp.infrastructure.ApiResponse.kt.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
package {{packageName}}.infrastructure

{{#nonPublicApi}}internal {{/nonPublicApi}}enum class ResponseType {
    Success, Informational, Redirection, ClientError, ServerError
}

{{#nonPublicApi}}internal {{/nonPublicApi}}interface Response

{{#nonPublicApi}}internal {{/nonPublicApi}}abstract class ApiResponse(val responseType: ResponseType): Response {
    abstract val statusCode: Int
    abstract val headers: Map>
}

{{#nonPublicApi}}internal {{/nonPublicApi}}class Success(
    val data: T{{#nullableReturnType}}?{{/nullableReturnType}},
    override val statusCode: Int = -1,
    override val headers: Map> = mapOf()
): ApiResponse(ResponseType.Success)

{{#nonPublicApi}}internal {{/nonPublicApi}}class Informational(
    val statusText: String,
    override val statusCode: Int = -1,
    override val headers: Map> = mapOf()
) : ApiResponse(ResponseType.Informational)

{{#nonPublicApi}}internal {{/nonPublicApi}}class Redirection(
    override val statusCode: Int = -1,
    override val headers: Map> = mapOf()
) : ApiResponse(ResponseType.Redirection)

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

{{#nonPublicApi}}internal {{/nonPublicApi}}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