Collections are used to store a custom user-defined set of items that may not all be in the same folder.
Currently, the only collection available is the favorites
collection (source).
- Get a User's Collections
- Get the Items in a Collection
- Add File to a Collection
- Remove File from a Collection
- Add Folder to a Collection
- Remove Folder from a Collection
- Add Web Link to a Collection
- Remove Web Link from a Collection
Get a list of all collections the user has defined by calling collections.getAll(callback)
.
A user always has a default collection called "Favorites" which they can add
items to.
client.collections.getAll()
.then(collections => {
/* collections -> { total_count: 1,
entries:
[ { type: 'collection',
id: '11111',
name: 'Favorites',
collection_type: 'favorites' } ],
limit: 100,
offset: 0 }
*/
});
Get a list of the items in a collection by passing the ID of the collection to
collections.getItems(collectionID, options, callback)
.
client.collections.getItems('81934', {fields: 'name', limit: 2})
.then(items => {
/* items -> { total_count: 24,
entries:
[ { type: 'folder',
id: '192429928',
sequence_id: '1',
etag: '1',
name: 'Stephen Curry Three Pointers' },
{ type: 'file',
id: '818853862',
sequence_id: '0',
etag: '0',
name: 'Warriors.jpg' } ],
offset: 0,
limit: 2 }
*/
});
To add a file to a collection, call the
files.addToCollection(fileID, collectionID, callback)
method with the IDs of the file and collection.
client.files.addToCollection('87263', '235747', callback);
To remove a file from a collection, call the
files.removeFromCollection(fileID, collectionID, callback)
method with the IDs of the file and collection.
client.files.removeFromCollection('87263', '235747', callback);
To add a folder to a collection, call the
folders.addToCollection(folderID, collectionID, callback)
method with the IDs of the folder and collection.
client.folders.addToCollection('87263', '235747', callback);
To remove a folder from a collection, call the
folders.removeFromCollection(folderID, collectionID, callback)
method with the IDs of the folder and collection.
client.folders.removeFromCollection('87263', '235747', callback);
To add a web link to a collection, call the
weblinks.addToCollection(webLinkID, collectionID, callback)
method with the IDs of the web link and collection.
client.weblinks.addToCollection('87263', '235747', callback);
To remove a web link from a collection, call the
weblinks.removeFromCollection(webLinkID, collectionID, callback)
method with the IDs of the web link and collection.
client.weblinks.removeFromCollection('87263', '235747', callback);