kotlin-client.libraries.jvm-okhttp.infrastructure.ApiResponse.kt.mustache Maven / Gradle / Ivy
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)