package com.qimai.android.fetch.Response

/**
@author wangwei

@version 1.1.1
@date 2019-08-19
@Description
@email wangwei_5521@163.com
 **/
data class Resource<out T>(val status: Status, val data: T? = null, val message: String? = null,val errorData:ErrorData? = null) {
    companion object {
        fun <T> success(data: T?): Resource<T> {
            return Resource(
                Status.SUCCESS,
                data,
                null
            )
        }

        fun <T> error(msg: String? = null, errData: ErrorData? = null): Resource<T> {
            return Resource(
                Status.ERROR,
                message = msg,
                errorData = errData,
            )
        }

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