Added support for the get_account_history API call
This commit is contained in:
parent
05699df638
commit
415e41ae11
3 changed files with 69 additions and 0 deletions
|
@ -19,6 +19,7 @@ public class RPC {
|
||||||
public static final String CALL_GET_REQUIRED_FEES = "get_required_fees";
|
public static final String CALL_GET_REQUIRED_FEES = "get_required_fees";
|
||||||
public static final String CALL_GET_KEY_REFERENCES = "get_key_references";
|
public static final String CALL_GET_KEY_REFERENCES = "get_key_references";
|
||||||
public static final String CALL_GET_RELATIVE_ACCOUNT_HISTORY = "get_relative_account_history";
|
public static final String CALL_GET_RELATIVE_ACCOUNT_HISTORY = "get_relative_account_history";
|
||||||
|
public static final String CALL_GET_ACCOUNT_HISTORY = "get_account_history";
|
||||||
public static final String CALL_LOOKUP_ACCOUNTS = "lookup_accounts";
|
public static final String CALL_LOOKUP_ACCOUNTS = "lookup_accounts";
|
||||||
public static final String CALL_LIST_ASSETS = "list_assets";
|
public static final String CALL_LIST_ASSETS = "list_assets";
|
||||||
public static final String GET_OBJECTS = "get_objects";
|
public static final String GET_OBJECTS = "get_objects";
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package cy.agorise.graphenej.api.calls;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import cy.agorise.graphenej.RPC;
|
||||||
|
import cy.agorise.graphenej.UserAccount;
|
||||||
|
import cy.agorise.graphenej.api.ApiAccess;
|
||||||
|
import cy.agorise.graphenej.models.ApiCall;
|
||||||
|
|
||||||
|
public class GetAccountHistory implements ApiCallable {
|
||||||
|
public static final int REQUIRED_API = ApiAccess.API_HISTORY;
|
||||||
|
|
||||||
|
private UserAccount mUserAccount;
|
||||||
|
private String startOperation;
|
||||||
|
private String endOperation;
|
||||||
|
private int limit;
|
||||||
|
|
||||||
|
public GetAccountHistory(UserAccount userAccount, String start, String end, int limit){
|
||||||
|
this.mUserAccount = userAccount;
|
||||||
|
this.startOperation = start;
|
||||||
|
this.endOperation = end;
|
||||||
|
this.limit = limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GetAccountHistory(String userId, String start, String end, int limit){
|
||||||
|
this.mUserAccount = new UserAccount(userId);
|
||||||
|
this.startOperation = start;
|
||||||
|
this.endOperation = end;
|
||||||
|
this.limit = limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiCall toApiCall(int apiId, long sequenceId) {
|
||||||
|
ArrayList<Serializable> params = new ArrayList<>();
|
||||||
|
params.add(mUserAccount.getObjectId());
|
||||||
|
params.add(endOperation);
|
||||||
|
params.add(limit);
|
||||||
|
params.add(startOperation);
|
||||||
|
return new ApiCall(apiId, RPC.CALL_GET_ACCOUNT_HISTORY, params, RPC.VERSION, sequenceId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package cy.agorise.graphenej.api.calls;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import cy.agorise.graphenej.UserAccount;
|
||||||
|
import cy.agorise.graphenej.models.ApiCall;
|
||||||
|
|
||||||
|
public class GetAccountHistoryTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSerialization(){
|
||||||
|
UserAccount userAccount = new UserAccount("1.2.139293");
|
||||||
|
String end = "1.11.225030218";
|
||||||
|
String start = "1.11.225487973";
|
||||||
|
int limit = 20;
|
||||||
|
GetAccountHistory getAccountHistory = new GetAccountHistory(userAccount, start, end, limit);
|
||||||
|
ApiCall apiCall = getAccountHistory.toApiCall(2, 3);
|
||||||
|
String serialized = apiCall.toJsonString();
|
||||||
|
System.out.println("> "+serialized);
|
||||||
|
String expected = "{\"id\":3,\"method\":\"call\",\"params\":[2,\"get_account_history\",[\"1.2.139293\",\"1.11.225030218\",20,\"1.11.225487973\"]],\"jsonrpc\":\"2.0\"}";
|
||||||
|
Assert.assertEquals("Serialized is as expected", expected, serialized);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue