Added support for the GetAccount api call in the new service-based single connection scheme

This commit is contained in:
Nelson R. Perez 2018-06-04 22:10:03 -05:00
parent 8048e77d30
commit aa758a09e0
3 changed files with 39 additions and 1 deletions

View file

@ -5,6 +5,7 @@ package cy.agorise.graphenej.api;
*/ */
public class ApiAccess { public class ApiAccess {
public static final int API_NONE = 0x00;
public static final int API_DATABASE = 0x01; public static final int API_DATABASE = 0x01;
public static final int API_HISTORY = 0x02; public static final int API_HISTORY = 0x02;
public static final int API_NETWORK_BROADCAST = 0x04; public static final int API_NETWORK_BROADCAST = 0x04;

View file

@ -0,0 +1,37 @@
package cy.agorise.graphenej.api.calls;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import cy.agorise.graphenej.RPC;
import cy.agorise.graphenej.UserAccount;
import cy.agorise.graphenej.api.ApiAccess;
import cy.agorise.graphenej.models.ApiCall;
/**
* Wrapper around the "get_accounts" API call.
*/
public class GetAccounts implements ApiCallable {
public static final int REQUIRED_API = ApiAccess.API_NONE;
private List<UserAccount> mUserAccounts;
public GetAccounts(List<UserAccount> accountList){
mUserAccounts = accountList;
}
public GetAccounts(UserAccount userAccount){
mUserAccounts = new ArrayList<>();
mUserAccounts.add(userAccount);
}
@Override
public ApiCall toApiCall(int apiId, long sequenceId) {
ArrayList<Serializable> params = new ArrayList();
for(UserAccount userAccount : mUserAccounts){
params.add(userAccount.getObjectId());
}
return new ApiCall(apiId, RPC.CALL_GET_ACCOUNTS, params, RPC.VERSION, sequenceId);
}
}

View file

@ -8,7 +8,7 @@ import cy.agorise.graphenej.api.ApiAccess;
import cy.agorise.graphenej.models.ApiCall; import cy.agorise.graphenej.models.ApiCall;
/** /**
* Wrapper aroung the "get_block" API call. * Wrapper around the "get_block" API call.
*/ */
public class GetBlock implements ApiCallable { public class GetBlock implements ApiCallable {