mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-17 05:44:20 +01:00
Remove GetFiatCurrenciesAndRates snippet
This commit is contained in:
@@ -22,32 +22,4 @@ class FiatCurrencies {
|
||||
}
|
||||
// ANCHOR_END: fetch-fiat-rates
|
||||
}
|
||||
|
||||
fun get_fiat_currencies_and_rates(sdk: BlockingBreezServices) {
|
||||
// ANCHOR: get-fiat-currencies-and-rates
|
||||
fun fiatCurrenciesAndRate(): Map<FiatCurrency, Rate> = try {
|
||||
val fiatCurrencies = sdk.listFiatCurrencies()
|
||||
val fiatRates = sdk.fetchFiatRates()
|
||||
|
||||
val ratesMap = mutableMapOf<String, Rate>()
|
||||
for (rate in fiatRates) {
|
||||
ratesMap[rate.coin.lowercase()] = rate
|
||||
}
|
||||
|
||||
val sorted = fiatCurrencies.sortedBy { it.info.name }
|
||||
val result = LinkedHashMap<FiatCurrency, Rate>()
|
||||
for (currency in sorted) {
|
||||
val rate = ratesMap[currency.id.lowercase()]
|
||||
if (rate != null) {
|
||||
result[currency] = rate
|
||||
}
|
||||
}
|
||||
|
||||
result
|
||||
} catch (e: Throwable) {
|
||||
// Handle error
|
||||
emptyMap()
|
||||
}
|
||||
// ANCHOR_END: get-fiat-currencies-and-rates
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user