diff --git a/snippets/csharp/FiatCurrencies.cs b/snippets/csharp/FiatCurrencies.cs index 7ceced3..41acdbc 100644 --- a/snippets/csharp/FiatCurrencies.cs +++ b/snippets/csharp/FiatCurrencies.cs @@ -29,11 +29,4 @@ public class FiatCurrenciesSnippets } // ANCHOR_END: fetch-fiat-rates } - - public void GetFiatCurrenciesAndRates(BlockingBreezServices sdk) - { - // ANCHOR: get-fiat-currencies-and-rates - // TODO - // ANCHOR_END: get-fiat-currencies-and-rates - } } diff --git a/snippets/dart_snippets/lib/fiat_currencies.dart b/snippets/dart_snippets/lib/fiat_currencies.dart index 9d2c4b0..9de0f5c 100644 --- a/snippets/dart_snippets/lib/fiat_currencies.dart +++ b/snippets/dart_snippets/lib/fiat_currencies.dart @@ -16,25 +16,3 @@ Future> fetchFiatRates(String lspId) async { // ANCHOR_END: fetch-fiat-rates return fiatRatesMap; } - -Future> fiatCurrenciesAndRate() async { - // ANCHOR: get-fiat-currencies-and-rates - List fiatCurrencies = await BreezSDK().listFiatCurrencies(); - Map fiatRates = await BreezSDK().fetchFiatRates(); - - var sorted = fiatCurrencies.toList(); - sorted.sort((f1, f2) { - return f1.id.compareTo(f2.id); - }); - - Map result = {}; - for (var currency in sorted) { - var rate = fiatRates[currency.id]; - if (rate != null) { - result[currency] = rate; - } - } - - return result; - // ANCHOR_END: get-fiat-currencies-and-rates -} diff --git a/snippets/go/fiat_currencies.go b/snippets/go/fiat_currencies.go index 28ee688..5e2ffe8 100644 --- a/snippets/go/fiat_currencies.go +++ b/snippets/go/fiat_currencies.go @@ -19,9 +19,3 @@ func FetchFiatRates() { } // ANCHOR_END: fetch-fiat-rates } - -func GetFiatCurrenciesAndRates() { - // ANCHOR: get-fiat-currencies-and-rates - // TODO - // ANCHOR_END: get-fiat-currencies-and-rates -} diff --git a/snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/FiatCurrencies.kt b/snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/FiatCurrencies.kt index 6ecd9b3..e80b001 100644 --- a/snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/FiatCurrencies.kt +++ b/snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/FiatCurrencies.kt @@ -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 = try { - val fiatCurrencies = sdk.listFiatCurrencies() - val fiatRates = sdk.fetchFiatRates() - - val ratesMap = mutableMapOf() - for (rate in fiatRates) { - ratesMap[rate.coin.lowercase()] = rate - } - - val sorted = fiatCurrencies.sortedBy { it.info.name } - val result = LinkedHashMap() - 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 - } } \ No newline at end of file diff --git a/snippets/react-native/fiat_currencies.ts b/snippets/react-native/fiat_currencies.ts index 5ed40ea..d318100 100644 --- a/snippets/react-native/fiat_currencies.ts +++ b/snippets/react-native/fiat_currencies.ts @@ -14,9 +14,3 @@ const exampleFetchRates = async () => { const fiatRates = await fetchFiatRates() // ANCHOR_END: fetch-fiat-rates } - -const exampleListCurrenciesAndRates = async () => { - // ANCHOR: get-fiat-currencies-and-rates - // TODO - // ANCHOR_END: get-fiat-currencies-and-rates -} diff --git a/snippets/rust/src/fiat_currencies.rs b/snippets/rust/src/fiat_currencies.rs index d7151dc..674ad81 100644 --- a/snippets/rust/src/fiat_currencies.rs +++ b/snippets/rust/src/fiat_currencies.rs @@ -1,4 +1,3 @@ -use std::collections::HashMap; use std::sync::Arc; use anyhow::Result; @@ -19,30 +18,3 @@ async fn get_current_rates(sdk: Arc) -> Result<()> { Ok(()) } - -async fn get_fiat_currencies_and_rates( - sdk: Arc, -) -> Result> { - // ANCHOR: get-fiat-currencies-and-rates - let supported_fiat_currencies = sdk.list_fiat_currencies().await?; - let fiat_rates = sdk.fetch_fiat_rates().await?; - - let mut rates_map: HashMap = HashMap::new(); - for rate in fiat_rates { - rates_map.insert(rate.coin.to_string().to_lowercase(), rate); - } - - let mut sorted = supported_fiat_currencies.clone(); - sorted.sort_by_key(|f| f.info.name.clone()); - - let mut result: Vec<(FiatCurrency, Rate)> = Vec::new(); - for currency in sorted { - let rate = rates_map.get(¤cy.id.to_lowercase()); - if let Some(rate) = rate.cloned() { - result.push((currency, rate)); - } - } - - Ok(result) - // ANCHOR_END: get-fiat-currencies-and-rates -} diff --git a/snippets/swift/BreezSDKExamples/Sources/FiatCurrencies.swift b/snippets/swift/BreezSDKExamples/Sources/FiatCurrencies.swift index bdca755..792f560 100644 --- a/snippets/swift/BreezSDKExamples/Sources/FiatCurrencies.swift +++ b/snippets/swift/BreezSDKExamples/Sources/FiatCurrencies.swift @@ -21,28 +21,3 @@ func getCurrentRates(sdk:BlockingBreezServices) -> [Rate]? { // ANCHOR_END: fetch-fiat-rates return fiatRates } - -func getFiatCurrencyAndRates(sdk: BlockingBreezServices) -> [(FiatCurrency,Rate)]? { - // ANCHOR: get-fiat-currencies-and-rates - var ratesMap = [String:Rate]() - if let supportedFiatCurrencies = try? sdk.listFiatCurrencies(), let fiatRates = try? sdk.fetchFiatRates() { - for fiatRate in fiatRates { - ratesMap[fiatRate.coin.lowercased()] = fiatRate - } - - let sorted = supportedFiatCurrencies.sorted(by: { f1, f2 in - f1.id
Rust
@@ -68,7 +68,7 @@ In order to list the available fiat currencies: -To get the current BTC rate for the currencies: +To get the current BTC rate in the various supported fiat currencies:
Rust
@@ -139,71 +139,3 @@ except Exception as error: ```
- -At the example project you can see these methods combined: - - -
Rust
-
- -```rust,ignore -{{#include ../../snippets/rust/src/fiat_currencies.rs:get-fiat-currencies-and-rates}} -``` -
- -
Swift
-
- -```swift,ignore -{{#include ../../snippets/swift/BreezSDKExamples/Sources/FiatCurrencies.swift:get-fiat-currencies-and-rates}} -``` -
- -
Kotlin
-
- -```kotlin,ignore -{{#include ../../snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/FiatCurrencies.kt:get-fiat-currencies-and-rates}} -``` -
- -
React Native
-
- -```typescript -{{#include ../../snippets/react-native/fiat_currencies.ts:get-fiat-currencies-and-rates}} -``` -
- -
Dart
-
- -```dart,ignore -{{#include ../../snippets/dart_snippets/lib/fiat_currencies.dart:get-fiat-currencies-and-rates}} -``` -
- -
Python
-
- -```python,ignore -# TODO -``` -
- -
Go
-
- -```go,ignore -{{#include ../../snippets/go/fiat_currencies.go:get-fiat-currencies-and-rates}} -``` -
- -
C#
-
- -```cs,ignore -{{#include ../../snippets/csharp/FiatCurrencies.cs:get-fiat-currencies-and-rates}} -``` -
-
\ No newline at end of file