Created
February 4, 2018 18:26
-
-
Save antonicg/0af9700a61cc564a83b6fcb048258ce0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.antonicastejon.cryptodata.domain | |
import com.antonicastejon.cryptodata.model.CoinMarketCapRepository | |
import com.antonicastejon.cryptodata.model.Crypto | |
import io.reactivex.Single | |
/** | |
* Created by Antoni Castejón on 31/12/2017. | |
*/ | |
const val LIMIT_CRYPTO_LIST = 20 | |
class CryptoListInteractor(private val coinMarketCapRepository: CoinMarketCapRepository) : CryptoListUseCases { | |
override fun getCryptoListBy(page: Int): Single<List<CryptoViewModel>> { | |
return coinMarketCapRepository.getCryptoList(page, LIMIT_CRYPTO_LIST) | |
.map { cryptos -> cryptos.map(cryptoViewModelMapper) } | |
} | |
val cryptoViewModelMapper: (Crypto) -> CryptoViewModel = { | |
crypto -> CryptoViewModel(crypto.id, crypto.name, crypto.symbol, crypto.rank, crypto.priceUsd.toFloat(), crypto.priceBtc.toFloat(), crypto.percentChange24h.toFloat()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment