io.contek.invoker.binancefutures.api.rest.user.DeleteOrder Maven / Gradle / Ivy
package io.contek.invoker.binancefutures.api.rest.user;
import com.google.common.collect.ImmutableList;
import io.contek.invoker.binancefutures.api.common._Order;
import io.contek.invoker.binancefutures.api.rest.user.DeleteOrder.Response;
import io.contek.invoker.commons.api.actor.IActor;
import io.contek.invoker.commons.api.actor.ratelimit.RateLimitQuota;
import io.contek.invoker.commons.api.rest.RestContext;
import io.contek.invoker.commons.api.rest.RestMethod;
import io.contek.invoker.commons.api.rest.RestParams;
import javax.annotation.concurrent.NotThreadSafe;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static io.contek.invoker.binancefutures.api.ApiFactory.RateLimits.ONE_REST_REQUEST;
import static io.contek.invoker.commons.api.rest.RestMethod.DELETE;
@NotThreadSafe
public final class DeleteOrder extends UserRestRequest {
private String symbol;
private Long orderId;
private String origClientOrderId;
DeleteOrder(IActor actor, RestContext context) {
super(actor, context);
}
public DeleteOrder setSymbol(String symbol) {
this.symbol = symbol;
return this;
}
public DeleteOrder setOrderId(Long orderId) {
this.orderId = orderId;
return this;
}
public DeleteOrder setOrigClientOrderId(String origClientOrderId) {
this.origClientOrderId = origClientOrderId;
return this;
}
@Override
protected Class getResponseType() {
return Response.class;
}
@Override
protected RestMethod getMethod() {
return DELETE;
}
@Override
protected String getEndpointPath() {
return "/fapi/v1/order";
}
@Override
protected RestParams getParams() {
RestParams.Builder builder = RestParams.newBuilder();
checkNotNull(symbol);
builder.add("symbol", symbol);
checkArgument(orderId != null || origClientOrderId != null);
if (orderId != null) {
builder.add("orderId", orderId);
}
if (origClientOrderId != null) {
builder.add("origClientOrderId", origClientOrderId);
}
builder.add("timestamp", getMillis());
return builder.build();
}
@Override
protected ImmutableList getRequiredQuotas() {
return ONE_REST_REQUEST;
}
@NotThreadSafe
public static final class Response extends _Order {}
}