Skip to content

Instantly share code, notes, and snippets.

@lucapiccinelli
Last active December 18, 2020 21:44
Show Gist options
  • Save lucapiccinelli/f5e4957aeb88cf4e4f4baa012ae77bfb to your computer and use it in GitHub Desktop.
Save lucapiccinelli/f5e4957aeb88cf4e4f4baa012ae77bfb 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): BuyCryptoInfo? = with(user){
if(phoneNumber != null && creditCard != null && kycVerification != null)
BuyCryptoInfo(username, phoneNumber, creditCard, kycVerification)
else null
}
fun from2(user: CryptoUser): BuyCryptoInfo? = with(user){
phoneNumber?.let {
creditCard?.let {
kycVerification?.let {
BuyCryptoInfo(username, phoneNumber, creditCard, kycVerification)
}}}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment