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

import java.math.BigDecimal;
import java.util.Date;

import org.knowm.xchange.bitstamp.BitstampUtils;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

public class WithdrawalRequest {

  private Long id;

  private final Date datetime;

  private Type type;
  private BigDecimal amount;
  private Status status;
  
  private String data;                   // additional withdrawal request data
  private String address;                // Bitcoin withdrawal address (bitcoin withdrawals only).
  @JsonProperty("transaction_id")
  private String transactionId;         // Transaction id (bitcoin withdrawals only).

  //  private String data; // additional withdrawal request data

  

  public Long getId() { return id; }
  public WithdrawalRequest(@JsonProperty("datetime") String datetime) {
    super();
    this.datetime = BitstampUtils.parseDate(datetime);
  }
  
  public Date getDatetime() { return datetime; }
  public Type getType() { return type; }
  public BigDecimal getAmount() { return amount; }
  public Status getStatus() { return status; }
  public String getData() { return data; }
  public String getAddress() { return address; }
  public String getTransactionId() { return transactionId; }

  @Override
  public String toString() {
    return "WithdrawalRequest [id=" + id + ", datetime=" + datetime + ", type=" + type + ", amount=" + amount + ", status="
            + status + ", data=" + data + ", address=" + address + ", transactionId=" + transactionId + "]";
  }

  public enum Type {
    SEPA, bitcoin, wire, rippleUSD, rippleBTC, XRP, litecoin, unknown;
    
    // 0 (SEPA), 1 (bitcoin) or 2(WIRE transfer).
    @JsonCreator
    public static Type fromString(String string) {
        switch (string) {
        case "0": return SEPA;
        case "1": return bitcoin;
        case "2": return wire;
        case "6": return rippleUSD;
        case "7": return rippleBTC;
        case "14": return XRP;
        case "15": return litecoin;
        default: return unknown;
      }
    }
  }

  public enum Status {
    open, in_process, finished, canceled, failed;
    
    // 0 (open), 1 (in process), 2 (finished), 3 (canceled) or 4 (failed).
    @JsonCreator
    public static Status fromString(String string) {
        switch (string) {
        case "0": return open;
        case "1": return in_process;
        case "2": return finished;
        case "3": return canceled;
        case "4": return failed;
        case "10": return in_process;
        default:throw new IllegalArgumentException(string + " has no corresponding value");
      }
    }
  }
}

@@ -2186,24 +2186,33 @@
 eled, failed
+, unknown
 ;%0A    %0A    /
@@ -2560,128 +2560,31 @@
     
-case %2210%22: return in_process;%0A        default:throw new IllegalArgumentException(string + %22 has no corresponding value%22)
+default: return unknown
 ;%0A  

support unknown status values