Updated on 2026-08-14
This commit is contained in:
commit
8146119ccd
15 changed files with 204 additions and 3 deletions
|
|
@ -0,0 +1,23 @@
|
|||
package com.tangem.datasource.api.promotion.models
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class StoryContentResponse(
|
||||
@Json(name = "imageHost") val imageHost: String,
|
||||
@Json(name = "story") val story: StoryResponse,
|
||||
) {
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class StoryResponse(
|
||||
@Json(name = "id") val id: String,
|
||||
@Json(name = "title") val title: String?,
|
||||
@Json(name = "slides") val slides: List<StorySlideResponse>?,
|
||||
)
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class StorySlideResponse(
|
||||
@Json(name = "id") val id: String,
|
||||
)
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.tangem.datasource.api.tangemTech
|
|||
|
||||
import com.tangem.datasource.api.common.response.ApiResponse
|
||||
import com.tangem.datasource.api.promotion.models.PromotionInfoResponse
|
||||
import com.tangem.datasource.api.promotion.models.StoryContentResponse
|
||||
import com.tangem.datasource.api.tangemTech.models.*
|
||||
import com.tangem.datasource.api.utils.ReadTimeout
|
||||
import com.tangem.datasource.local.config.providers.models.ProviderModel
|
||||
|
|
@ -125,6 +126,12 @@ interface TangemTechApi {
|
|||
@GET("hot_crypto")
|
||||
suspend fun getHotCrypto(@Query("currency") currencyId: String): ApiResponse<HotCryptoResponse>
|
||||
|
||||
@GET("stories/{story_id}")
|
||||
suspend fun getStoryById(
|
||||
@Path("story_id") storyId: String,
|
||||
@Query("language") language: String,
|
||||
): ApiResponse<StoryContentResponse>
|
||||
|
||||
companion object {
|
||||
val marketsQuoteFields = listOf(
|
||||
"price",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package com.tangem.datasource.di
|
||||
|
||||
import com.tangem.datasource.local.datastore.RuntimeDataStore
|
||||
import com.tangem.datasource.local.promo.DefaultPromoStoriesStore
|
||||
import com.tangem.datasource.local.promo.PromoStoriesStore
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
object PromoStoreModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun providePromoStoriesStore(): PromoStoriesStore {
|
||||
return DefaultPromoStoriesStore(dataStore = RuntimeDataStore())
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.tangem.datasource.local.promo
|
||||
|
||||
import com.tangem.datasource.api.promotion.models.StoryContentResponse
|
||||
import com.tangem.datasource.local.datastore.core.StringKeyDataStore
|
||||
|
||||
internal class DefaultPromoStoriesStore(
|
||||
private val dataStore: StringKeyDataStore<StoryContentResponse>,
|
||||
) : PromoStoriesStore {
|
||||
override suspend fun getSyncOrNull(storyId: String): StoryContentResponse? {
|
||||
return dataStore.getSyncOrNull(storyId)
|
||||
}
|
||||
|
||||
override suspend fun store(storyId: String, item: StoryContentResponse) {
|
||||
dataStore.store(storyId, item)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.tangem.datasource.local.promo
|
||||
|
||||
import com.tangem.datasource.api.promotion.models.StoryContentResponse
|
||||
|
||||
interface PromoStoriesStore {
|
||||
suspend fun getSyncOrNull(storyId: String): StoryContentResponse?
|
||||
|
||||
suspend fun store(storyId: String, item: StoryContentResponse)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue