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

import java.io.IOException;

import com.xeiam.xchange.ExchangeException;
import com.xeiam.xchange.ExchangeSpecification;
import com.xeiam.xchange.NotAvailableFromExchangeException;
import com.xeiam.xchange.NotYetImplementedForExchangeException;
import com.xeiam.xchange.dto.Order.OrderType;
import com.xeiam.xchange.dto.trade.LimitOrder;
import com.xeiam.xchange.dto.trade.MarketOrder;
import com.xeiam.xchange.dto.trade.OpenOrders;
import com.xeiam.xchange.dto.trade.UserTrades;
import com.xeiam.xchange.empoex.EmpoExAdapters;
import com.xeiam.xchange.service.polling.PollingTradeService;
import com.xeiam.xchange.service.polling.trade.TradeHistoryParams;

public class EmpoExTradeService extends EmpoExTradeServiceRaw implements PollingTradeService {

  public EmpoExTradeService(ExchangeSpecification exchangeSpecification) {

    super(exchangeSpecification);
  }

  @Override
  public OpenOrders getOpenOrders() throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException {

    return EmpoExAdapters.adaptOpenOrders(super.getEmpoExOpenOrders());
  }

  @Override
  public String placeMarketOrder(MarketOrder marketOrder) throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException {

    throw new NotAvailableFromExchangeException();
  }

  @Override
  public String placeLimitOrder(LimitOrder limitOrder) throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException {

    if (limitOrder.getType() == OrderType.BID) {
      return super.buy(limitOrder);
    } else {
      return super.sell(limitOrder);
    }
  }

  @Override
  public boolean cancelOrder(String orderId) throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException {

    return super.cancel(orderId);
  }

  @Override
  public UserTrades getTradeHistory(Object... arguments) throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException {

    throw new NotAvailableFromExchangeException();
  }

  @Override
  public UserTrades getTradeHistory(TradeHistoryParams params) throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException {

    throw new NotAvailableFromExchangeException();
  }

  @Override
  public TradeHistoryParams createTradeHistoryParams() {

    return null;
  }
}

@@ -71,16 +71,38 @@
 ception;
+%0Aimport java.util.Map;
 %0A%0Aimport
@@ -340,27 +340,135 @@
 nge.
-dto.Order.OrderType
+currency.CurrencyPair;%0Aimport com.xeiam.xchange.dto.Order.OrderType;%0Aimport com.xeiam.xchange.dto.marketdata.TradeServiceHelper
 ;%0Aim
@@ -2639,11 +2639,523 @@
 ull;%0A  %7D
+%0A%0A  /**%0A   * Fetch the %7B@link com.xeiam.xchange.dto.marketdata.TradeServiceHelper%7D from%0A   * the exchange.%0A   *%0A   * @return Map of currency pairs to their corresponding metadata.%0A   * @see com.xeiam.xchange.dto.marketdata.TradeServiceHelper%0A   */%0A  @Override%0A  public Map%3CCurrencyPair, ? extends TradeServiceHelper%3E getTradeServiceHelperMap() throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException %7B%0A    throw new NotAvailableFromExchangeException();%0A  %7D
 %0A%7D%0A

Add getTradeServiceHelperMap