Skip to content

Commit 4e4ce90

Browse files
committed
Remove STATUS enum in Order class for more flexibility
Signed-off-by: Victor <victor.cruz.isc@gmail.com>
1 parent 08d2d57 commit 4e4ce90

1 file changed

Lines changed: 5 additions & 22 deletions

File tree

src/main/java/com/bitso/BitsoOrder.java

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@ public String toString() {
1717
}
1818
}
1919

20-
public static enum STATUS {
21-
OPEN, PARTIALLY_FILLED, COMPLETED, CANCELLED;
22-
23-
public String toString() {
24-
return this.name().toLowerCase();
25-
}
26-
}
27-
2820
public static enum TYPE {
2921
MARKET, LIMIT;
3022

@@ -42,7 +34,8 @@ public String toString() {
4234
private BigDecimal price;
4335
private String oid;
4436
private SIDE side;
45-
private STATUS status;
37+
// open || partially filled || completed || cancelled || queuedis
38+
private String status;
4639
private TYPE type;
4740

4841
public BitsoOrder(JSONObject o) {
@@ -55,24 +48,14 @@ public BitsoOrder(JSONObject o) {
5548
price = Helpers.getBD(o, "price");
5649
oid = Helpers.getString(o, "oid");
5750
side = retrieveSide(Helpers.getString(o, "side"));
58-
status = retrieveStatus(Helpers.getString(o, "status"));
51+
status = Helpers.getString(o, "status");
5952
type = retrieveType(Helpers.getString(o, "type"));
6053
}
6154

6255
private BitsoOrder.SIDE retrieveSide(String side) {
6356
return BitsoOrder.SIDE.valueOf(side.toUpperCase());
6457
}
6558

66-
private BitsoOrder.STATUS retrieveStatus(String status) {
67-
if (status.equals("open")) return BitsoOrder.STATUS.OPEN;
68-
if (status.equals("partially filled")) return BitsoOrder.STATUS.PARTIALLY_FILLED;
69-
if (status.equals("completed")) return BitsoOrder.STATUS.COMPLETED;
70-
if (status.equals("cancelled")) return BitsoOrder.STATUS.CANCELLED;
71-
72-
String exceptionMessage = status + "is not a supported order status";
73-
throw new BitsoExceptionNotExpectedValue(exceptionMessage);
74-
}
75-
7659
private BitsoOrder.TYPE retrieveType(String type) {
7760
return BitsoOrder.TYPE.valueOf(type.toUpperCase());
7861
}
@@ -149,11 +132,11 @@ public void setSide(SIDE side) {
149132
this.side = side;
150133
}
151134

152-
public STATUS getStatus() {
135+
public String getStatus() {
153136
return status;
154137
}
155138

156-
public void setStatus(STATUS status) {
139+
public void setStatus(String status) {
157140
this.status = status;
158141
}
159142

0 commit comments

Comments
 (0)