Updated on 2026-08-14
This commit is contained in:
parent
ff8f9c9b18
commit
6aab25427d
75 changed files with 2122 additions and 57 deletions
|
|
@ -0,0 +1,39 @@
|
|||
package com.tangem.datasource.api.promotion.models
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class PromotionsResponse(
|
||||
@Json(name = "promotions") val promotions: List<PromotionDto>,
|
||||
) {
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class PromotionDto(
|
||||
@Json(name = "name") val name: String,
|
||||
@Json(name = "all") val all: All?,
|
||||
) {
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class All(
|
||||
@Json(name = "timeline") val timeline: Timeline,
|
||||
@Json(name = "tokens") val tokens: List<PromoToken>?,
|
||||
@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,
|
||||
)
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class PromoToken(
|
||||
@Json(name = "tokenAddress") val tokenAddress: String,
|
||||
@Json(name = "tokenSymbol") val tokenSymbol: String,
|
||||
@Json(name = "tokenName") val tokenName: String,
|
||||
@Json(name = "networkId") val networkId: String,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.tangem.datasource.api.promotion.models
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class YieldBoostStatusResponse(
|
||||
@Json(name = "tokenName") val tokenName: String?,
|
||||
@Json(name = "networkId") val networkId: String?,
|
||||
@Json(name = "moduleAddress") val moduleAddress: String?,
|
||||
@Json(name = "userAddress") val userAddress: String?,
|
||||
@Json(name = "contractAddress") val contractAddress: String?,
|
||||
@Json(name = "promoEnrollmentStatus") val promoEnrollmentStatus: String,
|
||||
@Json(name = "activationDate") val activationDate: String?,
|
||||
@Json(name = "qualificationEndDate") val qualificationEndDate: String?,
|
||||
@Json(name = "disqualificationReason") val disqualificationReason: String?,
|
||||
)
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package com.tangem.datasource.api.tangemTech
|
||||
|
||||
import com.tangem.datasource.api.common.response.ApiResponse
|
||||
import com.tangem.datasource.api.promotion.models.PromotionsResponse
|
||||
import com.tangem.datasource.api.promotion.models.YieldBoostStatusResponse
|
||||
import com.tangem.datasource.api.stories.models.StoryContentResponse
|
||||
import com.tangem.datasource.api.tangemTech.models.*
|
||||
import com.tangem.datasource.api.tangemTech.models.account.GetWalletAccountsResponse
|
||||
|
|
@ -118,6 +120,18 @@ interface TangemTechApi {
|
|||
@GET("v1/stories/{story_id}")
|
||||
suspend fun getStoryById(@Path("story_id") storyId: String): ApiResponse<StoryContentResponse>
|
||||
|
||||
// region yield-boost promo
|
||||
@GET("/v2/promotion")
|
||||
suspend fun getPromotions(
|
||||
@Query("walletId") walletId: String,
|
||||
@Header("Cache-Control") cacheControl: String = "max-age=600",
|
||||
): ApiResponse<PromotionsResponse>
|
||||
|
||||
@Suppress("FunctionSignature", "TrailingCommaOnDeclarationSite")
|
||||
@GET("/v2/promotion/yield-apr-boost/status")
|
||||
suspend fun getYieldBoostStatus(@Query("walletId") walletId: String): ApiResponse<YieldBoostStatusResponse>
|
||||
// endregion
|
||||
|
||||
// region push notifications
|
||||
@GET("v1/notification/push_notifications_eligible_networks")
|
||||
suspend fun getEligibleNetworksForPushNotifications(): ApiResponse<List<CryptoNetworkResponse>>
|
||||
|
|
|
|||
|
|
@ -5,8 +5,13 @@ import androidx.datastore.core.DataStoreFactory
|
|||
import androidx.datastore.dataStoreFile
|
||||
import com.squareup.moshi.Moshi
|
||||
import com.tangem.datasource.api.tangemTech.models.YieldSupplyMarketTokenDto
|
||||
import com.tangem.datasource.local.datastore.RuntimeSharedStore
|
||||
import com.tangem.datasource.local.yieldsupply.DefaultYieldMarketsStore
|
||||
import com.tangem.datasource.local.yieldsupply.YieldMarketsStore
|
||||
import com.tangem.datasource.local.yieldsupply.promo.DefaultYieldBoostPromoStore
|
||||
import com.tangem.datasource.local.yieldsupply.promo.DefaultYieldBoostStatusStore
|
||||
import com.tangem.datasource.local.yieldsupply.promo.YieldBoostPromoStore
|
||||
import com.tangem.datasource.local.yieldsupply.promo.YieldBoostStatusStore
|
||||
import com.tangem.datasource.utils.MoshiDataStoreSerializer
|
||||
import com.tangem.datasource.utils.listTypes
|
||||
import com.tangem.utils.coroutines.AppCoroutineScope
|
||||
|
|
@ -40,4 +45,16 @@ object YieldSupplyModule {
|
|||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideYieldBoostPromoStore(): YieldBoostPromoStore {
|
||||
return DefaultYieldBoostPromoStore(dataStore = RuntimeSharedStore())
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideYieldBoostStatusStore(): YieldBoostStatusStore {
|
||||
return DefaultYieldBoostStatusStore(dataStore = RuntimeSharedStore())
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.tangem.datasource.local.yieldsupply.promo
|
||||
|
||||
import com.tangem.datasource.local.datastore.RuntimeSharedStore
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.yield.supply.models.YieldBoostPromo
|
||||
|
||||
internal class DefaultYieldBoostPromoStore(
|
||||
private val dataStore: RuntimeSharedStore<Map<UserWalletId, YieldBoostPromo>>,
|
||||
) : YieldBoostPromoStore {
|
||||
|
||||
override suspend fun getSyncOrNull(userWalletId: UserWalletId): YieldBoostPromo? {
|
||||
return dataStore.getSyncOrNull()?.get(userWalletId)
|
||||
}
|
||||
|
||||
override suspend fun store(userWalletId: UserWalletId, value: YieldBoostPromo) {
|
||||
dataStore.update(emptyMap()) { current ->
|
||||
current + (userWalletId to value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.tangem.datasource.local.yieldsupply.promo
|
||||
|
||||
import com.tangem.datasource.local.datastore.RuntimeSharedStore
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.yield.supply.models.YieldBoostStatus
|
||||
|
||||
internal class DefaultYieldBoostStatusStore(
|
||||
private val dataStore: RuntimeSharedStore<Map<UserWalletId, YieldBoostStatus>>,
|
||||
) : YieldBoostStatusStore {
|
||||
|
||||
override suspend fun getSyncOrNull(userWalletId: UserWalletId): YieldBoostStatus? {
|
||||
return dataStore.getSyncOrNull()?.get(userWalletId)
|
||||
}
|
||||
|
||||
override suspend fun store(userWalletId: UserWalletId, value: YieldBoostStatus) {
|
||||
dataStore.update(emptyMap()) { current ->
|
||||
current + (userWalletId to value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.tangem.datasource.local.yieldsupply.promo
|
||||
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.yield.supply.models.YieldBoostPromo
|
||||
|
||||
interface YieldBoostPromoStore {
|
||||
|
||||
suspend fun getSyncOrNull(userWalletId: UserWalletId): YieldBoostPromo?
|
||||
|
||||
suspend fun store(userWalletId: UserWalletId, value: YieldBoostPromo)
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.tangem.datasource.local.yieldsupply.promo
|
||||
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.yield.supply.models.YieldBoostStatus
|
||||
|
||||
interface YieldBoostStatusStore {
|
||||
|
||||
suspend fun getSyncOrNull(userWalletId: UserWalletId): YieldBoostStatus?
|
||||
|
||||
suspend fun store(userWalletId: UserWalletId, value: YieldBoostStatus)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue