Last active
December 18, 2020 21:47
-
-
Save lucapiccinelli/87f9fa914a20c22bf70ee9ca95260fc1 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
sealed class Result<out T>{ | |
data class Ok<out T>(val value: T): Result<T>() | |
data class Error(val description: String): Result<Nothing>() | |
} | |
data class BuyCryptoInfo( | |
val username: String, | |
val phoneNumber: PhoneNumber, | |
val creditCard: CreditCard, | |
val kycVerification: KycVerificationData){ | |
companion object{ | |
fun from1(user: CryptoUser): Result<BuyCryptoInfo> = with(user){ | |
if(phoneNumber == null) return Result.Error("missing phone number") | |
if(creditCard == null) return Result.Error("missing credit card") | |
if(kycVerification == null) return Result.Error("missing kyc verification") | |
return Result.Ok(BuyCryptoInfo(username, phoneNumber, creditCard, kycVerification)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment