Updated on 2026-08-14

This commit is contained in:
Tangem 2026-06-08 12:38:54 +03:00
parent 0f8b2ab26e
commit 1cf8a16fae
18 changed files with 922 additions and 22 deletions

View file

@ -0,0 +1,22 @@
package com.tangem.domain.pushnotificationpreferences
import arrow.core.Either
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.domain.pushnotificationpreferences.repository.WalletPushNotificationPreferencesRepository
class SetAllWalletPushNotificationPreferencesUseCase(
private val repository: WalletPushNotificationPreferencesRepository,
) {
suspend operator fun invoke(
userWalletId: UserWalletId,
transactionAlerts: Boolean,
offersUpdates: Boolean,
priceAlerts: Boolean,
): Either<Throwable, Unit> = repository.setAllPreferences(
userWalletId = userWalletId,
transactionAlerts = transactionAlerts,
offersUpdates = offersUpdates,
priceAlerts = priceAlerts,
)
}

View file

@ -4,4 +4,18 @@ data class WalletPushNotificationPreferences(
val transactionAlerts: PushNotificationPreference,
val offersUpdates: PushNotificationPreference,
val priceAlerts: PushNotificationPreference,
)
) {
fun withCategory(category: PushNotificationCategory, isEnabled: Boolean): WalletPushNotificationPreferences =
when (category) {
PushNotificationCategory.TransactionAlerts -> copy(
transactionAlerts = transactionAlerts.copy(isEnabled = isEnabled),
)
PushNotificationCategory.OffersUpdates -> copy(
offersUpdates = offersUpdates.copy(isEnabled = isEnabled),
)
PushNotificationCategory.PriceAlerts -> copy(
priceAlerts = priceAlerts.copy(isEnabled = isEnabled),
)
}
}

View file

@ -20,4 +20,14 @@ interface WalletPushNotificationPreferencesRepository {
category: PushNotificationCategory,
isEnabled: Boolean,
): Either<Throwable, Unit>
/**
* Set all categories at once
*/
suspend fun setAllPreferences(
userWalletId: UserWalletId,
transactionAlerts: Boolean,
offersUpdates: Boolean,
priceAlerts: Boolean,
): Either<Throwable, Unit>
}