class PermRemoveAccountsFromAllowlist implements JsonRpcMethod {

  @Override
  @SuppressWarnings("unchecked")
  public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
    final List<String> accountsList = requestContext.getRequiredParameter(0, List.class);
    if (allowlistController.isPresent()) {
      final AllowlistOperationResult removeResult =
          allowlistController.get().removeAccounts(accountsList);

      switch (removeResult) {
        case ERROR_EMPTY_ENTRY:
          return new JsonRpcErrorResponse(
              requestContext.getRequest().getId(), JsonRpcError.ACCOUNT_ALLOWLIST_EMPTY_ENTRY);
        case ERROR_INVALID_ENTRY:
          return new JsonRpcErrorResponse(
              requestContext.getRequest().getId(), JsonRpcError.ACCOUNT_ALLOWLIST_INVALID_ENTRY);
        case ERROR_ABSENT_ENTRY:
          return new JsonRpcErrorResponse(
              requestContext.getRequest().getId(), JsonRpcError.ACCOUNT_ALLOWLIST_ABSENT_ENTRY);
        case ERROR_DUPLICATED_ENTRY:
          return new JsonRpcErrorResponse(
              requestContext.getRequest().getId(), JsonRpcError.ACCOUNT_ALLOWLIST_DUPLICATED_ENTRY);
        case ERROR_ALLOWLIST_PERSIST_FAIL:
          return new JsonRpcErrorResponse(
              requestContext.getRequest().getId(), JsonRpcError.ALLOWLIST_PERSIST_FAILURE);
        case ERROR_ALLOWLIST_FILE_SYNC:
          return new JsonRpcErrorResponse(
              requestContext.getRequest().getId(), JsonRpcError.ALLOWLIST_FILE_SYNC);
        case SUCCESS:
          return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
        default:
          throw new IllegalStateException(
              "Unmapped result from AccountLocalConfigPermissioningController");
      }
    } else {
      return new JsonRpcErrorResponse(
          requestContext.getRequest().getId(), JsonRpcError.ACCOUNT_ALLOWLIST_NOT_ENABLED);
    }
  }

  public  PermRemoveAccountsFromAllowlist(
      final Optional<AccountLocalConfigPermissioningController> allowlistController);

}