public function getRecordIdBatches($batchSize = null, $filterLogic = null, $recordIdFieldName = null)
    {
        $recordIdBatches = array();
        
        #-----------------------------------
        # Check arguments
        #-----------------------------------
        if (!isset($batchSize)) {
            $message = 'The number of batches was not specified.';
            $this->errorHandler->throwException($message, ErrorHandlerInterface::INVALID_ARGUMENT);
        } elseif (!is_int($batchSize)) {
            $message = "The batch size argument has type '".gettype($batchSize).'", '
                .'but it should have type integer.';
                $this->errorHandler->throwException($message, ErrorHandlerInterface::INVALID_ARGUMENT);
        } elseif ($batchSize < 1) {
            $message = 'The batch size argument is less than 1. It needs to be at least 1.';
            $this->errorHandler->throwException($message, ErrorHandlerInterface::INVALID_ARGUMENT);
        } // @codeCoverageIgnore
        
        $filterLogic = $this->processFilterLogicArgument($filterLogic);
        
        if (!isset($recordIdFieldName)) {
            $recordIdFieldName = $this->getRecordIdFieldName();
        }
        
        $records = $this->exportRecordsAp(
            ['fields' => [$recordIdFieldName], 'filterLogic' => $filterLogic]
        );
        $recordIds = array_column($records, $recordIdFieldName);
        $recordIds = array_unique($recordIds);  # Remove duplicate record IDs
        
        $numberOfRecordIds = count($recordIds);
        
        $position = 0;
        for ($position = 0; $position < $numberOfRecordIds; $position += $batchSize) {
            $recordIdBatch = array();
            $recordIdBatch = array_slice($recordIds, $position, $batchSize);
            array_push($recordIdBatches, $recordIdBatch);
        }
        
        return $recordIdBatches;
    }