Search in sources :

Example 1 with RequestHandler

use of run.wallet.iota.api.handler.RequestHandler in project run-wallet-android by runplay.

the class BasicApiProvider method processRequest.

@Override
public ApiResponse processRequest(ApiRequest apiRequest) {
    ApiResponse response = null;
    try {
        if (useRequestHandlerMap.containsKey(apiRequest.getClass())) {
            RequestHandler requestHandler = useRequestHandlerMap.get(apiRequest.getClass());
            response = requestHandler.handle(apiRequest);
        }
    } catch (IllegalAccessError e) {
        NetworkError error = new NetworkError();
        error.setErrorType(NetworkErrorType.ACCESS_ERROR);
        response = error;
        Log.e("ERR-B-API1", "" + e.getMessage());
    } catch (Exception e) {
        Log.e("ERR-B-API2", e.toString() + " -- " + e.getMessage());
        response = new NetworkError();
    }
    return response == null ? new NetworkError() : response;
}
Also used : RequestHandler(run.wallet.iota.api.handler.RequestHandler) WebGetExchangeRatesHistoryRequestHandler(run.wallet.iota.api.handler.WebGetExchangeRatesHistoryRequestHandler) WebGetExchangeRatesRequestHandler(run.wallet.iota.api.handler.WebGetExchangeRatesRequestHandler) NetworkError(run.wallet.iota.api.responses.error.NetworkError) ApiResponse(run.wallet.iota.api.responses.ApiResponse)

Example 2 with RequestHandler

use of run.wallet.iota.api.handler.RequestHandler in project run-wallet-android by runplay.

the class IotaMessageApiProvider method loadRequestMap.

private void loadRequestMap() {
    Map<Class<? extends ApiRequest>, RequestHandler> requestHandlerMap = new HashMap<>();
    MessageSendRequestHandler sendMessageAction = new MessageSendRequestHandler(iotaApi, context);
    MessageNewAddressRequestHandler newAddressAction = new MessageNewAddressRequestHandler(iotaApi, context);
    MessageFirstLoadRequestHandler firstLoad = new MessageFirstLoadRequestHandler(iotaApi, context);
    requestHandlerMap.put(sendMessageAction.getType(), sendMessageAction);
    this.requestHandlerMap = requestHandlerMap;
}
Also used : MessageNewAddressRequestHandler(run.wallet.iota.api.handler.MessageNewAddressRequestHandler) MessageFirstLoadRequestHandler(run.wallet.iota.api.handler.MessageFirstLoadRequestHandler) MessageFirstLoadRequestHandler(run.wallet.iota.api.handler.MessageFirstLoadRequestHandler) RequestHandler(run.wallet.iota.api.handler.RequestHandler) MessageSendRequestHandler(run.wallet.iota.api.handler.MessageSendRequestHandler) MessageNewAddressRequestHandler(run.wallet.iota.api.handler.MessageNewAddressRequestHandler) HashMap(java.util.HashMap) MessageSendRequestHandler(run.wallet.iota.api.handler.MessageSendRequestHandler) ApiRequest(run.wallet.iota.api.requests.ApiRequest)

Example 3 with RequestHandler

use of run.wallet.iota.api.handler.RequestHandler in project run-wallet-android by runplay.

the class IotaMessageApiProvider method processRequest.

@Override
public ApiResponse processRequest(ApiRequest apiRequest) {
    ApiResponse response = null;
    try {
        // Log.e("IotaMessageApiProvider", "");
        if (this.requestHandlerMap.containsKey(apiRequest.getClass())) {
            // Log.e("IotaMessageApiProvider", "requesting");
            RequestHandler requestHandler = this.requestHandlerMap.get(apiRequest.getClass());
            response = requestHandler.handle(apiRequest);
        }
    } catch (IllegalAccessError e) {
        NetworkError error = new NetworkError();
        error.setErrorType(NetworkErrorType.ACCESS_ERROR);
        response = error;
    // Log.e("IotaMessageApi ERR",""+e.getMessage());
    } catch (Exception e) {
        Log.e("ERR-API", "ex: " + e.getMessage());
        response = new NetworkError();
    }
    return response == null ? new NetworkError() : response;
}
Also used : MessageFirstLoadRequestHandler(run.wallet.iota.api.handler.MessageFirstLoadRequestHandler) RequestHandler(run.wallet.iota.api.handler.RequestHandler) MessageSendRequestHandler(run.wallet.iota.api.handler.MessageSendRequestHandler) MessageNewAddressRequestHandler(run.wallet.iota.api.handler.MessageNewAddressRequestHandler) NetworkError(run.wallet.iota.api.responses.error.NetworkError) ApiResponse(run.wallet.iota.api.responses.ApiResponse)

Example 4 with RequestHandler

use of run.wallet.iota.api.handler.RequestHandler in project run-wallet-android by runplay.

the class BasicApiProvider method loadRequestMap.

private void loadRequestMap() {
    if (useRequestHandlerMap == null) {
        Map<Class<? extends ApiRequest>, RequestHandler> requestHandlerMap = new HashMap<>();
        WebGetExchangeRatesRequestHandler webExchangeAction = new WebGetExchangeRatesRequestHandler(context);
        WebGetExchangeRatesHistoryRequestHandler webExchangeHistoryAction = new WebGetExchangeRatesHistoryRequestHandler(context);
        requestHandlerMap.put(webExchangeAction.getType(), webExchangeAction);
        requestHandlerMap.put(webExchangeHistoryAction.getType(), webExchangeHistoryAction);
        useRequestHandlerMap = requestHandlerMap;
    }
}
Also used : WebGetExchangeRatesHistoryRequestHandler(run.wallet.iota.api.handler.WebGetExchangeRatesHistoryRequestHandler) RequestHandler(run.wallet.iota.api.handler.RequestHandler) WebGetExchangeRatesHistoryRequestHandler(run.wallet.iota.api.handler.WebGetExchangeRatesHistoryRequestHandler) WebGetExchangeRatesRequestHandler(run.wallet.iota.api.handler.WebGetExchangeRatesRequestHandler) HashMap(java.util.HashMap) ApiRequest(run.wallet.iota.api.requests.ApiRequest) WebGetExchangeRatesRequestHandler(run.wallet.iota.api.handler.WebGetExchangeRatesRequestHandler)

Example 5 with RequestHandler

use of run.wallet.iota.api.handler.RequestHandler in project run-wallet-android by runplay.

the class IotaApiProvider method loadRequestMap.

private void loadRequestMap() {
    Map<Class<? extends ApiRequest>, RequestHandler> requestHandlerMap = new HashMap<>();
    AddressSecurityChangeRequestHandler addressSecurity = new AddressSecurityChangeRequestHandler(iotaApi, context);
    AddNeighborsRequestHandler addNeighborsAction = new AddNeighborsRequestHandler(iotaApi, context);
    AuditAddressesRequestHandler auditAddresses = new AuditAddressesRequestHandler(iotaApi, context);
    AutoNudgeHandler autoNudge = new AutoNudgeHandler(iotaApi, context);
    RefreshUsedAddressesHandler refreshUsed = new RefreshUsedAddressesHandler(iotaApi, context);
    FindTransactionsRequestHandler findTransactionsAction = new FindTransactionsRequestHandler(iotaApi, context);
    GetBundleRequestHandler getBundleAction = new GetBundleRequestHandler(iotaApi, context);
    GetNeighborsRequestHandler getNeighborsAction = new GetNeighborsRequestHandler(iotaApi, context);
    GetNewAddressRequestHandler getNewAddressAction = new GetNewAddressRequestHandler(iotaApi, context);
    GetAccountDataRequestHandler getAccountDataAction = new GetAccountDataRequestHandler(iotaApi, context);
    RemoveNeighborsRequestHandler removeNeighborsAction = new RemoveNeighborsRequestHandler(iotaApi, context);
    ReplayBundleRequestHandler replayBundleAction = new ReplayBundleRequestHandler(iotaApi, context);
    SendTransferRequestHandler sendTransferAction = new SendTransferRequestHandler(iotaApi, context);
    NodeInfoRequestHandler nodeInfoAction = new NodeInfoRequestHandler(iotaApi, context);
    GetFirstLoadRequestHandler firstLoad = new GetFirstLoadRequestHandler(iotaApi, context);
    NudgeRequestHandler nudgeRequest = new NudgeRequestHandler(iotaApi, context);
    GetBalanceAndFormatRequestHandler getBalanceAndFormatRequest = new GetBalanceAndFormatRequestHandler(iotaApi, context);
    requestHandlerMap.put(refreshUsed.getType(), refreshUsed);
    requestHandlerMap.put(autoNudge.getType(), autoNudge);
    requestHandlerMap.put(nudgeRequest.getType(), nudgeRequest);
    requestHandlerMap.put(addressSecurity.getType(), addressSecurity);
    requestHandlerMap.put(auditAddresses.getType(), auditAddresses);
    requestHandlerMap.put(firstLoad.getType(), firstLoad);
    requestHandlerMap.put(addNeighborsAction.getType(), addNeighborsAction);
    requestHandlerMap.put(findTransactionsAction.getType(), findTransactionsAction);
    requestHandlerMap.put(getBundleAction.getType(), getBundleAction);
    requestHandlerMap.put(getNeighborsAction.getType(), getNeighborsAction);
    requestHandlerMap.put(getNewAddressAction.getType(), getNewAddressAction);
    requestHandlerMap.put(getAccountDataAction.getType(), getAccountDataAction);
    requestHandlerMap.put(removeNeighborsAction.getType(), removeNeighborsAction);
    requestHandlerMap.put(replayBundleAction.getType(), replayBundleAction);
    requestHandlerMap.put(sendTransferAction.getType(), sendTransferAction);
    requestHandlerMap.put(nodeInfoAction.getType(), nodeInfoAction);
    requestHandlerMap.put(getBalanceAndFormatRequest.getType(), getBalanceAndFormatRequest);
    this.requestHandlerMap = requestHandlerMap;
}
Also used : NodeInfoRequestHandler(run.wallet.iota.api.handler.NodeInfoRequestHandler) GetFirstLoadRequestHandler(run.wallet.iota.api.handler.GetFirstLoadRequestHandler) HashMap(java.util.HashMap) FindTransactionsRequestHandler(run.wallet.iota.api.handler.FindTransactionsRequestHandler) AutoNudgeHandler(run.wallet.iota.api.handler.AutoNudgeHandler) AuditAddressesRequestHandler(run.wallet.iota.api.handler.AuditAddressesRequestHandler) GetNeighborsRequestHandler(run.wallet.iota.api.handler.GetNeighborsRequestHandler) GetNewAddressRequestHandler(run.wallet.iota.api.handler.GetNewAddressRequestHandler) AddressSecurityChangeRequestHandler(run.wallet.iota.api.handler.AddressSecurityChangeRequestHandler) ApiRequest(run.wallet.iota.api.requests.ApiRequest) GetBundleRequestHandler(run.wallet.iota.api.handler.GetBundleRequestHandler) RemoveNeighborsRequestHandler(run.wallet.iota.api.handler.RemoveNeighborsRequestHandler) ReplayBundleRequestHandler(run.wallet.iota.api.handler.ReplayBundleRequestHandler) SendTransferRequestHandler(run.wallet.iota.api.handler.SendTransferRequestHandler) RefreshUsedAddressesHandler(run.wallet.iota.api.handler.RefreshUsedAddressesHandler) GetBalanceAndFormatRequestHandler(run.wallet.iota.api.handler.GetBalanceAndFormatRequestHandler) GetAccountDataRequestHandler(run.wallet.iota.api.handler.GetAccountDataRequestHandler) GetBundleRequestHandler(run.wallet.iota.api.handler.GetBundleRequestHandler) RemoveNeighborsRequestHandler(run.wallet.iota.api.handler.RemoveNeighborsRequestHandler) GetNewAddressRequestHandler(run.wallet.iota.api.handler.GetNewAddressRequestHandler) GetFirstLoadRequestHandler(run.wallet.iota.api.handler.GetFirstLoadRequestHandler) GetBalanceAndFormatRequestHandler(run.wallet.iota.api.handler.GetBalanceAndFormatRequestHandler) ReplayBundleRequestHandler(run.wallet.iota.api.handler.ReplayBundleRequestHandler) NudgeRequestHandler(run.wallet.iota.api.handler.NudgeRequestHandler) FindTransactionsRequestHandler(run.wallet.iota.api.handler.FindTransactionsRequestHandler) GetNeighborsRequestHandler(run.wallet.iota.api.handler.GetNeighborsRequestHandler) AddressSecurityChangeRequestHandler(run.wallet.iota.api.handler.AddressSecurityChangeRequestHandler) AuditAddressesRequestHandler(run.wallet.iota.api.handler.AuditAddressesRequestHandler) RequestHandler(run.wallet.iota.api.handler.RequestHandler) NodeInfoRequestHandler(run.wallet.iota.api.handler.NodeInfoRequestHandler) AddNeighborsRequestHandler(run.wallet.iota.api.handler.AddNeighborsRequestHandler) SendTransferRequestHandler(run.wallet.iota.api.handler.SendTransferRequestHandler) AddNeighborsRequestHandler(run.wallet.iota.api.handler.AddNeighborsRequestHandler) NudgeRequestHandler(run.wallet.iota.api.handler.NudgeRequestHandler) GetAccountDataRequestHandler(run.wallet.iota.api.handler.GetAccountDataRequestHandler)

Aggregations

RequestHandler (run.wallet.iota.api.handler.RequestHandler)6 HashMap (java.util.HashMap)3 ApiRequest (run.wallet.iota.api.requests.ApiRequest)3 ApiResponse (run.wallet.iota.api.responses.ApiResponse)3 NetworkError (run.wallet.iota.api.responses.error.NetworkError)3 AddNeighborsRequestHandler (run.wallet.iota.api.handler.AddNeighborsRequestHandler)2 AddressSecurityChangeRequestHandler (run.wallet.iota.api.handler.AddressSecurityChangeRequestHandler)2 AuditAddressesRequestHandler (run.wallet.iota.api.handler.AuditAddressesRequestHandler)2 FindTransactionsRequestHandler (run.wallet.iota.api.handler.FindTransactionsRequestHandler)2 GetAccountDataRequestHandler (run.wallet.iota.api.handler.GetAccountDataRequestHandler)2 GetBalanceAndFormatRequestHandler (run.wallet.iota.api.handler.GetBalanceAndFormatRequestHandler)2 GetBundleRequestHandler (run.wallet.iota.api.handler.GetBundleRequestHandler)2 GetFirstLoadRequestHandler (run.wallet.iota.api.handler.GetFirstLoadRequestHandler)2 GetNeighborsRequestHandler (run.wallet.iota.api.handler.GetNeighborsRequestHandler)2 GetNewAddressRequestHandler (run.wallet.iota.api.handler.GetNewAddressRequestHandler)2 MessageFirstLoadRequestHandler (run.wallet.iota.api.handler.MessageFirstLoadRequestHandler)2 MessageNewAddressRequestHandler (run.wallet.iota.api.handler.MessageNewAddressRequestHandler)2 MessageSendRequestHandler (run.wallet.iota.api.handler.MessageSendRequestHandler)2 NodeInfoRequestHandler (run.wallet.iota.api.handler.NodeInfoRequestHandler)2 NudgeRequestHandler (run.wallet.iota.api.handler.NudgeRequestHandler)2