Correctly deserializing the GetRequiredFees API call's response
This commit is contained in:
parent
7c79c7f5bf
commit
c71d9802ba
2 changed files with 14 additions and 5 deletions
|
@ -1,12 +1,10 @@
|
|||
package cy.agorise.graphenej.api.android;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.ExclusionStrategy;
|
||||
import com.google.gson.FieldAttributes;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -16,7 +14,7 @@ import cy.agorise.graphenej.Authority;
|
|||
import cy.agorise.graphenej.Transaction;
|
||||
import cy.agorise.graphenej.api.calls.GetAccounts;
|
||||
import cy.agorise.graphenej.api.calls.GetBlock;
|
||||
import cy.agorise.graphenej.models.AccountProperties;
|
||||
import cy.agorise.graphenej.api.calls.GetRequiredFees;
|
||||
import cy.agorise.graphenej.models.Block;
|
||||
import cy.agorise.graphenej.operations.CustomOperation;
|
||||
import cy.agorise.graphenej.operations.LimitOrderCreateOperation;
|
||||
|
@ -48,8 +46,6 @@ public class DeserializationMap {
|
|||
mGsonMap.put(GetBlock.class, getBlockGson);
|
||||
|
||||
// GetAccounts
|
||||
Type GetAccountResponse = new TypeToken<List<AccountProperties>>() {}.getType();
|
||||
mClassMap.put(GetAccounts.class, GetAccountResponse.getClass());
|
||||
mClassMap.put(GetAccounts.class, List.class);
|
||||
Gson getAccountsGson = new GsonBuilder()
|
||||
.setExclusionStrategies(new GetAccountsExclusionStrategy())
|
||||
|
@ -57,6 +53,13 @@ public class DeserializationMap {
|
|||
.registerTypeAdapter(AccountOptions.class, new AccountOptions.AccountOptionsDeserializer())
|
||||
.create();
|
||||
mGsonMap.put(GetAccounts.class, getAccountsGson);
|
||||
|
||||
// GetRequiredFees
|
||||
mClassMap.put(GetRequiredFees.class, List.class);
|
||||
Gson getRequiredFeesGson = new GsonBuilder()
|
||||
.registerTypeAdapter(AssetAmount.class, new AssetAmount.AssetAmountDeserializer())
|
||||
.create();
|
||||
mGsonMap.put(GetRequiredFees.class, getRequiredFeesGson);
|
||||
}
|
||||
|
||||
public Class getReceivedClass(Class _class){
|
||||
|
|
|
@ -17,12 +17,14 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import cy.agorise.graphenej.AssetAmount;
|
||||
import cy.agorise.graphenej.RPC;
|
||||
import cy.agorise.graphenej.api.ApiAccess;
|
||||
import cy.agorise.graphenej.api.ConnectionStatusUpdate;
|
||||
import cy.agorise.graphenej.api.bitshares.Nodes;
|
||||
import cy.agorise.graphenej.api.calls.ApiCallable;
|
||||
import cy.agorise.graphenej.api.calls.GetAccounts;
|
||||
import cy.agorise.graphenej.api.calls.GetRequiredFees;
|
||||
import cy.agorise.graphenej.models.AccountProperties;
|
||||
import cy.agorise.graphenej.models.ApiCall;
|
||||
import cy.agorise.graphenej.models.Block;
|
||||
|
@ -284,6 +286,10 @@ public class NetworkService extends Service {
|
|||
Type GetAccountsResponse = new TypeToken<JsonRpcResponse<List<AccountProperties>>>(){}.getType();
|
||||
JsonRpcResponse<List<AccountProperties>> accountResponse = (JsonRpcResponse) gson.fromJson(text, GetAccountsResponse);
|
||||
parsedResponse = accountResponse;
|
||||
}else if(requestClass == GetRequiredFees.class){
|
||||
Type GetRequiredFeesResponse = new TypeToken<JsonRpcResponse<List<AssetAmount>>>(){}.getType();
|
||||
JsonRpcResponse<List<AssetAmount>> assetAmountResponse = (JsonRpcResponse) gson.fromJson(text, GetRequiredFeesResponse);
|
||||
parsedResponse = assetAmountResponse;
|
||||
}else{
|
||||
Log.w(TAG,"Unknown request class");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue