Skip to content

Instantly share code, notes, and snippets.

@lucapiccinelli
Last active December 18, 2020 21:50
Show Gist options
  • Save lucapiccinelli/e099bef88f3975ed25d10beead876138 to your computer and use it in GitHub Desktop.
Save lucapiccinelli/e099bef88f3975ed25d10beead876138 to your computer and use it in GitHub Desktop.
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