All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.contek.invoker.binanceinverse.api.rest.user.GetOrder Maven / Gradle / Ivy

The newest version!
package io.contek.invoker.binanceinverse.api.rest.user;

import com.google.common.collect.ImmutableList;
import io.contek.invoker.binanceinverse.api.common._Order;
import io.contek.invoker.binanceinverse.api.rest.user.GetOrder.Response;
import io.contek.invoker.commons.actor.IActor;
import io.contek.invoker.commons.actor.ratelimit.TypedPermitRequest;
import io.contek.invoker.commons.rest.RestContext;
import io.contek.invoker.commons.rest.RestMethod;
import io.contek.invoker.commons.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.binanceinverse.api.ApiFactory.RateLimits.ONE_REST_REQUEST;
import static io.contek.invoker.commons.rest.RestMethod.GET;

@NotThreadSafe
public final class GetOrder extends UserRestRequest {

  private String symbol;
  private Long orderId;
  private String origClientOrderId;

  GetOrder(IActor actor, RestContext context) {
    super(actor, context);
  }

  public GetOrder setSymbol(String symbol) {
    this.symbol = symbol;
    return this;
  }

  public GetOrder setOrderId(Long orderId) {
    this.orderId = orderId;
    return this;
  }

  public GetOrder setOrigClientOrderId(String origClientOrderId) {
    this.origClientOrderId = origClientOrderId;
    return this;
  }

  @Override
  protected RestMethod getMethod() {
    return GET;
  }

  @Override
  protected Class getResponseType() {
    return Response.class;
  }

  @Override
  protected String getEndpointPath() {
    return "/dapi/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 {}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy