Last active
December 10, 2021 17:20
-
-
Save Kashif-E/7a7cbac2603435840ef6b0c20f3835be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A generic class that holds a value with its loading status. | |
* @param <T> | |
</T> */ | |
sealed class Resource<T>( | |
val data: T? = null, | |
val error : CustomMessages= CustomMessages.SomethingWentWrong("Something Went Wrong") | |
) { | |
class Success<T>(data: T?) : Resource<T>(data) | |
class Loading<T> : Resource<T>() | |
class Error<T>(customMessages: CustomMessages):Resource<T>(error = customMessages) | |
sealed class CustomMessages(val message: String="") { | |
object BusinessDetailsUpdatedSuccessfully: CustomMessages() | |
object EmptyOtp: CustomMessages() | |
object InvalidOtp : CustomMessages() | |
object NetworkError : CustomMessages() | |
object InvalidInput : CustomMessages() | |
object InvalidPhoneNumber : CustomMessages() | |
object Timeout : CustomMessages() | |
object EmailEmpty: CustomMessages() | |
object PasswordEmpty : CustomMessages() | |
object emptyName: CustomMessages() | |
object ServerBusy : CustomMessages() | |
object PhoneNumberLengthError : CustomMessages() | |
object InputEmptyError : CustomMessages() | |
object HttpException : CustomMessages() | |
object SocketTimeOutException : CustomMessages() | |
object NoInternet : CustomMessages() | |
object Unauthorized : CustomMessages() | |
object InternalServerError : CustomMessages() | |
object BadRequest : CustomMessages() | |
object Conflict : CustomMessages() | |
object NotFound : CustomMessages() | |
object NotAcceptable : CustomMessages() | |
object ServiceUnavailable : CustomMessages() | |
object Forbidden : CustomMessages() | |
object SignupSuccessfull : CustomMessages() | |
object LoginSuccessfull : CustomMessages() | |
object MakeAndYearSelect: CustomMessages() | |
object NoModelFound : CustomMessages() | |
data class SomethingWentWrong(val error: String) : CustomMessages(message = error) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment