class ErrorToActionStatusMapper {

    public ActionStatus mapActionStatusError(MessageErrorCode error, boolean withBalance, TypeAccess access) {
        ActionStatus actionStatus = ActionStatus.FAILURE_ACCOUNT;
        if (error == MessageErrorCode.ACCESS_EXCEEDED) {
            actionStatus = ActionStatus.CONSENT_LIMIT_EXCEEDED;
        } else if (error == MessageErrorCode.CONSENT_EXPIRED) {
            actionStatus = ActionStatus.CONSENT_INVALID_STATUS;
        } else if (error.getName().equals(MessageErrorCode.CONSENT_UNKNOWN_400.getName()) && error.getCode() == MessageErrorCode.CONSENT_UNKNOWN_400.getCode()) {
            actionStatus = ActionStatus.CONSENT_NOT_FOUND;
        } else if (error.getName().equals(MessageErrorCode.CONSENT_INVALID.getName())) {
            if (access == TypeAccess.TRANSACTION) {
                actionStatus = ActionStatus.FAILURE_TRANSACTION;
            } else if (access == TypeAccess.BALANCE || withBalance) {
                actionStatus = ActionStatus.FAILURE_BALANCE;
            }
        }
        return actionStatus;
    }

}