Skip to content

Commit 45d397d

Browse files
committed
chore(flipcash): update protos to bring in preferred on ramp provider
Signed-off-by: Brandon McAnsh <[email protected]>
1 parent c6e5321 commit 45d397d

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

definitions/flipcash/protos/src/main/proto/account/v1/flipcash_account_service.proto

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ message UserFlags {
7171
bool is_staff = 2;
7272
// Does this user require IAP for registration in the account creation flow?
7373
bool requires_iap_for_registration = 3;
74-
// The set of supported on ramp providers for the user, based on their platform
75-
// and locale if provided
76-
repeated OnRampProvider supported_on_ramp_providers = 4 ;
7774
enum OnRampProvider {
7875
UNKNOWN = 0;
7976
COINBASE_VIRTUAL = 1;
@@ -82,4 +79,11 @@ message UserFlags {
8279
CRYPTO_WALLET = 4;
8380
PHANTOM = 5;
8481
}
82+
// The set of supported on ramp providers for the user, based on their platform
83+
// and locale if provided
84+
repeated OnRampProvider supported_on_ramp_providers = 4 ;
85+
86+
// The preferred on ramp provider for this user. If the value is UNKNOWN, client
87+
// should show the list of all supported providers.
88+
OnRampProvider preferred_on_ramp_provider = 5;
8589
}

services/flipcash/src/main/kotlin/com/flipcash/services/internal/domain/UserFlagsMapper.kt

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,21 @@ internal class UserFlagsMapper @Inject constructor():
1414
isRegistered = from.isRegisteredAccount,
1515
isStaff = from.isStaff,
1616
requiresIapForRegistration = from.requiresIapForRegistration,
17-
supportedOnRampProviders = from.supportedOnRampProvidersList.map {
18-
when (val ramp = it) {
19-
FlipcashAccountService.UserFlags.OnRampProvider.COINBASE_VIRTUAL -> OnRampProvider.Coinbase(OnRampType.Virtual)
20-
FlipcashAccountService.UserFlags.OnRampProvider.COINBASE_PHYSICAL_DEBIT -> OnRampProvider.Coinbase(OnRampType.PhysicalDebit)
21-
FlipcashAccountService.UserFlags.OnRampProvider.COINBASE_PHYSICAL_CREDIT -> OnRampProvider.Coinbase(OnRampType.PhysicalCredit)
22-
FlipcashAccountService.UserFlags.OnRampProvider.CRYPTO_WALLET -> OnRampProvider.CryptoDeposit
23-
FlipcashAccountService.UserFlags.OnRampProvider.PHANTOM -> OnRampProvider.Phantom
17+
preferredOnRampProvider = from.preferredOnRampProvider.toDomain().takeIf { it != OnRampProvider.Unknown },
18+
supportedOnRampProviders = from.supportedOnRampProvidersList.map { it.toDomain() },
19+
)
20+
}
21+
}
22+
23+
private fun FlipcashAccountService.UserFlags.OnRampProvider.toDomain(): OnRampProvider {
24+
return when (this) {
25+
FlipcashAccountService.UserFlags.OnRampProvider.COINBASE_VIRTUAL -> OnRampProvider.Coinbase(OnRampType.Virtual)
26+
FlipcashAccountService.UserFlags.OnRampProvider.COINBASE_PHYSICAL_DEBIT -> OnRampProvider.Coinbase(OnRampType.PhysicalDebit)
27+
FlipcashAccountService.UserFlags.OnRampProvider.COINBASE_PHYSICAL_CREDIT -> OnRampProvider.Coinbase(OnRampType.PhysicalCredit)
28+
FlipcashAccountService.UserFlags.OnRampProvider.CRYPTO_WALLET -> OnRampProvider.CryptoDeposit
29+
FlipcashAccountService.UserFlags.OnRampProvider.PHANTOM -> OnRampProvider.Phantom
2430

25-
FlipcashAccountService.UserFlags.OnRampProvider.UNKNOWN,
26-
FlipcashAccountService.UserFlags.OnRampProvider.UNRECOGNIZED -> OnRampProvider.Unknown
27-
}
28-
}
29-
).also { println(it) }
31+
FlipcashAccountService.UserFlags.OnRampProvider.UNKNOWN,
32+
FlipcashAccountService.UserFlags.OnRampProvider.UNRECOGNIZED -> OnRampProvider.Unknown
3033
}
3134
}

services/flipcash/src/main/kotlin/com/flipcash/services/internal/model/account/UserFlags.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ data class UserFlags(
66
val isStaff: Boolean,
77
val isRegistered: Boolean,
88
val requiresIapForRegistration: Boolean,
9+
val preferredOnRampProvider: OnRampProvider?,
910
val supportedOnRampProviders: List<OnRampProvider>,
1011
)

0 commit comments

Comments
 (0)