Updated on 2026-08-14

This commit is contained in:
Tangem 2025-04-28 16:08:31 +05:00
parent a0f6e4a008
commit 6c8b59c569
12 changed files with 288 additions and 66 deletions

View file

@ -1,17 +1,31 @@
plugins {
alias(deps.plugins.kotlin.jvm)
alias(deps.plugins.kotlin.serialization)
alias(deps.plugins.android.library)
alias(deps.plugins.kotlin.android)
alias(deps.plugins.kotlin.kapt)
alias(deps.plugins.hilt.android)
id("configuration")
}
android {
namespace = "com.tangem.domain.notifications"
}
dependencies {
implementation(projects.core.utils)
implementation(projects.domain.core)
implementation(projects.domain.wallets.models)
implementation(projects.domain.notifications.models)
implementation(projects.domain.wallets)
/* Tests */
// region DI
implementation(deps.hilt.android)
kapt(deps.hilt.kapt)
// end
// region Tests
testImplementation(deps.test.junit)
testImplementation(deps.test.coroutine)
testImplementation(deps.test.truth)
testImplementation(deps.test.mockk)
// end
}

View file

@ -11,15 +11,9 @@ interface NotificationsRepository {
suspend fun getApplicationId(): String?
@Throws
suspend fun setNotificationsEnabledForWallet(walletId: String, enabled: Boolean)
@Throws
suspend fun associateApplicationIdWithWallets(appId: String, wallets: List<String>)
@Throws
suspend fun isNotificationsEnabledForWallet(walletId: String): Boolean
@Throws
suspend fun setWalletName(walletId: String, walletName: String)

View file

@ -37,4 +37,10 @@ interface WalletsRepository {
suspend fun enableNFT(userWalletId: UserWalletId)
suspend fun disableNFT(userWalletId: UserWalletId)
@Throws
suspend fun isNotificationsEnabled(userWalletId: UserWalletId, force: Boolean): Boolean
@Throws
suspend fun setNotificationsEnabled(userWalletId: UserWalletId, isEnabled: Boolean)
}

View file

@ -0,0 +1,17 @@
package com.tangem.domain.wallets.usecase
import arrow.core.Either
import com.tangem.domain.wallets.models.UserWalletId
import com.tangem.domain.wallets.repository.WalletsRepository
class GetIsNotificationsEnabledUseCase(
private val walletsRepository: WalletsRepository,
) {
suspend operator fun invoke(userWalletId: UserWalletId, force: Boolean): Either<Throwable, Boolean> = Either.catch {
walletsRepository.isNotificationsEnabled(
userWalletId = userWalletId,
force = force,
)
}
}

View file

@ -0,0 +1,18 @@
package com.tangem.domain.wallets.usecase
import arrow.core.Either
import com.tangem.domain.wallets.models.UserWalletId
import com.tangem.domain.wallets.repository.WalletsRepository
class SetNotificationsEnabledUseCase(
private val walletsRepository: WalletsRepository,
) {
suspend operator fun invoke(userWalletId: UserWalletId, isEnabled: Boolean): Either<Throwable, Unit> =
Either.catch {
walletsRepository.setNotificationsEnabled(
userWalletId = userWalletId,
isEnabled = isEnabled,
)
}
}