Updated on 2026-08-14
This commit is contained in:
parent
550bd29f82
commit
f686146bcb
5 changed files with 8 additions and 12 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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> {
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -17,8 +17,4 @@ dependencies {
|
|||
|
||||
implementation(projects.domain.tokens.models)
|
||||
implementation(projects.domain.wallets.models)
|
||||
|
||||
implementation(deps.tangem.blockchain) {
|
||||
exclude(module = "joda-time")
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,6 @@ import com.tangem.domain.onramp.model.OnrampCountry
|
|||
import com.tangem.domain.onramp.model.OnrampCurrency
|
||||
|
||||
interface OnrampRepository {
|
||||
suspend fun fetchCurrencies(): List<OnrampCurrency>
|
||||
suspend fun fetchCountries(): List<OnrampCountry>
|
||||
suspend fun getCurrencies(): List<OnrampCurrency>
|
||||
suspend fun getCountries(): List<OnrampCountry>
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue