Updated on 2026-08-14

This commit is contained in:
Tangem 2026-01-26 21:41:59 +07:00
commit eb9eed8d6c
43 changed files with 1296 additions and 131 deletions

View file

@ -0,0 +1,3 @@
package com.tangem.domain.wallets.models
data class AppsFlyerConversionData(val refcode: String, val campaign: String?)

View file

@ -0,0 +1,10 @@
package com.tangem.domain.wallets.repository
import com.tangem.domain.wallets.models.AppsFlyerConversionData
interface WalletsPromoRepository {
suspend fun bindRefcodeWithWallets(conversionData: AppsFlyerConversionData)
suspend fun retryBindRefcodeWithWallets()
}

View file

@ -0,0 +1,35 @@
package com.tangem.domain.wallets.usecase
import arrow.core.Either
import arrow.core.raise.catch
import arrow.core.raise.either
import com.tangem.domain.wallets.models.AppsFlyerConversionData
import com.tangem.domain.wallets.repository.WalletsPromoRepository
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import javax.inject.Inject
class BindRefcodeWithWalletUseCase @Inject constructor(
private val walletsPromoRepository: WalletsPromoRepository,
) {
private val mutex = Mutex()
suspend operator fun invoke(conversionData: AppsFlyerConversionData): Either<Throwable, Unit> = either {
mutex.withLock {
catch(
block = { walletsPromoRepository.bindRefcodeWithWallets(conversionData) },
catch = ::raise,
)
}
}
suspend fun retry(): Either<Throwable, Unit> = either {
mutex.withLock {
catch(
block = { walletsPromoRepository.retryBindRefcodeWithWallets() },
catch = ::raise,
)
}
}
}