Updated on 2026-08-14
This commit is contained in:
commit
369ed25ac6
515 changed files with 6100 additions and 12756 deletions
|
|
@ -1,5 +1,7 @@
|
|||
package com.tangem.domain.settings.repositories
|
||||
|
||||
import com.tangem.domain.settings.usercountry.models.UserCountry
|
||||
|
||||
interface SettingsRepository {
|
||||
|
||||
suspend fun shouldShowSaveUserWalletScreen(): Boolean
|
||||
|
|
@ -33,4 +35,8 @@ interface SettingsRepository {
|
|||
suspend fun shouldShowMarketsTooltip(): Boolean
|
||||
|
||||
suspend fun setMarketsTooltipShown(value: Boolean)
|
||||
|
||||
suspend fun getUserCountryCodeSync(): UserCountry?
|
||||
|
||||
suspend fun fetchUserCountryCode()
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.tangem.domain.settings.usercountry
|
||||
|
||||
import arrow.core.Either
|
||||
import arrow.core.raise.catch
|
||||
import arrow.core.raise.either
|
||||
import com.tangem.domain.settings.repositories.SettingsRepository
|
||||
import com.tangem.domain.settings.usercountry.models.UserCountryError
|
||||
|
||||
/**
|
||||
* Fetch user country use case
|
||||
*
|
||||
* @property settingsRepository settings repository
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class FetchUserCountryUseCase(
|
||||
private val settingsRepository: SettingsRepository,
|
||||
) {
|
||||
|
||||
suspend operator fun invoke(): Either<UserCountryError, Unit> {
|
||||
return either {
|
||||
catch(
|
||||
block = { settingsRepository.fetchUserCountryCode() },
|
||||
catch = { raise(UserCountryError.DataError) },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.tangem.domain.settings.usercountry
|
||||
|
||||
import arrow.core.Either
|
||||
import arrow.core.raise.catch
|
||||
import arrow.core.raise.either
|
||||
import arrow.core.raise.ensureNotNull
|
||||
import com.tangem.domain.settings.repositories.SettingsRepository
|
||||
import com.tangem.domain.settings.usercountry.models.UserCountry
|
||||
import com.tangem.domain.settings.usercountry.models.UserCountryError
|
||||
|
||||
/**
|
||||
* Get user country code use case
|
||||
*
|
||||
* @property settingsRepository settings repository
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class GetUserCountryUseCase(
|
||||
private val settingsRepository: SettingsRepository,
|
||||
) {
|
||||
|
||||
suspend operator fun invoke(): Either<UserCountryError, UserCountry> {
|
||||
return either {
|
||||
val userCountryCode = catch(
|
||||
block = { settingsRepository.getUserCountryCodeSync() },
|
||||
catch = { raise(UserCountryError.DataError) },
|
||||
)
|
||||
|
||||
ensureNotNull(userCountryCode) { UserCountryError.NotSetup }
|
||||
|
||||
userCountryCode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.tangem.domain.settings.usercountry.models
|
||||
|
||||
/**
|
||||
* User country
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
sealed class UserCountry(open val code: String) {
|
||||
|
||||
data object Russia : UserCountry("ru")
|
||||
|
||||
data class Other(override val code: String) : UserCountry(code)
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.tangem.domain.settings.usercountry.models
|
||||
|
||||
/**
|
||||
* User country error
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
sealed interface UserCountryError {
|
||||
|
||||
/** User country is still loading */
|
||||
data object NotSetup : UserCountryError
|
||||
|
||||
/** Data error */
|
||||
data object DataError : UserCountryError
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue