package com.develop.common.utils

data class Resource<T>(
    val data: T?,
    val status: Status
) {

    enum class Status {
        LOADING,
        SUCCESS,
        FAILURE
    }

    companion object {

        fun <T> success(data: T?): Resource<T> {
            return Resource(data, Status.SUCCESS)
        }

        fun <T> failure(errorMsg: ErrorMsg): Resource<T> {
            return Resource(errorMsg as T, Status.FAILURE)
        }

        fun <T> loading(): Resource<T> {
            return Resource(null, Status.LOADING)
        }
    }
}

data class ErrorMsg(var code: Int, var desc: String)