package com.xeiam.xchange.bleutrade.service.polling;

import java.io.IOException;
import java.util.List;

import com.xeiam.xchange.ExchangeException;
import com.xeiam.xchange.ExchangeSpecification;
import com.xeiam.xchange.bleutrade.Bleutrade;
import com.xeiam.xchange.bleutrade.BleutradeUtils;
import com.xeiam.xchange.bleutrade.dto.marketdata.BleutradeMarketHistoryReturn;
import com.xeiam.xchange.bleutrade.dto.marketdata.BleutradeOrderBook;
import com.xeiam.xchange.bleutrade.dto.marketdata.BleutradeOrderBookReturn;
import com.xeiam.xchange.bleutrade.dto.marketdata.BleutradeTicker;
import com.xeiam.xchange.bleutrade.dto.marketdata.BleutradeTickerReturn;
import com.xeiam.xchange.bleutrade.dto.marketdata.BleutradeTrade;
import com.xeiam.xchange.currency.CurrencyPair;

/**
 * <p>
 * Implementation of the market data service for Bleutrade
 * </p>
 * <ul>
 * <li>Provides access to various market data values</li>
 * </ul>
 */
public class BleutradeMarketDataServiceRaw extends BleutradeBasePollingService<Bleutrade> {

  /**
   * Constructor
   * 
   * @param exchangeSpecification The {@link ExchangeSpecification}
   */
  public BleutradeMarketDataServiceRaw(ExchangeSpecification exchangeSpecification) {

    super(Bleutrade.class, exchangeSpecification);
  }

  public List<BleutradeTicker> getBleutradeTickers() throws IOException {

    BleutradeTickerReturn response = bleutrade.getBleutradeTickers();

    if (!response.getSuccess()) {
      throw new ExchangeException(response.getMessage());
    }

    return response.getResult();
  }

  public BleutradeTicker getBleutradeTicker(CurrencyPair currencyPair) throws IOException {

    String pairString = BleutradeUtils.toPairString(currencyPair);
    BleutradeTickerReturn response = bleutrade.getBleutradeTicker(pairString);

    if (!response.getSuccess()) {
      throw new ExchangeException(response.getMessage());
    }

    return response.getResult().get(0);
  }

  public BleutradeOrderBook getBleutradeOrderBook(CurrencyPair currencyPair, int depth) throws IOException {

    String pairString = BleutradeUtils.toPairString(currencyPair);

    BleutradeOrderBookReturn response = bleutrade.getBleutradeOrderBook(pairString, "ALL", depth);

    if (!response.getSuccess()) {
      throw new ExchangeException(response.getMessage());
    }

    return response.getResult();

  }

  public List<BleutradeTrade> getBleutradeMarketHistory(CurrencyPair currencyPair, int count) throws IOException {

    String pairString = BleutradeUtils.toPairString(currencyPair);

    BleutradeMarketHistoryReturn response = bleutrade.getBleutradeMarketHistory(pairString, count);

    if (!response.getSuccess()) {
      throw new ExchangeException(response.getMessage());
    }

    return response.getResult();
  }

}

@@ -349,31 +349,172 @@
 utradeMarket
-History
+;%0Aimport com.xeiam.xchange.bleutrade.dto.marketdata.BleutradeMarketHistoryReturn;%0Aimport com.xeiam.xchange.bleutrade.dto.marketdata.BleutradeMarkets
 Return;%0Aimpo
@@ -2485,24 +2485,309 @@
 lt();%0A%0A  %7D%0A%0A
+  public List%3CBleutradeMarket%3E getBleutradeMarkets() throws IOException %7B%0A%0A    BleutradeMarketsReturn response = bleutrade.getBleutradeMarkets();%0A%0A    if (!response.getSuccess()) %7B%0A      throw new ExchangeException(response.getMessage());%0A    %7D%0A%0A    return response.getResult();%0A%0A  %7D%0A%0A
   public Lis

Make BleutradeMarket DTO's accessible via 'raw' API