Updated on 2026-08-14

This commit is contained in:
Tangem 2024-09-27 17:10:46 +05:00
parent 550bd29f82
commit f686146bcb
5 changed files with 8 additions and 12 deletions

View file

@ -18,14 +18,14 @@ internal class DefaultOnrampRepository(
private val currencyConverter = CurrencyConverter()
private val countryConverter = CountryConverter(currencyConverter)
override suspend fun fetchCurrencies(): List<OnrampCurrency> = withContext(dispatchers.io) {
return@withContext onrampApi.getCurrencies()
override suspend fun getCurrencies(): List<OnrampCurrency> = withContext(dispatchers.io) {
onrampApi.getCurrencies()
.getOrThrow()
.map(currencyConverter::convert)
}
override suspend fun fetchCountries(): List<OnrampCountry> = withContext(dispatchers.io) {
return@withContext onrampApi.getCountries()
override suspend fun getCountries(): List<OnrampCountry> = withContext(dispatchers.io) {
onrampApi.getCountries()
.getOrThrow()
.map(countryConverter::convert)
}

View file

@ -4,7 +4,7 @@ import com.tangem.datasource.api.onramp.models.response.model.OnrampCountryDTO
import com.tangem.domain.onramp.model.OnrampCountry
import com.tangem.utils.converter.Converter
class CountryConverter(
internal class CountryConverter(
private val currencyConverter: CurrencyConverter,
) : Converter<OnrampCountryDTO, OnrampCountry> {

View file

@ -4,7 +4,7 @@ import com.tangem.datasource.api.onramp.models.response.model.OnrampCurrencyDTO
import com.tangem.domain.onramp.model.OnrampCurrency
import com.tangem.utils.converter.Converter
class CurrencyConverter : Converter<OnrampCurrencyDTO, OnrampCurrency> {
internal class CurrencyConverter : Converter<OnrampCurrencyDTO, OnrampCurrency> {
override fun convert(value: OnrampCurrencyDTO) = OnrampCurrency(
name = value.name,