/**
   * Fetches a <tt>CapitalMarketsOrder</tt> with the provided <tt>objectId</tt>.
   *
   * @param objectId the id of the object
   * @return an instance of <tt>CapitalMarketsOrder</tt>
   * @throws RemoteRequestException If there are other issues with the request.
   */
  public static CapitalMarketsOrder fetch(String objectId) throws RemoteRequestException {
    RemoteRequest.RemoteRequestBuilder remoteRequestBuilder =
        RemoteRailsConfig.getRouterAdapterByClassOrUseDefaultAdapter(CapitalMarketsOrder.class)
            .createRemoteRequestBuilder(RequestMethod.GET, CapitalMarketsOrder.class);

    CapitalMarketsOrder object = new CapitalMarketsOrder();
    object.setObjectIdAsString(objectId);

    remoteRequestBuilder.context(object);

    RemoteRequest remoteRequest = remoteRequestBuilder.createRemoteRequest();
    remoteRequest = Utility.interpolateRemoteRequest(remoteRequest);

    return com.anypresence.sdk.APObject.fetch(remoteRequest, CapitalMarketsOrder.class);
  }
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if ((obj == null) || (obj.getClass() != this.getClass())) return false;
   CapitalMarketsOrder other = (CapitalMarketsOrder) obj;
   return new EqualsBuilder()
       .append(comments, other.comments)
       .append(currency, other.currency)
       .append(lastPrice, other.lastPrice)
       .append(lastQty, other.lastQty)
       .append(price, other.price)
       .append(quantity, other.quantity)
       .append(side, other.side)
       .append(status, other.status)
       .append(symbol, other.symbol)
       .append(transactTime, other.transactTime)
       .append(getObjectId(), other.getObjectId())
       .isEquals();
 }
  /** Copies provided object. */
  public static final CapitalMarketsOrder copy(CapitalMarketsOrder orig) {
    final CapitalMarketsOrder newObject = new CapitalMarketsOrder();

    if (orig.getId() != null) newObject.setId(new ObjectId(orig.getId()));

    if (orig.getComments() != null) newObject.setComments(new String(orig.getComments()));

    if (orig.getCurrency() != null) newObject.setCurrency(new String(orig.getCurrency()));

    if (orig.getLastPrice() != null) newObject.setLastPrice(new Float(orig.getLastPrice()));

    if (orig.getLastQty() != null) newObject.setLastQty(new Integer(orig.getLastQty()));

    if (orig.getPrice() != null) newObject.setPrice(new Float(orig.getPrice()));

    if (orig.getQuantity() != null) newObject.setQuantity(new Integer(orig.getQuantity()));

    if (orig.getSide() != null) newObject.setSide(new String(orig.getSide()));

    if (orig.getStatus() != null) newObject.setStatus(new String(orig.getStatus()));

    if (orig.getSymbol() != null) newObject.setSymbol(new String(orig.getSymbol()));

    if (orig.getTransactTime() != null)
      newObject.setTransactTime(new String(orig.getTransactTime()));

    return newObject;
  }
  public RemoteObject deserialize(String queryScope, Parser parser) {
    final RouterAdapter routerAdapter = RemoteRailsConfig.getRouterAdapterByClass(this.getClass());
    CapitalMarketsOrder object = new CapitalMarketsOrder();
    HttpAdapter.Configuration configuration = null;
    if ((routerAdapter != null) && (routerAdapter instanceof HttpAdapter)) {
      if (queryScope != null && !queryScope.isEmpty()) {
        configuration =
            ((HttpAdapter) routerAdapter).getScopedConfigurationsByNameAsConfiguration(queryScope);
      } else {
        configuration = ((HttpAdapter) routerAdapter).getConfigurationsAsConfiguration("GET");
      }
    }
    if (configuration != null) {

      try {

        object.id = parser.parse(configuration.getResponseRemoteFieldName("id"), ObjectId.class);

      } catch (PathNotFoundException e) {
        log.info("Unable to deserialize field: " + e.getMessage());
      }

      try {

        object.comments =
            parser.parse(configuration.getResponseRemoteFieldName("comments"), String.class);

      } catch (PathNotFoundException e) {
        log.info("Unable to deserialize field: " + e.getMessage());
      }

      try {

        object.currency =
            parser.parse(configuration.getResponseRemoteFieldName("currency"), String.class);

      } catch (PathNotFoundException e) {
        log.info("Unable to deserialize field: " + e.getMessage());
      }

      try {

        object.lastPrice =
            parser.parse(configuration.getResponseRemoteFieldName("last_price"), Float.class);

      } catch (PathNotFoundException e) {
        log.info("Unable to deserialize field: " + e.getMessage());
      }

      try {

        object.lastQty =
            parser.parse(configuration.getResponseRemoteFieldName("last_qty"), Integer.class);

      } catch (PathNotFoundException e) {
        log.info("Unable to deserialize field: " + e.getMessage());
      }

      try {

        object.price = parser.parse(configuration.getResponseRemoteFieldName("price"), Float.class);

      } catch (PathNotFoundException e) {
        log.info("Unable to deserialize field: " + e.getMessage());
      }

      try {

        object.quantity =
            parser.parse(configuration.getResponseRemoteFieldName("quantity"), Integer.class);

      } catch (PathNotFoundException e) {
        log.info("Unable to deserialize field: " + e.getMessage());
      }

      try {

        object.side = parser.parse(configuration.getResponseRemoteFieldName("side"), String.class);

      } catch (PathNotFoundException e) {
        log.info("Unable to deserialize field: " + e.getMessage());
      }

      try {

        object.status =
            parser.parse(configuration.getResponseRemoteFieldName("status"), String.class);

      } catch (PathNotFoundException e) {
        log.info("Unable to deserialize field: " + e.getMessage());
      }

      try {

        object.symbol =
            parser.parse(configuration.getResponseRemoteFieldName("symbol"), String.class);

      } catch (PathNotFoundException e) {
        log.info("Unable to deserialize field: " + e.getMessage());
      }

      try {

        object.transactTime =
            parser.parse(configuration.getResponseRemoteFieldName("transact_time"), String.class);

      } catch (PathNotFoundException e) {
        log.info("Unable to deserialize field: " + e.getMessage());
      }

    } else {
      // Default to use gson deserializer
      String json = "";
      if (parser instanceof JsonParser) {
        json = ((JsonParser) parser).getRootElement().toString();
      }

      object = (CapitalMarketsOrder) Utilities.transformJsonToObject(json, this.getClass());
    }

    return object;
  }