forked from bitsoex/bitso-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBitsoBalance.java
More file actions
135 lines (111 loc) · 3.81 KB
/
Copy pathBitsoBalance.java
File metadata and controls
135 lines (111 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package com.bitso;
import java.math.BigDecimal;
import org.json.JSONArray;
import org.json.JSONObject;
import com.bitso.exceptions.BitsoExceptionJSONPayload;
import com.bitso.helpers.Helpers;
public class BitsoBalance {
protected BigDecimal mxnTotal;
protected BigDecimal ethTotal;
protected BigDecimal btcTotal;
protected BigDecimal mxnLocked;
protected BigDecimal ethLocked;
protected BigDecimal btcLocked;
protected BigDecimal mxnAvailable;
protected BigDecimal ethAvailable;
protected BigDecimal btcAvailable;
public BitsoBalance(JSONObject o) {
String currency = "";
if (o.has("payload")) {
JSONObject payload = o.getJSONObject("payload");
JSONArray jsonBalances = payload.getJSONArray("balances");
int totalElements = jsonBalances.length();
for (int i = 0; i < totalElements; i++) {
JSONObject balance = jsonBalances.getJSONObject(i);
currency = Helpers.getString(balance, "currency");
switch (currency) {
case "mxn":
mxnTotal = Helpers.getBD(balance, "total");
mxnLocked = Helpers.getBD(balance, "locked");
;
mxnAvailable = Helpers.getBD(balance, "available");
break;
case "btc":
btcTotal = Helpers.getBD(balance, "total");
btcLocked = Helpers.getBD(balance, "locked");
;
btcAvailable = Helpers.getBD(balance, "available");
break;
case "eth":
ethTotal = Helpers.getBD(balance, "total");
ethLocked = Helpers.getBD(balance, "locked");
;
ethAvailable = Helpers.getBD(balance, "available");
break;
default:
System.out.println(currency + " is not an expected currency");
}
}
} else {
throw new BitsoExceptionJSONPayload(o.toString() + "does not contains payload key");
}
}
@Override
public String toString() {
return Helpers.fieldPrinter(this);
}
public BigDecimal getMxnTotal() {
return mxnTotal;
}
public void setMxnTotal(BigDecimal mxnTotal) {
this.mxnTotal = mxnTotal;
}
public BigDecimal getEthTotal() {
return ethTotal;
}
public void setEthTotal(BigDecimal ethTotal) {
this.ethTotal = ethTotal;
}
public BigDecimal getBtcTotal() {
return btcTotal;
}
public void setBtcTotal(BigDecimal btcTotal) {
this.btcTotal = btcTotal;
}
public BigDecimal getMxnLocked() {
return mxnLocked;
}
public void setMxnLocked(BigDecimal mxnLocked) {
this.mxnLocked = mxnLocked;
}
public BigDecimal getEthLocked() {
return ethLocked;
}
public void setEthLocked(BigDecimal ethLocked) {
this.ethLocked = ethLocked;
}
public BigDecimal getBtcLocked() {
return btcLocked;
}
public void setBtcLocked(BigDecimal btcLocked) {
this.btcLocked = btcLocked;
}
public BigDecimal getMxnAvailable() {
return mxnAvailable;
}
public void setMxnAvailable(BigDecimal mxnAvailable) {
this.mxnAvailable = mxnAvailable;
}
public BigDecimal getEthAvailable() {
return ethAvailable;
}
public void setEthAvailable(BigDecimal ethAvailable) {
this.ethAvailable = ethAvailable;
}
public BigDecimal getBtcAvailable() {
return btcAvailable;
}
public void setBtcAvailable(BigDecimal btcAvailable) {
this.btcAvailable = btcAvailable;
}
}