package org.knowm.xchange.bitstamp.dto.trade;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.math.BigDecimal;
import java.util.Date;
import org.knowm.xchange.bitstamp.BitstampUtils;
import si.mazi.rescu.ExceptionalReturnContentException;

/** @author Matija Mazi */
public final class BitstampOrder {

  private long id;
  private Date datetime;
  /** 0 - buy (bid); 1 - sell (ask) */
  private int type;

  private BigDecimal price;
  private BigDecimal amount;
  private String errorMessage;

  public BitstampOrder(
      @JsonProperty("status") String status,
      @JsonProperty("reason") Object reason,
      @JsonProperty("id") long id,
      @JsonProperty("datetime") String datetime,
      @JsonProperty("type") int type,
      @JsonProperty("price") BigDecimal price,
      @JsonProperty("amount") BigDecimal amount,
      @JsonProperty("error") @JsonDeserialize(using = BitstampErrorDeserializer.class)
          String errorMessage) {

    if ("error".equals(status)) {
      throw new ExceptionalReturnContentException(String.valueOf(reason));
    }

    this.id = id;
    this.datetime = BitstampUtils.parseDate(datetime);
    this.type = type;
    this.price = price;
    this.amount = amount;
    this.errorMessage = errorMessage;
  }

  public Date getDatetime() {

    return datetime;
  }

  public long getId() {

    return id;
  }

  public int getType() {

    return type;
  }

  public BigDecimal getPrice() {

    return price;
  }

  public BigDecimal getAmount() {

    return amount;
  }

  @JsonIgnore
  public String getErrorMessage() {

    return errorMessage;
  }

  @Override
  public String toString() {

    return errorMessage != null
        ? errorMessage
        : String.format(
            "Order{id=%s, datetime=%s, type=%s, price=%s, amount=%s}",
            id, datetime, type, price, amount);
  }
}

@@ -594,16 +594,47 @@
 amount;%0A
+  private String currencyPair;%0A
   privat
@@ -656,16 +656,16 @@
 essage;%0A
-
 %0A  publi
@@ -989,16 +989,74 @@
 amount,%0A
+      @JsonProperty(%22currency_pair%22) String currencyPair,%0A
       @J
@@ -1429,16 +1429,54 @@
 amount;%0A
+    this.currencyPair = currencyPair;%0A
     this
@@ -1776,16 +1776,83 @@
 t;%0A  %7D%0A%0A
+  public String getCurrencyPair() %7B%0A%0A    return currencyPair;%0A  %7D%0A%0A
   @JsonI
@@ -2113,16 +2113,33 @@
 mount=%25s
+, currencyPair=%25s
 %7D%22,%0A    
@@ -2179,16 +2179,30 @@
 , amount
+, currencyPair
 );%0A  %7D%0A%7D

add currency pair for bistamp