test/quickstart.js
/**
 * Lists the names and IDs of up to 10 files.
 *
 * @param {google.auth.OAuth2} auth An authorized OAuth2 client.
 */
Lists the names and IDs of up to 10 files.
@param {google.auth.OAuth2} auth An authorized OAuth2 client.
Lists the names and IDs of up to 10 files . @param { google . auth . OAuth2 } auth An authorized OAuth2 client .
function listFiles(auth) {
    var service = new DriveConfigService(auth);
    service.list().then(files => {
        console.log(files);
        return service.create('quickstart-test-config.json', { foo: 'bar' });
    }).then(response => {
        console.log(response);
        return service.get(response.id);
    }).then(response => {
        console.log(response.data);
        response.data.fizz = 'buzz';
        return service.update(response.id, response.data);
    }).then(response => {
        return service.getByName(response.name);
    }).then(file => {
        console.log(file);
        return service.list();
    }).then(files => {
        console.log(files);
        let destroyCalls = [];
        for(let file of files) {
            if(file.name == 'quickstart-test-config.json') {
                destroyCalls.push(service.destroy(file.id));
            }
        }
        return Promise.all(destroyCalls);
    }).then(() => {
        return service.list();
    }).then(files => {
        console.log(files);
    }).catch(err => {
        console.error(err.message);
    });
}
function listFiles ( auth ) { var service = new DriveConfigService ( auth ) ; service . list ( ) . then ( files => { console . log ( files ) ; return service . create ( 'quickstart-test-config.json' , { foo : 'bar' } ) ; } ) . then ( response => { console . log ( response ) ; return service . get ( response . id ) ; } ) . then ( response => { console . log ( response . data ) ; response . data . fizz = 'buzz' ; return service . update ( response . id , response . data ) ; } ) . then ( response => { return service . getByName ( response . name ) ; } ) . then ( file => { console . log ( file ) ; return service . list ( ) ; } ) . then ( files => { console . log ( files ) ; let destroyCalls = [ ] ; for ( let file of files ) { if ( file . name == 'quickstart-test-config.json' ) { destroyCalls . push ( service . destroy ( file . id ) ) ; } } return Promise . all ( destroyCalls ) ; } ) . then ( ( ) => { return service . list ( ) ; } ) . then ( files => { console . log ( files ) ; } ) . catch ( err => { console . error ( err . message ) ; } ) ; }
Lists the names and IDs of up to 10 files.
Lists the names and IDs of up to 10 files .