package com.binance.connector.client.impl.websocketapi;

import com.binance.connector.client.utils.JSONParser;
import com.binance.connector.client.utils.ParameterChecker;
import com.binance.connector.client.utils.websocketapi.WebSocketApiRequestHandler;
import org.json.JSONObject;

/* loaded from: binance-connector-java-3.0.0rc3.jar:com/binance/connector/client/impl/websocketapi/WebSocketApiTrade.class */
public class WebSocketApiTrade {
    private WebSocketApiRequestHandler handler;

    public WebSocketApiTrade(WebSocketApiRequestHandler handler) {
        this.handler = handler;
    }

    public void newOrder(String symbol, String side, String type, JSONObject parameters) {
        ParameterChecker.checkParameterType(symbol, String.class, "symbol");
        ParameterChecker.checkParameterType(side, String.class, "side");
        ParameterChecker.checkParameterType(type, String.class, "type");
        this.handler.signedRequest("order.place", JSONParser.addKeyValue(JSONParser.addKeyValue(JSONParser.addKeyValue(parameters, "symbol", symbol), "side", side), "type", type));
    }

    public void testNewOrder(String symbol, String side, String type, JSONObject parameters) {
        ParameterChecker.checkParameterType(symbol, String.class, "symbol");
        ParameterChecker.checkParameterType(side, String.class, "side");
        ParameterChecker.checkParameterType(type, String.class, "type");
        this.handler.signedRequest("order.test", JSONParser.addKeyValue(JSONParser.addKeyValue(JSONParser.addKeyValue(parameters, "symbol", symbol), "side", side), "type", type));
    }

    public void getOrder(String symbol, JSONObject parameters) {
        ParameterChecker.checkOneOfParametersRequired(parameters, "orderId", "origClientOrderId");
        ParameterChecker.checkParameterType(symbol, String.class, "symbol");
        this.handler.signedRequest("order.status", JSONParser.addKeyValue(parameters, "symbol", symbol));
    }

    public void cancelOrder(String symbol, JSONObject parameters) {
        ParameterChecker.checkOneOfParametersRequired(parameters, "orderId", "origClientOrderId");
        ParameterChecker.checkParameterType(symbol, String.class, "symbol");
        this.handler.signedRequest("order.cancel", JSONParser.addKeyValue(parameters, "symbol", symbol));
    }

    public void cancelReplaceOrder(String symbol, String cancelReplaceMode, String side, String type, JSONObject parameters) {
        ParameterChecker.checkParameterType(symbol, String.class, "symbol");
        ParameterChecker.checkParameterType(cancelReplaceMode, String.class, "cancelReplaceMode");
        ParameterChecker.checkParameterType(side, String.class, "side");
        ParameterChecker.checkParameterType(type, String.class, "type");
        ParameterChecker.checkOneOfParametersRequired(parameters, "cancelOrderId", "cancelOrigClientOrderId");
        this.handler.signedRequest("order.cancelReplace", JSONParser.addKeyValue(JSONParser.addKeyValue(JSONParser.addKeyValue(JSONParser.addKeyValue(parameters, "symbol", symbol), "cancelReplaceMode", cancelReplaceMode), "side", side), "type", type));
    }

    public void getOpenOrders(JSONObject parameters) {
        this.handler.signedRequest("openOrders.status", parameters);
    }

    public void cancelAllOpenOrders(String symbol, JSONObject parameters) {
        ParameterChecker.checkParameterType(symbol, String.class, "symbol");
        this.handler.signedRequest("openOrders.cancelAll", JSONParser.addKeyValue(parameters, "symbol", symbol));
    }

    public void newOcoOrder(String symbol, String side, double price, double quantity, JSONObject parameters) {
        ParameterChecker.checkOneOfParametersRequired(parameters, "stopPrice", "trailingDelta");
        ParameterChecker.checkParameterType(symbol, String.class, "symbol");
        ParameterChecker.checkParameterType(side, String.class, "side");
        ParameterChecker.checkParameterType(Double.valueOf(price), Double.class, "price");
        ParameterChecker.checkParameterType(Double.valueOf(quantity), Double.class, "quantity");
        this.handler.signedRequest("orderList.place", JSONParser.addKeyValue(JSONParser.addKeyValue(JSONParser.addKeyValue(JSONParser.addKeyValue(parameters, "symbol", symbol), "side", side), "price", Double.valueOf(price)), "quantity", Double.valueOf(quantity)));
    }

    public void getOcoOrder(JSONObject parameters) {
        ParameterChecker.checkOneOfParametersRequired(parameters, "origClientOrderId", "orderListId");
        this.handler.signedRequest("orderList.status", parameters);
    }

    public void cancelOcoOrder(String symbol, JSONObject parameters) {
        ParameterChecker.checkOneOfParametersRequired(parameters, "listClientOrderId", "orderListId");
        ParameterChecker.checkParameterType(symbol, String.class, "symbol");
        this.handler.signedRequest("orderList.cancel", JSONParser.addKeyValue(parameters, "symbol", symbol));
    }

    public void getOpenOcoOrders(JSONObject parameters) {
        this.handler.signedRequest("openOrderLists.status", parameters);
    }
}
