diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/NotificationApplicationCreateBody.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/NotificationApplicationCreateBody.kt index e28589eefa..fdc296f8c1 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/NotificationApplicationCreateBody.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/NotificationApplicationCreateBody.kt @@ -5,10 +5,10 @@ import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) data class NotificationApplicationCreateBody( - @Json(name = "pushToken") val pushToken: String, - @Json(name = "platform") val platform: String, - @Json(name = "device") val device: String, - @Json(name = "systemVersion") val systemVersion: String, - @Json(name = "language") val language: String, - @Json(name = "timezone") val timezone: String, + @Json(name = "pushToken") val pushToken: String? = null, + @Json(name = "platform") val platform: String? = null, + @Json(name = "device") val device: String? = null, + @Json(name = "systemVersion") val systemVersion: String? = null, + @Json(name = "language") val language: String? = null, + @Json(name = "timezone") val timezone: String? = null, ) \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/WalletBody.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/WalletBody.kt index d7a5fa0b91..6ad3704bfb 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/WalletBody.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/WalletBody.kt @@ -5,6 +5,6 @@ import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) data class WalletBody( - @Json(name = "notifyStatus") val notifyStatus: String? = null, + @Json(name = "notifyStatus") val notifyStatus: Boolean? = null, @Json(name = "name") val name: String? = null, ) \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/WalletResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/WalletResponse.kt index ad0ff4ebc6..63263f0a1d 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/WalletResponse.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/WalletResponse.kt @@ -5,7 +5,7 @@ import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) data class WalletResponse( - @Json(name = "notifyStatus") val notifyStatus: String? = null, - @Json(name = "name") val name: String? = null, + @Json(name = "notifyStatus") val notifyStatus: Boolean, @Json(name = "id") val id: String, + @Json(name = "name") val name: String? = null, ) \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/di/AppInfoModule.kt b/core/datasource/src/main/java/com/tangem/datasource/di/AppInfoModule.kt new file mode 100644 index 0000000000..c67a5baa1f --- /dev/null +++ b/core/datasource/src/main/java/com/tangem/datasource/di/AppInfoModule.kt @@ -0,0 +1,21 @@ +package com.tangem.datasource.di + +import com.tangem.datasource.info.AndroidAppInfoProvider +import com.tangem.utils.info.AppInfoProvider +import com.tangem.utils.version.AppVersionProvider +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +internal object AppInfoModule { + + @Singleton + @Provides + fun provideAppInfoProvider(appVersionProvider: AppVersionProvider): AppInfoProvider { + return AndroidAppInfoProvider(appVersionProvider) + } +} \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/info/AndroidAppInfoProvider.kt b/core/datasource/src/main/java/com/tangem/datasource/info/AndroidAppInfoProvider.kt new file mode 100644 index 0000000000..08d960e333 --- /dev/null +++ b/core/datasource/src/main/java/com/tangem/datasource/info/AndroidAppInfoProvider.kt @@ -0,0 +1,25 @@ +package com.tangem.datasource.info + +import android.os.Build +import com.tangem.utils.SupportedLanguages +import com.tangem.utils.info.AppInfoProvider +import com.tangem.utils.version.AppVersionProvider +import java.util.* +import javax.inject.Inject + +internal class AndroidAppInfoProvider @Inject constructor( + private val appVersionProvider: AppVersionProvider, +) : AppInfoProvider { + override val platform: String + get() = "Android" + override val device: String + get() = "${Build.MANUFACTURER} ${Build.MODEL}" + override val osVersion: String + get() = Build.VERSION.RELEASE + override val language: String + get() = SupportedLanguages.getCurrentSupportedLanguageCode() + override val timezone: String + get() = TimeZone.getDefault().id + override val appVersion: String + get() = appVersionProvider.versionName +} \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt b/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt index 50275788dd..5177c8d4aa 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt @@ -123,6 +123,10 @@ object PreferencesKeys { val WALLETS_NFT_ENABLED_STATES_KEY by lazy { stringPreferencesKey(name = "walletsNftEnabledStates") } + // region Notifications + val NOTIFICATIONS_APPLICATION_ID_KEY by lazy { stringPreferencesKey(name = "notificationsApplicationId") } + // endregion + fun getShouldShowStoriesKey(storyId: String) = booleanPreferencesKey("shouldShowStories_$storyId") // region Permission diff --git a/core/utils/src/main/java/com/tangem/utils/info/AppInfoProvider.kt b/core/utils/src/main/java/com/tangem/utils/info/AppInfoProvider.kt new file mode 100644 index 0000000000..0ab3e32398 --- /dev/null +++ b/core/utils/src/main/java/com/tangem/utils/info/AppInfoProvider.kt @@ -0,0 +1,10 @@ +package com.tangem.utils.info + +interface AppInfoProvider { + val platform: String + val device: String + val osVersion: String + val language: String + val timezone: String + val appVersion: String +} \ No newline at end of file diff --git a/data/notifications/.gitignore b/data/notifications/.gitignore new file mode 100644 index 0000000000..796b96d1c4 --- /dev/null +++ b/data/notifications/.gitignore @@ -0,0 +1 @@ +/build diff --git a/data/notifications/build.gradle.kts b/data/notifications/build.gradle.kts new file mode 100644 index 0000000000..b3c107f390 --- /dev/null +++ b/data/notifications/build.gradle.kts @@ -0,0 +1,46 @@ +plugins { + alias(deps.plugins.android.library) + alias(deps.plugins.kotlin.android) + alias(deps.plugins.kotlin.kapt) + id("configuration") +} + +android { + namespace = "com.tangem.data.notifications" +} + +dependencies { + + // region AndroidX libraries + implementation(deps.androidx.datastore) + implementation(deps.kotlin.coroutines) + // endregion + + // region DI + implementation(deps.hilt.core) + kapt(deps.hilt.kapt) + // endregion + + // region Arrow + implementation(deps.arrow.core) + // endregion + + // region Core modules + implementation(projects.core.datasource) + implementation(projects.core.utils) + // endregion + + // region Domain modules + implementation(projects.domain.notifications.models) + implementation(projects.domain.notifications) + // endregion + + // region tests + testImplementation(deps.test.junit) + testImplementation(deps.test.coroutine) + testImplementation(deps.test.truth) + testImplementation(deps.test.mockk) + testImplementation(deps.moshi) + testImplementation(deps.moshi.kotlin) + // endregion +} \ No newline at end of file diff --git a/data/notifications/src/main/java/com/tangem/data/notifications/DefaultNotificationsRepository.kt b/data/notifications/src/main/java/com/tangem/data/notifications/DefaultNotificationsRepository.kt new file mode 100644 index 0000000000..3f8c27c889 --- /dev/null +++ b/data/notifications/src/main/java/com/tangem/data/notifications/DefaultNotificationsRepository.kt @@ -0,0 +1,96 @@ +package com.tangem.data.notifications + +import com.tangem.data.notifications.converters.NotificationsEligibleNetworkConverter +import com.tangem.datasource.api.common.response.getOrThrow +import com.tangem.datasource.api.tangemTech.TangemTechApi +import com.tangem.datasource.api.tangemTech.models.NotificationApplicationCreateBody +import com.tangem.datasource.api.tangemTech.models.WalletBody +import com.tangem.datasource.api.tangemTech.models.WalletIdBody +import com.tangem.utils.info.AppInfoProvider +import com.tangem.datasource.local.preferences.AppPreferencesStore +import com.tangem.datasource.local.preferences.PreferencesKeys +import com.tangem.datasource.local.preferences.utils.* +import com.tangem.domain.notifications.NotificationsRepository +import com.tangem.domain.notifications.models.NotificationsEligibleNetwork +import com.tangem.utils.coroutines.CoroutineDispatcherProvider +import kotlinx.coroutines.withContext +import javax.inject.Inject + +internal class DefaultNotificationsRepository @Inject constructor( + private val tangemTechApi: TangemTechApi, + private val appInfoProvider: AppInfoProvider, + private val appPreferencesStore: AppPreferencesStore, + private val dispatchers: CoroutineDispatcherProvider, +) : NotificationsRepository { + + override suspend fun createApplicationId(pushToken: String?): String = withContext(dispatchers.io) { + tangemTechApi.createApplicationId( + NotificationApplicationCreateBody( + platform = appInfoProvider.platform, + device = appInfoProvider.device, + systemVersion = appInfoProvider.osVersion, + language = appInfoProvider.language, + timezone = appInfoProvider.timezone, + pushToken = pushToken, + ), + ).getOrThrow().appId + } + + override suspend fun saveApplicationId(appId: String) { + appPreferencesStore.store(PreferencesKeys.NOTIFICATIONS_APPLICATION_ID_KEY, appId) + } + + override suspend fun getApplicationId(): String? { + return appPreferencesStore.getSyncOrNull(PreferencesKeys.NOTIFICATIONS_APPLICATION_ID_KEY) + } + + override suspend fun setNotificationsEnabledForWallet(walletId: String, enabled: Boolean) = + withContext(dispatchers.io) { + tangemTechApi.setNotificationsEnabled( + walletId = walletId, + body = WalletBody(notifyStatus = enabled), + ).getOrThrow() + } + + override suspend fun associateApplicationIdWithWallets(appId: String, wallets: List) = + withContext(dispatchers.io) { + tangemTechApi.associateApplicationIdWithWallets( + applicationId = appId, + body = wallets.map { + WalletIdBody(it) + }, + ).getOrThrow() + } + + override suspend fun isNotificationsEnabledForWallet(walletId: String): Boolean = withContext(dispatchers.io) { + tangemTechApi.getWalletById(walletId).getOrThrow().notifyStatus + } + + override suspend fun setWalletName(walletId: String, walletName: String) = withContext(dispatchers.io) { + tangemTechApi.updateWallet( + walletId, + WalletBody(name = walletName), + ).getOrThrow() + } + + override suspend fun getWalletName(walletId: String): String? = withContext(dispatchers.io) { + tangemTechApi.getWalletById(walletId).getOrThrow().name + } + + override suspend fun sendPushToken(appId: String, pushToken: String) { + withContext(dispatchers.io) { + tangemTechApi.updatePushTokenForApplicationId( + appId, + NotificationApplicationCreateBody( + pushToken = pushToken, + ), + ).getOrThrow() + } + } + + override suspend fun getEligibleNetworks(): List = withContext(dispatchers.io) { + tangemTechApi.getEligibleNetworksForPushNotifications().getOrThrow().map { + NotificationsEligibleNetworkConverter.convert(it) + } + } +} \ No newline at end of file diff --git a/data/notifications/src/main/java/com/tangem/data/notifications/converters/NotificationsEligibleNetworkConverter.kt b/data/notifications/src/main/java/com/tangem/data/notifications/converters/NotificationsEligibleNetworkConverter.kt new file mode 100644 index 0000000000..471dd0b137 --- /dev/null +++ b/data/notifications/src/main/java/com/tangem/data/notifications/converters/NotificationsEligibleNetworkConverter.kt @@ -0,0 +1,15 @@ +package com.tangem.data.notifications.converters + +import com.tangem.datasource.api.tangemTech.models.CryptoNetworkResponse +import com.tangem.domain.notifications.models.NotificationsEligibleNetwork +import com.tangem.utils.converter.Converter + +internal object NotificationsEligibleNetworkConverter : Converter { + override fun convert(value: CryptoNetworkResponse): NotificationsEligibleNetwork { + return NotificationsEligibleNetwork( + id = value.id.toString(), + networkId = value.networkId, + name = value.name, + ) + } +} \ No newline at end of file diff --git a/data/notifications/src/main/java/com/tangem/data/notifications/di/NotificationsModule.kt b/data/notifications/src/main/java/com/tangem/data/notifications/di/NotificationsModule.kt new file mode 100644 index 0000000000..9358da820e --- /dev/null +++ b/data/notifications/src/main/java/com/tangem/data/notifications/di/NotificationsModule.kt @@ -0,0 +1,18 @@ +package com.tangem.data.notifications.di + +import com.tangem.data.notifications.DefaultNotificationsRepository +import com.tangem.domain.notifications.NotificationsRepository +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +internal interface NotificationsModule { + + @Binds + @Singleton + fun bindNotificationsRepository(repository: DefaultNotificationsRepository): NotificationsRepository +} \ No newline at end of file diff --git a/data/notifications/src/test/java/com/tangem/data/notifications/DefaultNotificationsRepositoryTest.kt b/data/notifications/src/test/java/com/tangem/data/notifications/DefaultNotificationsRepositoryTest.kt new file mode 100644 index 0000000000..65c9a1220d --- /dev/null +++ b/data/notifications/src/test/java/com/tangem/data/notifications/DefaultNotificationsRepositoryTest.kt @@ -0,0 +1,256 @@ +package com.tangem.data.notifications + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.stringPreferencesKey +import com.tangem.datasource.api.tangemTech.TangemTechApi +import com.tangem.utils.info.AppInfoProvider +import com.tangem.datasource.local.preferences.AppPreferencesStore +import com.tangem.datasource.local.preferences.PreferencesKeys +import com.google.common.truth.Truth.assertThat +import com.squareup.moshi.Moshi +import com.tangem.data.notifications.converters.NotificationsEligibleNetworkConverter +import com.tangem.datasource.api.common.response.ApiResponse +import com.tangem.datasource.api.tangemTech.models.* +import com.tangem.utils.coroutines.TestingCoroutineDispatcherProvider +import io.mockk.coEvery +import io.mockk.coVerify +import io.mockk.every +import io.mockk.mockk +import kotlinx.coroutines.flow.flowOf +import kotlinx.coroutines.test.runTest +import org.junit.Test + +class DefaultNotificationsRepositoryTest { + private val tangemTechApi: TangemTechApi = mockk() + private val appInfoProvider: AppInfoProvider = mockk() + private val preferencesDataStore: DataStore = mockk() + private val appPreferencesStore = AppPreferencesStore( + moshi = Moshi.Builder().build(), + dispatchers = TestingCoroutineDispatcherProvider(), + preferencesDataStore = preferencesDataStore, + ) + private val repository = DefaultNotificationsRepository( + tangemTechApi = tangemTechApi, + appInfoProvider = appInfoProvider, + appPreferencesStore = appPreferencesStore, + dispatchers = TestingCoroutineDispatcherProvider(), + ) + + @Test + fun `GIVEN valid push token WHEN createApplicationId THEN returns application id`() = runTest { + // GIVEN + val pushToken = "test-push-token" + val expectedAppId = "test-app-id" + val expectedAppIdResponse = NotificationApplicationIdResponse( + appId = expectedAppId, + ) + coEvery { appInfoProvider.platform } returns "android" + coEvery { appInfoProvider.device } returns "test-device" + coEvery { appInfoProvider.osVersion } returns "11" + coEvery { appInfoProvider.language } returns "en" + coEvery { appInfoProvider.timezone } returns "UTC" + coEvery { tangemTechApi.createApplicationId(any()) } returns ApiResponse.Success( + expectedAppIdResponse, + ) + + // WHEN + val result = repository.createApplicationId(pushToken) + + // THEN + assertThat(result).isEqualTo(expectedAppId) + coVerify { + tangemTechApi.createApplicationId( + NotificationApplicationCreateBody( + platform = "android", + device = "test-device", + systemVersion = "11", + language = "en", + timezone = "UTC", + pushToken = pushToken, + ), + ) + } + } + + @Test + fun `GIVEN application id WHEN saveApplicationId THEN stores it in preferences`() = runTest { + // GIVEN + val appId = "test-app-id" + val preferences = mockk(relaxed = true) + coEvery { preferencesDataStore.updateData(any()) } returns preferences + + // WHEN + repository.saveApplicationId(appId) + + // THEN + coVerify { preferencesDataStore.updateData(any()) } + } + + @Test + fun `GIVEN stored application id WHEN getApplicationId THEN returns it`() = runTest { + // GIVEN + val expectedAppId = "test-app-id" + val preferences = mockk(relaxed = true) + val key = stringPreferencesKey(PreferencesKeys.NOTIFICATIONS_APPLICATION_ID_KEY.name) + every { preferences[key] } returns expectedAppId + coEvery { preferencesDataStore.data } returns flowOf(preferences) + + // WHEN + val result = repository.getApplicationId() + + // THEN + assertThat(result).isEqualTo(expectedAppId) + } + + @Test + fun `GIVEN wallet id and enabled status WHEN setNotificationsEnabledForWallet THEN updates notification status`() = + runTest { + // GIVEN + val walletId = "test-wallet-id" + val enabled = true + coEvery { + tangemTechApi.setNotificationsEnabled( + walletId, + WalletBody(notifyStatus = enabled), + ) + } returns ApiResponse.Success(Unit) + + // WHEN + repository.setNotificationsEnabledForWallet(walletId, enabled) + + // THEN + coVerify { tangemTechApi.setNotificationsEnabled(walletId, WalletBody(notifyStatus = enabled)) } + } + + @Test + fun `GIVEN application id and wallet list WHEN associateApplicationIdWithWallets THEN associates them`() = runTest { + // GIVEN + val appId = "test-app-id" + val wallets = listOf("wallet1", "wallet2") + coEvery { + tangemTechApi.associateApplicationIdWithWallets( + appId, + wallets.map { WalletIdBody(it) }, + ) + } returns ApiResponse.Success(Unit) + + // WHEN + repository.associateApplicationIdWithWallets(appId, wallets) + + // THEN + coVerify { tangemTechApi.associateApplicationIdWithWallets(appId, wallets.map { WalletIdBody(it) }) } + } + + @Test + fun `GIVEN wallet id WHEN isNotificationsEnabledForWallet THEN returns notification status`() = runTest { + // GIVEN + val walletId = "test-wallet-id" + val expectedStatus = true + coEvery { tangemTechApi.getWalletById(walletId) } returns ApiResponse.Success( + WalletResponse( + notifyStatus = expectedStatus, + name = "Test Wallet", + id = walletId, + ), + ) + + // WHEN + val result = repository.isNotificationsEnabledForWallet(walletId) + + // THEN + assertThat(result).isEqualTo(expectedStatus) + } + + @Test + fun `GIVEN wallet id and name WHEN setWalletName THEN updates wallet name`() = runTest { + // GIVEN + val walletId = "test-wallet-id" + val walletName = "Test Wallet" + coEvery { + tangemTechApi.updateWallet( + walletId, + WalletBody(name = walletName), + ) + } returns ApiResponse.Success(Unit) + + // WHEN + repository.setWalletName(walletId, walletName) + + // THEN + coVerify { tangemTechApi.updateWallet(walletId, WalletBody(name = walletName)) } + } + + @Test + fun `GIVEN wallet id WHEN getWalletName THEN returns wallet name`() = runTest { + // GIVEN + val walletId = "test-wallet-id" + val expectedName = "Test Wallet" + coEvery { tangemTechApi.getWalletById(walletId) } returns ApiResponse.Success( + WalletResponse( + notifyStatus = false, + name = expectedName, + id = walletId, + ), + ) + + // WHEN + val result = repository.getWalletName(walletId) + + // THEN + assertThat(result).isEqualTo(expectedName) + } + + @Test + fun `GIVEN application id and push token WHEN sendPushToken THEN updates push token`() = runTest { + // GIVEN + val appId = "test-app-id" + val pushToken = "test-push-token" + coEvery { + tangemTechApi.updatePushTokenForApplicationId( + appId, + NotificationApplicationCreateBody(pushToken = pushToken), + ) + } returns ApiResponse.Success(appId) + + // WHEN + repository.sendPushToken(appId, pushToken) + + // THEN + coVerify { + tangemTechApi.updatePushTokenForApplicationId( + appId, + NotificationApplicationCreateBody(pushToken = pushToken), + ) + } + } + + @Test + fun `GIVEN eligible networks WHEN getEligibleNetworks THEN returns converted networks`() = runTest { + // GIVEN + val expectedNetworks = listOf( + CryptoNetworkResponse( + id = 1, + name = "Ethereum", + networkId = "Ethereum", + ), + CryptoNetworkResponse( + id = 2, + name = "Bitcoin", + networkId = "bitcoin", + ), + ) + coEvery { tangemTechApi.getEligibleNetworksForPushNotifications() } returns ApiResponse.Success( + expectedNetworks, + ) + + // WHEN + val result = repository.getEligibleNetworks() + + // THEN + assertThat(result).hasSize(2) + assertThat(result[0]).isEqualTo(NotificationsEligibleNetworkConverter.convert(expectedNetworks[0])) + assertThat(result[1]).isEqualTo(NotificationsEligibleNetworkConverter.convert(expectedNetworks[1])) + coVerify { tangemTechApi.getEligibleNetworksForPushNotifications() } + } +} \ No newline at end of file diff --git a/domain/notifications/.gitignore b/domain/notifications/.gitignore new file mode 100644 index 0000000000..796b96d1c4 --- /dev/null +++ b/domain/notifications/.gitignore @@ -0,0 +1 @@ +/build diff --git a/domain/notifications/build.gradle.kts b/domain/notifications/build.gradle.kts new file mode 100644 index 0000000000..485c40d9ab --- /dev/null +++ b/domain/notifications/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + alias(deps.plugins.kotlin.jvm) + alias(deps.plugins.kotlin.serialization) + id("configuration") +} + +dependencies { + implementation(deps.arrow.core) + implementation(deps.kotlin.coroutines) + + implementation(projects.domain.notifications.models) +} \ No newline at end of file diff --git a/domain/notifications/models/.gitignore b/domain/notifications/models/.gitignore new file mode 100644 index 0000000000..796b96d1c4 --- /dev/null +++ b/domain/notifications/models/.gitignore @@ -0,0 +1 @@ +/build diff --git a/domain/notifications/models/build.gradle.kts b/domain/notifications/models/build.gradle.kts new file mode 100644 index 0000000000..7dd715c617 --- /dev/null +++ b/domain/notifications/models/build.gradle.kts @@ -0,0 +1,5 @@ +plugins { + alias(deps.plugins.kotlin.jvm) + alias(deps.plugins.kotlin.serialization) + id("configuration") +} \ No newline at end of file diff --git a/domain/notifications/models/src/main/java/com/tangem/domain/notifications/models/NotificationsEligibleNetwork.kt b/domain/notifications/models/src/main/java/com/tangem/domain/notifications/models/NotificationsEligibleNetwork.kt new file mode 100644 index 0000000000..7cd89c6754 --- /dev/null +++ b/domain/notifications/models/src/main/java/com/tangem/domain/notifications/models/NotificationsEligibleNetwork.kt @@ -0,0 +1,7 @@ +package com.tangem.domain.notifications.models + +data class NotificationsEligibleNetwork( + val id: String, + val networkId: String, + val name: String, +) \ No newline at end of file diff --git a/domain/notifications/src/main/java/com/tangem/domain/notifications/NotificationsRepository.kt b/domain/notifications/src/main/java/com/tangem/domain/notifications/NotificationsRepository.kt new file mode 100644 index 0000000000..bb42e3efab --- /dev/null +++ b/domain/notifications/src/main/java/com/tangem/domain/notifications/NotificationsRepository.kt @@ -0,0 +1,34 @@ +package com.tangem.domain.notifications + +import com.tangem.domain.notifications.models.NotificationsEligibleNetwork + +interface NotificationsRepository { + + @Throws + suspend fun createApplicationId(pushToken: String? = null): String + + suspend fun saveApplicationId(appId: String) + + suspend fun getApplicationId(): String? + + @Throws + suspend fun setNotificationsEnabledForWallet(walletId: String, enabled: Boolean) + + @Throws + suspend fun associateApplicationIdWithWallets(appId: String, wallets: List) + + @Throws + suspend fun isNotificationsEnabledForWallet(walletId: String): Boolean + + @Throws + suspend fun setWalletName(walletId: String, walletName: String) + + @Throws + suspend fun getWalletName(walletId: String): String? + + @Throws + suspend fun sendPushToken(appId: String, pushToken: String) + + @Throws + suspend fun getEligibleNetworks(): List +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 01e4240001..5aa3d2ba61 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -291,6 +291,8 @@ include(":domain:networks") include(":domain:quotes") include(":domain:blockaid") include(":domain:blockaid:models") +include(":domain:notifications") +include(":domain:notifications:models") // endregion Domain modules // region Data modules @@ -318,5 +320,6 @@ include(":data:networks") include(":data:nft") include(":data:onramp") include(":data:quotes") +include(":data:notifications") include(":data:blockaid") // endregion Data modules \ No newline at end of file