Search in sources :

Example 1 with CmcCurrencyInfoResponse

use of org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.response.CmcCurrencyInfoResponse in project XChange by knowm.

the class CmcMarketDataServiceRaw method getCmcMultipleCurrencyInfo.

public Map<String, CmcCurrencyInfo> getCmcMultipleCurrencyInfo(List<Currency> currencyList) throws IOException {
    List<String> currencyCodes = currencyList.stream().map(Currency::getCurrencyCode).collect(Collectors.toList());
    String commaSeparatedCurrencyCodes = StringUtils.join(currencyCodes, ",");
    CmcCurrencyInfoResponse response = null;
    try {
        response = cmcAuthenticated.getCurrencyInfo(apiKey, commaSeparatedCurrencyCodes);
    } catch (HttpStatusIOException ex) {
        CmcErrorAdapter.adapt(ex);
    }
    return response.getData();
}
Also used : CmcCurrencyInfoResponse(org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.response.CmcCurrencyInfoResponse) HttpStatusIOException(si.mazi.rescu.HttpStatusIOException)

Example 2 with CmcCurrencyInfoResponse

use of org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.response.CmcCurrencyInfoResponse in project XChange by knowm.

the class CmcMarketDataServiceRaw method getCmcCurrencyInfo.

public CmcCurrencyInfo getCmcCurrencyInfo(Currency currency) throws IOException {
    String currencyCode = currency.getCurrencyCode();
    CmcCurrencyInfoResponse response = null;
    try {
        response = cmcAuthenticated.getCurrencyInfo(apiKey, currencyCode);
    } catch (HttpStatusIOException ex) {
        CmcErrorAdapter.adapt(ex);
    }
    return response.getData().get(currencyCode);
}
Also used : CmcCurrencyInfoResponse(org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.response.CmcCurrencyInfoResponse) HttpStatusIOException(si.mazi.rescu.HttpStatusIOException)

Aggregations

CmcCurrencyInfoResponse (org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.response.CmcCurrencyInfoResponse)2 HttpStatusIOException (si.mazi.rescu.HttpStatusIOException)2