package org.octopus.internal.web.utils.responses

import org.springframework.http.HttpStatus


data class WebResponse<T>(
    val status: HttpStatus,
    val error: String? = null,
    val data: T? = null
) {

    companion object {
        fun ok(): WebResponse<Unit> {
            return WebResponse(status = HttpStatus.OK)
        }

        fun <T> ok(data: T): WebResponse<T> {
            return WebResponse(status = HttpStatus.OK, data = data)
        }

        fun <T> ko(status: HttpStatus, error: String?): WebResponse<T> {
            return WebResponse(status = status, error = error)
        }

        fun <T> ko(status: HttpStatus, errors: List<String>): WebResponse<T> {
            return WebResponse(status = status, error = errors.toString())
        }
    }

}