From ca3ae3019bd6ae67c22649e1780248920228112c Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Fri, 16 Dec 2016 15:21:27 -0500 Subject: [PATCH] Fixing merge issues --- .../de/bitsharesmunich/graphenej/Market.java | 54 ++++++------ .../de/bitsharesmunich/graphenej/RPC.java | 1 + .../graphenej/api/GetAsset.java | 87 ------------------- .../graphenej/api/GetLimitOrders.java | 24 +++-- 4 files changed, 38 insertions(+), 128 deletions(-) delete mode 100644 src/main/java/de/bitsharesmunich/graphenej/api/GetAsset.java diff --git a/src/main/java/de/bitsharesmunich/graphenej/Market.java b/src/main/java/de/bitsharesmunich/graphenej/Market.java index 90179f9..e745180 100644 --- a/src/main/java/de/bitsharesmunich/graphenej/Market.java +++ b/src/main/java/de/bitsharesmunich/graphenej/Market.java @@ -1,28 +1,26 @@ -package com.luminiasoft.bitshares; - - -/** - * - * @author henry - */ -public class Market { - - public String id; - public String expiration; - public String seller; - public long for_sale; - public long deferred_fee; - public Price sell_price; - - public class Price { - - public AmountPrice base; - public AmountPrice quote; - } - - public class AmountPrice { - - public String asset_id; - public long amount; - } -} +package de.bitsharesmunich.graphenej; + +/** + * + * @author henry + */ +public class Market { + + public String id; + public String expiration; + public String seller; + public long for_sale; + public long deferred_fee; + public Price sell_price; + + public class Price { + public AmountPrice base; + public AmountPrice quote; + } + + public class AmountPrice { + + public String asset_id; + public long amount; + } +} diff --git a/src/main/java/de/bitsharesmunich/graphenej/RPC.java b/src/main/java/de/bitsharesmunich/graphenej/RPC.java index 5ae0052..e2b80ed 100644 --- a/src/main/java/de/bitsharesmunich/graphenej/RPC.java +++ b/src/main/java/de/bitsharesmunich/graphenej/RPC.java @@ -19,4 +19,5 @@ public class RPC { public static final String CALL_LOOKUP_ACCOUNTS = "lookup_accounts"; public static final String CALL_LOOKUP_ASSET_SYMBOLS = "lookup_asset_symbols"; public static final String CALL_GET_BLOCK_HEADER = "get_block_header"; + public static final String CALL_GET_LIMIT_ORDERS = "get_limit_orders"; } diff --git a/src/main/java/de/bitsharesmunich/graphenej/api/GetAsset.java b/src/main/java/de/bitsharesmunich/graphenej/api/GetAsset.java deleted file mode 100644 index f16d5df..0000000 --- a/src/main/java/de/bitsharesmunich/graphenej/api/GetAsset.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.luminiasoft.bitshares.ws; - -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -import com.google.gson.reflect.TypeToken; -import com.luminiasoft.bitshares.Asset; -import com.luminiasoft.bitshares.RPC; -import com.luminiasoft.bitshares.interfaces.JsonSerializable; -import com.luminiasoft.bitshares.interfaces.WitnessResponseListener; -import com.luminiasoft.bitshares.models.AccountProperties; -import com.luminiasoft.bitshares.models.ApiCall; -import com.luminiasoft.bitshares.models.BaseResponse; -import com.luminiasoft.bitshares.models.WitnessResponse; -import com.neovisionaries.ws.client.WebSocket; -import com.neovisionaries.ws.client.WebSocketAdapter; -import com.neovisionaries.ws.client.WebSocketException; -import com.neovisionaries.ws.client.WebSocketFrame; - -import java.io.Serializable; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * Created by nelson on 11/15/16. - */ -public class GetAsset extends WebSocketAdapter { - - private String assetName; - private WitnessResponseListener mListener; - - public GetAsset(String assetName, WitnessResponseListener listener){ - this.assetName = assetName; - this.mListener = listener; - } - - @Override - public void onConnected(WebSocket websocket, Map> headers) throws Exception { - ArrayList accountParams = new ArrayList<>(); - ArrayList assetList = new ArrayList(); - assetList.add(new JsonSerializable() { - @Override - public String toJsonString() { - return assetName; - } - - @Override - public JsonElement toJsonObject() { - return new JsonParser().parse(assetName); - } - }); - accountParams.add(assetList); - ApiCall getAccountByName = new ApiCall(0, RPC.CALL_GET_ASSET, accountParams, "2.0", 1); - websocket.sendText(getAccountByName.toJsonString()); - } - - @Override - public void onTextFrame(WebSocket websocket, WebSocketFrame frame) throws Exception { - String response = frame.getPayloadText(); - Gson gson = new Gson(); - - Type getAssetResponse = new TypeToken>>(){}.getType(); - WitnessResponse> witnessResponse = gson.fromJson(response, getAssetResponse); - - if(witnessResponse.error != null){ - this.mListener.onError(witnessResponse.error); - }else{ - this.mListener.onSuccess(witnessResponse); - } - - websocket.disconnect(); - } - - @Override - public void onError(WebSocket websocket, WebSocketException cause) throws Exception { - mListener.onError(new BaseResponse.Error(cause.getMessage())); - websocket.disconnect(); - } - - @Override - public void handleCallbackError(WebSocket websocket, Throwable cause) throws Exception { - mListener.onError(new BaseResponse.Error(cause.getMessage())); - websocket.disconnect(); - } -} diff --git a/src/main/java/de/bitsharesmunich/graphenej/api/GetLimitOrders.java b/src/main/java/de/bitsharesmunich/graphenej/api/GetLimitOrders.java index a418dd2..ccc6b6d 100644 --- a/src/main/java/de/bitsharesmunich/graphenej/api/GetLimitOrders.java +++ b/src/main/java/de/bitsharesmunich/graphenej/api/GetLimitOrders.java @@ -1,18 +1,17 @@ -package com.luminiasoft.bitshares.ws; +package de.bitsharesmunich.graphenej.api; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; -import com.luminiasoft.bitshares.Market; -import com.luminiasoft.bitshares.RPC; -import com.luminiasoft.bitshares.interfaces.WitnessResponseListener; -import com.luminiasoft.bitshares.models.AccountProperties; -import com.luminiasoft.bitshares.models.ApiCall; -import com.luminiasoft.bitshares.models.BaseResponse; -import com.luminiasoft.bitshares.models.WitnessResponse; import com.neovisionaries.ws.client.WebSocket; import com.neovisionaries.ws.client.WebSocketAdapter; import com.neovisionaries.ws.client.WebSocketException; import com.neovisionaries.ws.client.WebSocketFrame; +import de.bitsharesmunich.graphenej.Market; +import de.bitsharesmunich.graphenej.RPC; +import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener; +import de.bitsharesmunich.graphenej.models.ApiCall; +import de.bitsharesmunich.graphenej.models.BaseResponse; +import de.bitsharesmunich.graphenej.models.WitnessResponse; import java.io.Serializable; import java.lang.reflect.Type; @@ -23,14 +22,14 @@ import java.util.Map; /** * Created by nelson on 11/15/16. */ -public class getLimitOrders extends WebSocketAdapter { +public class GetLimitOrders extends WebSocketAdapter { private String a; private String b; private int limit; private WitnessResponseListener mListener; - public getLimitOrders(String a, String b, int limit, WitnessResponseListener mListener) { + public GetLimitOrders(String a, String b, int limit, WitnessResponseListener mListener) { this.a = a; this.b = b; this.limit = limit; @@ -43,7 +42,7 @@ public class getLimitOrders extends WebSocketAdapter { accountParams.add(this.a); accountParams.add(this.b); accountParams.add(this.limit); - ApiCall getAccountByName = new ApiCall(0, RPC.CALL_GET_LIMIT_ORDERS, accountParams, "2.0", 1); + ApiCall getAccountByName = new ApiCall(0, RPC.CALL_GET_LIMIT_ORDERS, accountParams, RPC.VERSION, 1); websocket.sendText(getAccountByName.toJsonString()); } @@ -53,8 +52,7 @@ public class getLimitOrders extends WebSocketAdapter { String response = frame.getPayloadText(); Gson gson = new Gson(); - Type GetLimitiOrdersResponse = new TypeToken>>() { - }.getType(); + Type GetLimitiOrdersResponse = new TypeToken>>() {}.getType(); WitnessResponse> witnessResponse = gson.fromJson(response, GetLimitiOrdersResponse); if (witnessResponse.error != null) { this.mListener.onError(witnessResponse.error);