-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathBitsoTransfer.java
More file actions
79 lines (71 loc) · 2.79 KB
/
Copy pathBitsoTransfer.java
File metadata and controls
79 lines (71 loc) · 2.79 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
package com.bitso;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Iterator;
import org.json.JSONArray;
import org.json.JSONObject;
import com.bitso.helpers.Helpers;
public class BitsoTransfer {
protected String walletAddress;
protected BigDecimal currencyAmount;
protected BigDecimal btcPending;
protected String confirmationCode;
protected String paymentOutletId;
protected String qrImgUri;
protected long createdAt;
protected BigDecimal currencyFees;
protected BigDecimal btcReceived;
protected BigDecimal btcAmount;
protected String currency;
protected String id;
protected String userUri;
protected HashMap<String, Object> fields;
protected BigDecimal currencySettled;
protected long expiresEpoch;
public enum STATUS {
pending, confirming, completed, expired
}
public STATUS status;
public BitsoTransfer(JSONObject json) {
JSONObject o = json.getJSONObject("order");
walletAddress = o.getString("wallet_address");
currencyAmount = new BigDecimal(o.getString("currency_amount"));
btcPending = new BigDecimal(o.getString("btc_pending"));
confirmationCode = o.getString("confirmation_code");
paymentOutletId = o.getString("payment_outlet_id");
qrImgUri = o.getString("qr_img_uri");
createdAt = Long.valueOf(o.getString("created_at"));
currencyFees = new BigDecimal(o.getString("currency_fees"));
btcReceived = new BigDecimal(o.getString("btc_received"));
btcAmount = new BigDecimal(o.getString("btc_amount"));
currency = o.getString("currency");
id = o.getString("id");
userUri = o.getString("user_uri");
if (o.has("fields")) {
Object fields = o.get("fields");
if (fields.getClass() == JSONObject.class) {
JSONObject f = o.getJSONObject("fields");
this.fields = new HashMap<String, Object>();
Iterator<String> keys = f.keys();
String currentKey;
while(keys.hasNext()){
currentKey = keys.next();
this.fields.put(currentKey, f.get(currentKey));
}
} else if (fields.getClass() == JSONArray.class) {
JSONArray f = o.getJSONArray("fields");
if (f.length() > 0) {
System.err.println("Unknown fields format " + json.toString());
}
}
}
currencySettled = new BigDecimal(o.getString("currency_settled"));
expiresEpoch = Long.valueOf(o.getString("expires_epoch"));
if (o.has("status")) {
status = STATUS.valueOf(o.getString("status"));
}
}
public String toString() {
return Helpers.fieldPrinter(this);
}
}