-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathBitsoTransactions.java
More file actions
116 lines (92 loc) · 3.07 KB
/
Copy pathBitsoTransactions.java
File metadata and controls
116 lines (92 loc) · 3.07 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
package com.bitso;
import java.math.BigDecimal;
import java.util.Date;
import org.json.JSONArray;
import org.json.JSONObject;
import com.bitso.helpers.Helpers;
public class BitsoTransactions {
private Transaction[] mTransactionsList;
public BitsoTransactions(JSONArray jsonArray) {
int totalElements = jsonArray.length();
mTransactionsList = new Transaction[totalElements];
for (int i = 0; i < totalElements; i++) {
JSONObject o = jsonArray.getJSONObject(i);
Transaction transaction = new Transaction(Helpers.getZonedDatetime(o, "created_at"),
String.valueOf(o.getInt("tid")), Helpers.getBD(o, "price"), Helpers.getBD(o, "amount"),
BitsoOrder.SIDE.valueOf(Helpers.getString(o, "maker_side").toUpperCase()),
Helpers.getString(o, "book"));
mTransactionsList[i] = transaction;
}
}
public Transaction[] getTransactionsList() {
return mTransactionsList;
}
public void setmTransactionsList(Transaction[] mTransactionsList) {
this.mTransactionsList = mTransactionsList;
}
public String toString() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Bitso Recent Transactions\n");
for (Transaction transaction : mTransactionsList) {
stringBuilder.append(transaction);
}
return stringBuilder.toString();
}
public class Transaction {
private Date date;
private String tid;
private BigDecimal price;
private BigDecimal amount;
private BitsoOrder.SIDE side;
private String book;
public Transaction(Date date, String tid, BigDecimal price, BigDecimal amount, BitsoOrder.SIDE side,
String book) {
super();
this.date = date;
this.tid = tid;
this.price = price;
this.amount = amount;
this.side = side;
this.book = book;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getTid() {
return tid;
}
public void setTid(String tid) {
this.tid = tid;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public BitsoOrder.SIDE getSide() {
return side;
}
public void setSide(BitsoOrder.SIDE side) {
this.side = side;
}
public String getBook() {
return book;
}
public void setBook(String book) {
this.book = book;
}
public String toString() {
return Helpers.fieldPrinter(this, BitsoTransactions.Transaction.class);
}
}
}