package mtp.polymer.com.autowidget.utils

enum class TaskStatus {
    SUCCESS, FAILURE, IN_FLIGHT, IDLE
}

data class TaskUiModel(val taskStatus: TaskStatus = TaskStatus.IDLE, val msg: CharSequence = "") {
    companion object {
        fun success(msg: CharSequence = "") = TaskUiModel(taskStatus = TaskStatus.SUCCESS, msg = msg)
        fun failed(throwable: Throwable) = TaskUiModel(taskStatus = TaskStatus.FAILURE, msg = throwable.optErrorMessage())
        fun inFlight(msg: CharSequence = "") = TaskUiModel(taskStatus = TaskStatus.IN_FLIGHT, msg = msg)
        fun idel() = TaskUiModel(taskStatus = TaskStatus.IDLE)
    }
}