Search in sources :

Example 1 with CmcCurrencyInfo

use of org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.CmcCurrencyInfo 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 CmcCurrencyInfo

use of org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.CmcCurrencyInfo 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)

Example 3 with CmcCurrencyInfo

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

the class CurrencyInfoFetchIntegration method getCmcCurrencyInfoTest.

@Test
public void getCmcCurrencyInfoTest() throws Exception {
    CmcCurrencyInfo currency = cmcMarketDataService.getCmcCurrencyInfo(Currency.BTC);
    assertThat(currency).isNotNull();
    assertThat(currency.getSymbol()).isEqualTo(Currency.BTC.getSymbol());
}
Also used : CmcCurrencyInfo(org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.CmcCurrencyInfo) Test(org.junit.Test)

Aggregations

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