Last active
December 18, 2020 21:50
-
-
Save lucapiccinelli/e099bef88f3975ed25d10beead876138 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
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){ | |
val listOfErrors = mutableListOf<String>() | |
if(phoneNumber == null) listOfErrors.add("missing phone number") | |
if(creditCard == null) listOfErrors.add("missing credit card") | |
if(kycVerification == null) listOfErrors.add("missing kyc verification") | |
if(listOfErrors.size > 0) return Result.Error(listOfErrors.joinToString(",")) | |
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