async function readGeotabRecords(typeName, fromVersion) {
    // Start fetching records from 7 days ago if no valid fromVersion is provided.
    const startDate = new Date((new Date()).getTime() - (7 * 24 * 60 * 60 * 1000)).toISOString();
    return new Promise(function (resolve, reject) {
        geotab.call('GetFeed', {
            fromVersion,
            typeName,
            resultsLimit: MAX_RECORDS_PER_ITERATION,
            search: {
                fromDate: startDate
            }
        }, function (error, result) {
            if (error) {
                console.error('Got error:', error);
                reject(Error(error));
            } else {
                console.debug(
                    `Got ${typeName}, toVersion: ${result.toVersion}, number or records: ${result.data.length}`);
                // Uncomment the next line to see the full first record.
                // console.debug('First record:', JSON.stringify(result.data[0], null, 4));
                resolve(result);
            }
        });
    });
}
/**
 * Poll Geotab for records of the given type.
 */
Poll Geotab for records of the given type.
Poll Geotab for records of the given type .
async function readGeotabRecords(typeName, fromVersion) {
    const startDate = new Date((new Date()).getTime() - (7 * 24 * 60 * 60 * 1000)).toISOString();
    return new Promise(function (resolve, reject) {
        geotab.call('GetFeed', {
            fromVersion,
            typeName,
            resultsLimit: MAX_RECORDS_PER_ITERATION,
            search: {
                fromDate: startDate
            }
        }, function (error, result) {
            if (error) {
                console.error('Got error:', error);
                reject(Error(error));
            } else {
                console.debug(
                    `Got ${typeName}, toVersion: ${result.toVersion}, number or records: ${result.data.length}`);
                resolve(result);
            }
        });
    });
}
async function readGeotabRecords ( typeName , fromVersion ) { const startDate = new Date ( ( new Date ( ) ) . getTime ( ) - ( 7 * 24 * 60 * 60 * 1000 ) ) . toISOString ( ) ; return new Promise ( function ( resolve , reject ) { geotab . call ( 'GetFeed' , { fromVersion , typeName , resultsLimit : MAX_RECORDS_PER_ITERATION , search : { fromDate : startDate } } , function ( error , result ) { if ( error ) { console . error ( 'Got error:' , error ) ; reject ( Error ( error ) ) ; } else { console . debug ( ` ${ typeName } ${ result . toVersion } ${ result . data . length } ` ) ; resolve ( result ) ; } } ) ; } ) ; }
Poll Geotab for records of the given type.
Poll Geotab for records of the given type .
// Start fetching records from 7 days ago if no valid fromVersion is provided. // Uncomment the next line to see the full first record. // console.debug('First record:', JSON.stringify(result.data[0], null, 4));