async function copy_LogRecords() {
    const dateType_LogRecord = 'LogRecord';
    // Geotab expect the client to maintain the polling status.
    // The marker returned by the latest call to the API must be passed to the next one
    // as the fromVersion parameter. It is stored in the local file system to survive
    // restarts of the script.
    let fromVersion = await loadFromVersion(dateType_LogRecord);

    // The loop should run infinitely in the production environment, with the DEBUG_ITERATIONS_LIMIT
    // constant set to 0 at the top of this script. Early exit is supported for debug purposes.
    let iterationsLeft = DEBUG_ITERATIONS_LIMIT;
    do {
        let result = await readGeotabRecords(dateType_LogRecord, fromVersion);
        if (Array.isArray(result.data) && result.data.length > 0) {
            fromVersion = result.toVersion;
            let statusCode = await post_LogRecords(result.data);
            console.info(`Got SAP status code: ${statusCode}\n`);
            await storeFromVersion(dateType_LogRecord, fromVersion);
        } else {
            // The fetch returned no records, wait to reduce the polling load
            await sleep(POLLING_DELAY_MS);
        }
    } while (DEBUG_ITERATIONS_LIMIT <= 0 || --iterationsLeft > 0);
}
/**
 * Poll Geotab for records of typeName 'LogRecord' and POST them to IoT Service.
 */
Poll Geotab for records of typeName 'LogRecord' and POST them to IoT Service.
Poll Geotab for records of typeName ' LogRecord ' and POST them to IoT Service .
async function copy_LogRecords() {
    const dateType_LogRecord = 'LogRecord';
    let fromVersion = await loadFromVersion(dateType_LogRecord);
    let iterationsLeft = DEBUG_ITERATIONS_LIMIT;
    do {
        let result = await readGeotabRecords(dateType_LogRecord, fromVersion);
        if (Array.isArray(result.data) && result.data.length > 0) {
            fromVersion = result.toVersion;
            let statusCode = await post_LogRecords(result.data);
            console.info(`Got SAP status code: ${statusCode}\n`);
            await storeFromVersion(dateType_LogRecord, fromVersion);
        } else {
            await sleep(POLLING_DELAY_MS);
        }
    } while (DEBUG_ITERATIONS_LIMIT <= 0 || --iterationsLeft > 0);
}
async function copy_LogRecords ( ) { const dateType_LogRecord = 'LogRecord' ; let fromVersion = await loadFromVersion ( dateType_LogRecord ) ; let iterationsLeft = DEBUG_ITERATIONS_LIMIT ; do { let result = await readGeotabRecords ( dateType_LogRecord , fromVersion ) ; if ( Array . isArray ( result . data ) && result . data . length > 0 ) { fromVersion = result . toVersion ; let statusCode = await post_LogRecords ( result . data ) ; console . info ( ` ${ statusCode } \n ` ) ; await storeFromVersion ( dateType_LogRecord , fromVersion ) ; } else { await sleep ( POLLING_DELAY_MS ) ; } } while ( DEBUG_ITERATIONS_LIMIT <= 0 || -- iterationsLeft > 0 ) ; }
Poll Geotab for records of typeName 'LogRecord' and POST them to IoT Service.
Poll Geotab for records of typeName ' LogRecord ' and POST them to IoT Service .
// Geotab expect the client to maintain the polling status. // The marker returned by the latest call to the API must be passed to the next one // as the fromVersion parameter. It is stored in the local file system to survive // restarts of the script. // The loop should run infinitely in the production environment, with the DEBUG_ITERATIONS_LIMIT // constant set to 0 at the top of this script. Early exit is supported for debug purposes. // The fetch returned no records, wait to reduce the polling load