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