Updated on 2026-08-14
This commit is contained in:
parent
46ff455a6f
commit
e3eada68fd
35 changed files with 757 additions and 13 deletions
|
|
@ -0,0 +1,41 @@
|
|||
package com.tangem.datasource.api.markets
|
||||
|
||||
import com.tangem.datasource.api.common.response.ApiResponse
|
||||
import com.tangem.datasource.api.markets.models.response.*
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Path
|
||||
import retrofit2.http.Query
|
||||
|
||||
interface TangemTechMarketsApi {
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
@GET("coins/list")
|
||||
suspend fun getCoinsList(
|
||||
@Query("currency") currency: String,
|
||||
@Query("interval") interval: String,
|
||||
@Query("offset") offset: Int,
|
||||
@Query("limit") limit: Int,
|
||||
@Query("order") order: String,
|
||||
@Query("general_coins") generalCoins: Boolean,
|
||||
@Query("search") search: String?,
|
||||
): ApiResponse<TokenMarketListResponse>
|
||||
|
||||
@GET("coins/{coin_id}")
|
||||
suspend fun getCoinMarketData(
|
||||
@Path("coin_id") coinId: String,
|
||||
@Query("currency") currency: String,
|
||||
): ApiResponse<TokenMarketDetailsResponse>
|
||||
|
||||
@GET("coins/{coin_id}/history")
|
||||
suspend fun getCoinChart(
|
||||
@Query("currency") currency: String,
|
||||
@Query("interval") interval: String,
|
||||
): ApiResponse<TokenMarketChartResponse>
|
||||
|
||||
@GET("coins/history_preview")
|
||||
suspend fun getCoinsListCharts(
|
||||
@Query("coin_ids") coinIds: List<String>,
|
||||
@Query("currency") currency: String,
|
||||
@Query("interval") interval: String,
|
||||
): ApiResponse<TokenMarketChartListResponse>
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.tangem.datasource.api.markets.models.response
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
|
||||
class TokenMarketChartListResponse(
|
||||
@Json(name = "tokens")
|
||||
val tokens: Map<String, TokenMarketChartResponse>,
|
||||
)
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.tangem.datasource.api.markets.models.response
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import java.math.BigDecimal
|
||||
|
||||
data class TokenMarketChartResponse(
|
||||
@Json(name = "prices")
|
||||
val prices: Map<Long, BigDecimal>,
|
||||
)
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
package com.tangem.datasource.api.markets.models.response
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import java.math.BigDecimal
|
||||
|
||||
data class TokenMarketDetailsResponse(
|
||||
@Json(name = "id")
|
||||
val id: String,
|
||||
@Json(name = "name")
|
||||
val name: String,
|
||||
@Json(name = "symbol")
|
||||
val symbol: String,
|
||||
@Json(name = "active")
|
||||
val active: Boolean,
|
||||
@Json(name = "current_price")
|
||||
val currentPrice: BigDecimal,
|
||||
@Json(name = "price_change_percentage")
|
||||
val priceChangePercentage: PriceChangePercentage,
|
||||
@Json(name = "networks")
|
||||
val networks: List<Network>,
|
||||
@Json(name = "short_description")
|
||||
val shortDescription: String?,
|
||||
@Json(name = "full_description")
|
||||
val fullDescription: String?,
|
||||
@Json(name = "insights")
|
||||
val insights: List<Insight>?,
|
||||
@Json(name = "metrics")
|
||||
val metrics: Metrics,
|
||||
@Json(name = "links")
|
||||
val links: Links,
|
||||
@Json(name = "price_performance")
|
||||
val pricePerformance: PricePerformance,
|
||||
) {
|
||||
data class PriceChangePercentage(
|
||||
@Json(name = "24h")
|
||||
val h24: BigDecimal,
|
||||
@Json(name = "1w")
|
||||
val week1: BigDecimal,
|
||||
@Json(name = "1m")
|
||||
val month1: BigDecimal,
|
||||
@Json(name = "3m")
|
||||
val month3: BigDecimal,
|
||||
@Json(name = "6m")
|
||||
val month6: BigDecimal,
|
||||
@Json(name = "1y")
|
||||
val year1: BigDecimal,
|
||||
@Json(name = "all_time")
|
||||
val allTime: BigDecimal,
|
||||
)
|
||||
|
||||
data class Network(
|
||||
@Json(name = "network_id")
|
||||
val networkId: String,
|
||||
@Json(name = "exchangeable")
|
||||
val exchangeable: Boolean,
|
||||
@Json(name = "contract_address")
|
||||
val contractAddress: String,
|
||||
@Json(name = "decimalCount")
|
||||
val decimalCount: Int,
|
||||
)
|
||||
|
||||
data class Insight(
|
||||
@Json(name = "holders_change")
|
||||
val holdersChange: Change,
|
||||
@Json(name = "liquidity_change")
|
||||
val liquidityChange: Change,
|
||||
@Json(name = "buy_pressure_change")
|
||||
val buyPressureChange: Change,
|
||||
@Json(name = "experienced_buyer_change")
|
||||
val experiencedBuyerChange: Change,
|
||||
) {
|
||||
data class Change(
|
||||
@Json(name = "1d")
|
||||
val day1: Int,
|
||||
@Json(name = "1w")
|
||||
val week1: Int,
|
||||
@Json(name = "1m")
|
||||
val month1: Int,
|
||||
)
|
||||
}
|
||||
|
||||
data class Metrics(
|
||||
@Json(name = "market_rating")
|
||||
val marketRating: Int,
|
||||
@Json(name = "circulating_supply")
|
||||
val circulatingSupply: BigDecimal,
|
||||
@Json(name = "market_cap")
|
||||
val marketCap: BigDecimal,
|
||||
@Json(name = "volume_24h")
|
||||
val volume24h: BigDecimal,
|
||||
@Json(name = "total_supply")
|
||||
val totalSupply: BigDecimal,
|
||||
@Json(name = "fully_diluted_valuation")
|
||||
val fullyDilutedValuation: BigDecimal,
|
||||
)
|
||||
|
||||
data class Links(
|
||||
@Json(name = "official_links")
|
||||
val officialLinks: List<Link> = emptyList(),
|
||||
@Json(name = "social")
|
||||
val social: List<Link> = emptyList(),
|
||||
@Json(name = "repository")
|
||||
val repository: List<Link> = emptyList(),
|
||||
@Json(name = "blockchain_site")
|
||||
val blockchainSite: List<Link> = emptyList(),
|
||||
)
|
||||
|
||||
data class Link(
|
||||
@Json(name = "title")
|
||||
val title: String?,
|
||||
@Json(name = "id")
|
||||
val id: String,
|
||||
@Json(name = "link")
|
||||
val url: String,
|
||||
)
|
||||
|
||||
data class PricePerformance(
|
||||
@Json(name = "high_price")
|
||||
val highPrice: Price,
|
||||
@Json(name = "low_price")
|
||||
val lowPrice: Price,
|
||||
) {
|
||||
data class Price(
|
||||
@Json(name = "24h")
|
||||
val h24: BigDecimal,
|
||||
@Json(name = "1m")
|
||||
val month1: BigDecimal,
|
||||
@Json(name = "all_time")
|
||||
val allTime: BigDecimal,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.tangem.datasource.api.markets.models.response
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import java.math.BigDecimal
|
||||
|
||||
data class TokenMarketListResponse(
|
||||
@Json(name = "imageHost")
|
||||
val imageHost: String,
|
||||
@Json(name = "tokens")
|
||||
val tokens: List<Token>,
|
||||
@Json(name = "total")
|
||||
val total: Int,
|
||||
@Json(name = "limit")
|
||||
val limit: Int,
|
||||
@Json(name = "offset")
|
||||
val offset: Int,
|
||||
) {
|
||||
data class Token(
|
||||
@Json(name = "id")
|
||||
val id: String,
|
||||
@Json(name = "name")
|
||||
val name: String,
|
||||
@Json(name = "symbol")
|
||||
val symbol: String,
|
||||
@Json(name = "current_price")
|
||||
val currentPrice: BigDecimal,
|
||||
@Json(name = "price_change_percentage")
|
||||
val priceChangePercentage: PriceChangePercentage,
|
||||
@Json(name = "market_rating")
|
||||
val marketRating: Int?,
|
||||
@Json(name = "market_cap")
|
||||
val marketCap: BigDecimal?,
|
||||
) {
|
||||
data class PriceChangePercentage(
|
||||
@Json(name = "24h")
|
||||
val h24: BigDecimal,
|
||||
@Json(name = "1w")
|
||||
val week1: BigDecimal,
|
||||
@Json(name = "30d")
|
||||
val day30: BigDecimal,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,10 @@ data class QuotesResponse(
|
|||
@Json(name = "price")
|
||||
val price: BigDecimal?,
|
||||
@Json(name = "priceChange24h")
|
||||
val priceChange: BigDecimal?,
|
||||
val priceChange24h: BigDecimal?,
|
||||
@Json(name = "priceChange1w")
|
||||
val priceChange1w: BigDecimal?,
|
||||
@Json(name = "priceChange30d")
|
||||
val priceChange30d: BigDecimal?,
|
||||
)
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import com.squareup.moshi.Moshi
|
|||
import com.tangem.datasource.BuildConfig
|
||||
import com.tangem.datasource.api.common.response.ApiResponseCallAdapterFactory
|
||||
import com.tangem.datasource.api.express.TangemExpressApi
|
||||
import com.tangem.datasource.api.markets.TangemTechMarketsApi
|
||||
import com.tangem.datasource.api.stakekit.StakeKitApi
|
||||
import com.tangem.datasource.api.tangemTech.TangemTechApi
|
||||
import com.tangem.datasource.api.tangemTech.TangemTechApiV2
|
||||
|
|
@ -128,6 +129,23 @@ class NetworkModule {
|
|||
)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@DevTangemApi
|
||||
@Singleton
|
||||
fun provideCoinMarketsApi(
|
||||
@NetworkMoshi moshi: Moshi,
|
||||
@ApplicationContext context: Context,
|
||||
appVersionProvider: AppVersionProvider,
|
||||
): TangemTechMarketsApi {
|
||||
return provideTangemTechApiInternal(
|
||||
moshi = moshi,
|
||||
context = context,
|
||||
appVersionProvider = appVersionProvider,
|
||||
baseUrl = DEV_V1_TANGEM_TECH_BASE_URL,
|
||||
requestHeaders = listOf(AppVersionPlatformHeaders(appVersionProvider)),
|
||||
)
|
||||
}
|
||||
|
||||
private inline fun <reified T> provideTangemTechApiInternal(
|
||||
moshi: Moshi,
|
||||
context: Context,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue