package org.knowm.xchange.cryptofacilities;

import java.io.IOException;
import java.math.BigDecimal;
import javax.ws.rs.Consumes;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.knowm.xchange.cryptofacilities.dto.account.CryptoFacilitiesAccounts;
import org.knowm.xchange.cryptofacilities.dto.marketdata.CryptoFacilitiesCancel;
import org.knowm.xchange.cryptofacilities.dto.marketdata.CryptoFacilitiesFills;
import org.knowm.xchange.cryptofacilities.dto.marketdata.CryptoFacilitiesOpenOrders;
import org.knowm.xchange.cryptofacilities.dto.marketdata.CryptoFacilitiesOpenPositions;
import org.knowm.xchange.cryptofacilities.dto.marketdata.CryptoFacilitiesOrder;
import si.mazi.rescu.ParamsDigest;
import si.mazi.rescu.SynchronizedValueFactory;

/** @author Jean-Christophe Laruelle */
@Path("/api/v3")
@Produces(MediaType.APPLICATION_JSON)
public interface CryptoFacilitiesAuthenticated extends CryptoFacilities {

  @POST
  @Path("/accounts")
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  CryptoFacilitiesAccounts accounts(
      @HeaderParam("APIKey") String apiKey,
      @HeaderParam("Authent") ParamsDigest signer,
      @HeaderParam("Nonce") SynchronizedValueFactory<Long> nonce)
      throws IOException;

  @POST
  @Path("/sendorder")
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  CryptoFacilitiesOrder sendOrder(
      @HeaderParam("APIKey") String apiKey,
      @HeaderParam("Authent") ParamsDigest signer,
      @HeaderParam("Nonce") SynchronizedValueFactory<Long> nonce,
      @QueryParam("orderType") String orderType,
      @QueryParam("symbol") String symbol,
      @QueryParam("side") String side,
      @QueryParam("size") BigDecimal size,
      @QueryParam("limitPrice") BigDecimal limitPrice)
      throws IOException;

  @POST
  @Path("/cancelorder")
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  CryptoFacilitiesCancel cancelOrder(
      @HeaderParam("APIKey") String apiKey,
      @HeaderParam("Authent") ParamsDigest signer,
      @HeaderParam("Nonce") SynchronizedValueFactory<Long> nonce,
      @QueryParam("order_id") String order_id)
      throws IOException;

  @POST
  @Path("/openorders")
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  CryptoFacilitiesOpenOrders openOrders(
      @HeaderParam("APIKey") String apiKey,
      @HeaderParam("Authent") ParamsDigest signer,
      @HeaderParam("Nonce") SynchronizedValueFactory<Long> nonce)
      throws IOException;

  @POST
  @Path("/fills")
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  CryptoFacilitiesFills fills(
      @HeaderParam("APIKey") String apiKey,
      @HeaderParam("Authent") ParamsDigest signer,
      @HeaderParam("Nonce") SynchronizedValueFactory<Long> nonce)
      throws IOException;

  @POST
  @Path("/openpositions")
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  CryptoFacilitiesOpenPositions openPositions(
      @HeaderParam("APIKey") String apiKey,
      @HeaderParam("Authent") ParamsDigest signer,
      @HeaderParam("Nonce") SynchronizedValueFactory<Long> nonce)
      throws IOException;
}

@@ -114,24 +114,19 @@
 x.ws.rs.
-Consumes
+GET
 ;%0Aimport
@@ -155,33 +155,8 @@
 am;%0A
-import javax.ws.rs.POST;%0A
 impo
@@ -1017,27 +1017,26 @@
 ities %7B%0A%0A  @
-POS
+GE
 T%0A  @Path(%22/
@@ -1050,59 +1050,8 @@
 s%22)%0A
-  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)%0A
   Cr
@@ -1266,35 +1266,34 @@
 OException;%0A%0A  @
-POS
+GE
 T%0A  @Path(%22/send
@@ -1304,59 +1304,8 @@
 r%22)%0A
-  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)%0A
   Cr
@@ -1747,35 +1747,34 @@
 OException;%0A%0A  @
-POS
+GE
 T%0A  @Path(%22/canc
@@ -1787,59 +1787,8 @@
 r%22)%0A
-  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)%0A
   Cr
@@ -2051,35 +2051,34 @@
 OException;%0A%0A  @
-POS
+GE
 T%0A  @Path(%22/open
@@ -2090,59 +2090,8 @@
 s%22)%0A
-  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)%0A
   Cr
@@ -2310,35 +2310,34 @@
 OException;%0A%0A  @
-POS
+GE
 T%0A  @Path(%22/fill
@@ -2344,59 +2344,8 @@
 s%22)%0A
-  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)%0A
   Cr
@@ -2566,11 +2566,10 @@
 %0A  @
-POS
+GE
 T%0A  
@@ -2596,59 +2596,8 @@
 s%22)%0A
-  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)%0A
   Cr

Fix authenticated requests