use of network.bisq.api.model.CurrencyList in project bisq-api by mrosseel.
the class BisqProxy method calculateCurrencyList.
public static CurrencyList calculateCurrencyList() {
CurrencyList currencyList = new CurrencyList();
CurrencyUtil.getAllSortedCryptoCurrencies().forEach(cryptoCurrency -> currencyList.add(cryptoCurrency.getCode(), cryptoCurrency.getName(), "crypto"));
CurrencyUtil.getAllSortedFiatCurrencies().forEach(fiatCurrency -> currencyList.add(fiatCurrency.getCurrency().getCurrencyCode(), fiatCurrency.getName(), "fiat"));
Collections.sort(currencyList.currencies, (network.bisq.api.model.Currency p1, Currency p2) -> p1.name.compareTo(p2.name));
return currencyList;
}
use of network.bisq.api.model.CurrencyList in project bisq-api by mrosseel.
the class CurrencyResourceIT method getCurrencyList_always_returns200.
@InSequence(1)
@Test
public void getCurrencyList_always_returns200() {
final CurrencyList currencyList = given().port(getAlicePort()).when().get("/api/v1/currencies").then().statusCode(200).and().body("total", isA(Integer.class)).and().body("currencies[0].code", isA(String.class)).and().body("currencies[0].name", isA(String.class)).and().body("currencies[0].type", isA(String.class)).and().body("currencies[0].type", isOneOf("crypto", "fiat")).extract().as(CurrencyList.class);
/**
* Make sure that currency code is used instead of symbol
*/
final Optional<Currency> usd = currencyList.currencies.stream().filter(currency -> "USD".equals(currency.code)).findFirst();
Assert.assertTrue(usd.isPresent());
}
use of network.bisq.api.model.CurrencyList in project bisq-api by mrosseel.
the class BisqProxy method calculateMarketList.
public static MarketList calculateMarketList() {
MarketList marketList = new MarketList();
// we calculate this twice but only at startup
CurrencyList currencyList = calculateCurrencyList();
// currencyList.getCurrencies().stream().flatMap(currency -> marketList.getMarkets().forEach(currency1 -> cur))
List<Market> btc = CurrencyUtil.getAllSortedCryptoCurrencies().stream().filter(cryptoCurrency -> !(cryptoCurrency.getCode().equals("BTC"))).map(cryptoCurrency -> new Market(cryptoCurrency.getCode(), "BTC")).collect(toList());
marketList.markets.addAll(btc);
btc = CurrencyUtil.getAllSortedFiatCurrencies().stream().map(cryptoCurrency -> new Market("BTC", cryptoCurrency.getCode())).collect(toList());
marketList.markets.addAll(btc);
Collections.sort(currencyList.currencies, Comparator.comparing(p -> p.name));
return marketList;
}
Aggregations