public function importRecords(
        $records,
        $format = 'php',
        $type = 'flat',
        $overwriteBehavior = 'normal',
        $dateFormat = 'YMD',
        $returnContent = 'count',
        $forceAutoNumber = false
    ) {
            
        $data = array (
            'token'         => $this->apiToken,
            'content'       => 'record',
            'returnFormat'  => 'json'
        );
            
        #---------------------------------------
        # Process format
        #---------------------------------------
        $legalFormats = array('csv', 'json', 'odm', 'php', 'xml');
        $data['format'] = $this->processFormatArgument($format, $legalFormats);
        $data['data']   = $this->processImportDataArgument($records, 'records', $format);
        $data['type']   = $this->processTypeArgument($type);
            
        $data['overwriteBehavior'] = $this->processOverwriteBehaviorArgument($overwriteBehavior);
        $data['forceAutoNumber']   = $this->processForceAutoNumberArgument($forceAutoNumber);
        $data['returnContent']     = $this->processReturnContentArgument($returnContent, $forceAutoNumber);
        $data['dateFormat']        = $this->processDateFormatArgument($dateFormat);
        
        $result = $this->connection->callWithArray($data);

        $this->processNonExportResult($result);
        
        
        #--------------------------------------------------------------------------
        # Process result, which should either be a count of the records imported,
        # or a list of the record IDs that were imported
        #
        # The result should be a string in JSON for all formats.
        # Need to convert the result to a PHP data structure.
        #--------------------------------------------------------------------------
        $phpResult = json_decode($result, true); // true => return as array instead of object
        
        $jsonError = json_last_error();
        
        switch ($jsonError) {
            case JSON_ERROR_NONE:
                $result = $phpResult;
                # If this is a count, then just return the count, and not an
                # array that has a count index with the count
                if (isset($result) && is_array($result) && array_key_exists('count', $result)) {
                    $result = $result['count'];
                }
                break;
            default:
                # Hopefully the REDCap API will always return valid JSON, and this
                # will never happen.
                $message =  'JSON error ('.$jsonError.') "'.json_last_error_msg().
                    '" while processing import return value: "'.
                $result.'".';
                $this->errorHandler->throwException($message, ErrorHandlerInterface::JSON_ERROR);
                break; // @codeCoverageIgnore
        }
        
        return $result;
    }