View Javadoc
1   package org.oxerr.peatio.websocket.dto;
2   
3   import java.math.BigDecimal;
4   import java.time.Instant;
5   import java.util.Date;
6   
7   import javax.json.JsonObject;
8   
9   public class Order extends org.oxerr.peatio.rest.dto.Order {
10  
11  	public Order(JsonObject jsonObject) {
12  		super(
13  			jsonObject.getJsonNumber("id").longValue(),
14  			jsonObject.getString("side"),
15  			jsonObject.getString("ord_type"),
16  			new BigDecimal(jsonObject.getString("price")),
17  			new BigDecimal(jsonObject.getString("avg_price")),
18  			jsonObject.getString("state"),
19  			jsonObject.getString("market"),
20  			Date.from(Instant.parse(jsonObject.getString("created_at"))),
21  			new BigDecimal(jsonObject.getString("volume")),
22  			new BigDecimal(jsonObject.getString("remaining_volume")),
23  			new BigDecimal(jsonObject.getString("executed_volume")),
24  			Integer.valueOf(jsonObject.getInt("trades_count"))
25  		);
26  	}
27  
28  	public static Order from(JsonObject jsonObject) {
29  		if (jsonObject == null) {
30  			return null;
31  		}
32  
33  		Order order = new Order(jsonObject);
34  
35  		return order;
36  	}
37  
38  }