Updated on 2026-08-14
This commit is contained in:
parent
f1a4be49b3
commit
ce948a71ae
51 changed files with 20 additions and 1186 deletions
|
|
@ -1,24 +0,0 @@
|
|||
package com.tangem.datasource.api.promotion.models
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class PromoBannerResponse(
|
||||
@Json(name = "name") val name: String,
|
||||
@Json(name = "all") val bannerState: BannerState?,
|
||||
) {
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class BannerState(
|
||||
@Json(name = "timeline") val timeline: Timeline,
|
||||
@Json(name = "status") val status: String,
|
||||
@Json(name = "link") val link: String?,
|
||||
)
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class Timeline(
|
||||
@Json(name = "start") val start: String,
|
||||
@Json(name = "end") val end: String,
|
||||
)
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
package com.tangem.datasource.api.promotion.models
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class PromoBannerV2Response(
|
||||
@Json(name = "promotions")
|
||||
val promotions: List<PromoBannerResponse>,
|
||||
)
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
package com.tangem.datasource.api.tangemTech
|
||||
|
||||
import com.tangem.datasource.api.common.response.ApiResponse
|
||||
import com.tangem.datasource.api.promotion.models.PromoBannerResponse
|
||||
import com.tangem.datasource.api.promotion.models.PromoBannerV2Response
|
||||
import com.tangem.datasource.api.promotion.models.StoryContentResponse
|
||||
import com.tangem.datasource.api.tangemTech.models.*
|
||||
import com.tangem.datasource.api.tangemTech.models.promobanners.PromoBannerDisplaysResponse
|
||||
|
|
@ -172,20 +170,6 @@ interface TangemTechApi {
|
|||
): ApiResponse<GetWalletArchivedAccountsResponse>
|
||||
// endregion
|
||||
|
||||
// region promo banners
|
||||
@GET("/v1/promotion")
|
||||
suspend fun getPromoBanner(
|
||||
@Query("programName") name: String,
|
||||
@Header("Cache-Control") cacheControl: String = "max-age=600",
|
||||
): ApiResponse<PromoBannerResponse>
|
||||
|
||||
@GET("/v2/promotion")
|
||||
suspend fun getPromoBannersV2(
|
||||
@Query("walletId") walletId: String,
|
||||
@Header("Cache-Control") cacheControl: String = "max-age=600",
|
||||
): ApiResponse<PromoBannerV2Response>
|
||||
// endregion
|
||||
|
||||
// region promo banners
|
||||
@GET("v1/banner/displays")
|
||||
suspend fun getPromoBannerDisplays(
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
package com.tangem.datasource.di
|
||||
|
||||
import com.tangem.datasource.local.datastore.RuntimeDataStore
|
||||
import com.tangem.datasource.local.datastore.RuntimeSharedStore
|
||||
import com.tangem.datasource.local.promo.DefaultPromoBannerStore
|
||||
import com.tangem.datasource.local.promo.DefaultPromoStoriesStore
|
||||
import com.tangem.datasource.local.promo.PromoBannerStore
|
||||
import com.tangem.datasource.local.promo.PromoStoriesStore
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
|
@ -21,10 +18,4 @@ object PromoStoreModule {
|
|||
fun providePromoStoriesStore(): PromoStoriesStore {
|
||||
return DefaultPromoStoriesStore(dataStore = RuntimeDataStore())
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun providePromoBannerStore(): PromoBannerStore {
|
||||
return DefaultPromoBannerStore(dataStore = RuntimeSharedStore())
|
||||
}
|
||||
}
|
||||
|
|
@ -172,8 +172,6 @@ object PreferencesKeys {
|
|||
|
||||
// region Promo
|
||||
fun getShouldShowStoriesKey(storyId: String) = booleanPreferencesKey("shouldShowStories_$storyId")
|
||||
|
||||
fun getShouldShowPromoKey(promoId: String) = booleanPreferencesKey("shouldShowPromo_$promoId")
|
||||
// endregion
|
||||
|
||||
// region Permission
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
package com.tangem.datasource.local.promo
|
||||
|
||||
import com.tangem.datasource.api.promotion.models.PromoBannerResponse
|
||||
import com.tangem.datasource.local.datastore.RuntimeSharedStore
|
||||
|
||||
internal class DefaultPromoBannerStore(
|
||||
private val dataStore: RuntimeSharedStore<Map<String, PromoBannerResponse>>,
|
||||
) : PromoBannerStore {
|
||||
|
||||
override suspend fun getSyncOrNull(promoId: String): PromoBannerResponse? {
|
||||
return dataStore.getSyncOrNull()?.get(promoId)
|
||||
}
|
||||
|
||||
override suspend fun store(promoId: String, promoBanner: PromoBannerResponse) {
|
||||
dataStore.update(emptyMap()) { current ->
|
||||
current + (promoId to promoBanner)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
package com.tangem.datasource.local.promo
|
||||
|
||||
import com.tangem.datasource.api.promotion.models.PromoBannerResponse
|
||||
|
||||
interface PromoBannerStore {
|
||||
|
||||
suspend fun getSyncOrNull(promoId: String): PromoBannerResponse?
|
||||
|
||||
suspend fun store(promoId: String, promoBanner: PromoBannerResponse)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue