1
1
package dev.shorthouse.coinwatch.data.source.remote
2
2
3
3
import dev.shorthouse.coinwatch.data.datastore.CoinSort
4
+ import dev.shorthouse.coinwatch.data.datastore.Currency
4
5
import dev.shorthouse.coinwatch.data.source.remote.model.CoinChartApiModel
5
6
import dev.shorthouse.coinwatch.data.source.remote.model.CoinDetailsApiModel
6
7
import dev.shorthouse.coinwatch.data.source.remote.model.CoinSearchResultsApiModel
@@ -13,27 +14,36 @@ class CoinNetworkDataSourceImpl @Inject constructor(
13
14
) : CoinNetworkDataSource {
14
15
override suspend fun getCoins (
15
16
coinIds : List <String >,
16
- coinSort : CoinSort
17
+ coinSort : CoinSort ,
18
+ currency : Currency
17
19
): Response <CoinsApiModel > {
18
- val orderBy = when (coinSort) {
19
- CoinSort .MarketCap -> " marketCap"
20
- CoinSort .Price -> " price"
21
- CoinSort .PriceChange24h -> " change"
22
- CoinSort .Volume24h -> " 24hVolume"
23
- }
24
-
25
- return coinApi.getCoins(coinIds = coinIds, orderBy = orderBy)
20
+ return coinApi.getCoins(
21
+ coinIds = coinIds,
22
+ orderBy = coinSort.toOrderByString(),
23
+ currencyUUID = currency.toCurrencyUUID()
24
+ )
26
25
}
27
26
28
- override suspend fun getCoinDetails (coinId : String ): Response <CoinDetailsApiModel > {
29
- return coinApi.getCoinDetails(coinId = coinId)
27
+ override suspend fun getCoinDetails (
28
+ coinId : String ,
29
+ currency : Currency
30
+ ): Response <CoinDetailsApiModel > {
31
+ return coinApi.getCoinDetails(
32
+ coinId = coinId,
33
+ currencyUUID = currency.toCurrencyUUID()
34
+ )
30
35
}
31
36
32
37
override suspend fun getCoinChart (
33
38
coinId : String ,
34
- chartPeriod : String
39
+ chartPeriod : String ,
40
+ currency : Currency
35
41
): Response <CoinChartApiModel > {
36
- return coinApi.getCoinChart(coinId = coinId, chartPeriod = chartPeriod)
42
+ return coinApi.getCoinChart(
43
+ coinId = coinId,
44
+ chartPeriod = chartPeriod,
45
+ currencyUUID = currency.toCurrencyUUID()
46
+ )
37
47
}
38
48
39
49
override suspend fun getCoinSearchResults (
@@ -42,3 +52,20 @@ class CoinNetworkDataSourceImpl @Inject constructor(
42
52
return coinApi.getCoinSearchResults(searchQuery = searchQuery)
43
53
}
44
54
}
55
+
56
+ private fun CoinSort.toOrderByString (): String {
57
+ return when (this ) {
58
+ CoinSort .MarketCap -> " marketCap"
59
+ CoinSort .Price -> " price"
60
+ CoinSort .PriceChange24h -> " change"
61
+ CoinSort .Volume24h -> " 24hVolume"
62
+ }
63
+ }
64
+
65
+ private fun Currency.toCurrencyUUID (): String {
66
+ return when (this ) {
67
+ Currency .USD -> " yhjMzLPhuIDl"
68
+ Currency .GBP -> " Hokyui45Z38f"
69
+ Currency .EUR -> " 5k-_VTxqtCEI"
70
+ }
71
+ }
0 commit comments