0.1.5 • Published 5 years ago

zoho-workdrive-api v0.1.5

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

zoho-workdrive-api

onix

ZohoWorkDrive module, which makes communication with ZohoWorkDrive API easier.

Install

npm i zoho-workdrive-api

API

Methods

Examples

Require module

const ZWorkDriveApi = require('zoho-workdrive-api');
const zWDApi = new ZWorkDriveApi(token, domain);
ParamTypeDescriptionRequired
paramsObject
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse

The following api methods do not require a domain and token if you passed them when creating an instance. But this structure allows you to make requests with other tokens and domains without creating a new instance of API

team

team.all

Return all user`s teams info

Returns: Object[] - User`s teams array of objects

ParamTypeDescriptionRequired
paramsObject
params.zuidStringZoho user`s account id | true
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.team
    .all({
        zuid: 'Zoho user`s id',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with info all user`s teams
    });

// If you specified a domain and token when creating an instance and want to use them:

zWDApi.team
    .all({
        zuid: 'Zoho user`s id',
    })
    .then(data => {
        // console.log(data)
        // returns data with info all user`s teams
    });

//This is typical for the following examples too

team.info

Return user`s team by id

Returns: Object - User`s team object

ParamTypeDescriptionRequired
paramsObject
params.teamIdStringId of the desired teamtrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.team
    .info({
        teamId: 'Zoho team`s id',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with team`s info
    });

team.currentUser

Return current user for team

Returns: Object - current user object

ParamTypeDescriptionRequired
paramsObject
params.teamIdStringId of the desired team`s user | true
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.team
    .currentUser({
        teamId: 'Zoho team`s id',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with current user info
    });

workspase

ws.all

Return current team`s workspases

Returns: Object[] - current team`s workspases array of objects

ParamTypeDescriptionRequired
paramsObject
params.teamIdStringId of the desired team`s ws | true
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.ws
    .all({
        teamId: 'Zoho team`s id',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with current team`s workspases
    });

ws.info

Return current workspase by id

Returns: Object - current workspase object

ParamTypeDescriptionRequired
paramsObject
params.teamIdStringId of the desired team`s ws | true
params.wsIdStringId of the desired wstrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.ws
    .info({
        teamId: 'Zoho team`s id',
        wsId: 'Zoho ws id',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with current workspace
    });

ws.create

Create new workspace

Returns: Object - new workspase object

ParamTypeDescriptionRequired
paramsObject
params.teamIdStringId of the desired team`s ws | true
params.nameStringName your new workspacetrue
params.isPublicTeamBooleanIs public within teamfalse
params.descriptionStringdescription for your new workspacefalse
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.ws
    .create({
        teamId: 'Zoho team`s id',
        name: 'myWs',
        isPublicTeam: 'true',
        description: 'new workspace for example',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with new workspace
    });

ws.rename

Rename current workspace

Returns: Object - object with workspase id and new name

ParamTypeDescriptionRequired
paramsObject
params.wsIdStringId of the desired wstrue
params.nameStringNew name your workspacetrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.ws
    .rename({
        wsId: 'Zoho ws id',
        name: 'renamedWs',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with ws id and new name
    });

ws.delete

Delete current workspace

Returns: Object - object with message about delete workspace

ParamTypeDescriptionRequired
paramsObject
params.wsIdStringId of the desired wstrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.ws
    .delete({
        wsId: 'Zoho ws id',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with message about removing ws
    });

ws.users

ws.users.all

Return current workspase`s users

Returns: Object[] - current workspase`s users array of objects

ParamTypeDescriptionRequired
paramsObject
params.wsIdStringId of the desired wstrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.ws.users
    .all({
        wsId: 'Zoho ws id',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with current workspase`s users
    });

ws.users.add

Add new user for current workspase

Returns: Object - new workspase`s user object

ParamTypeDescriptionRequired
paramsObject
params.wsIdStringId of the desired wstrue
params.emailStringNew user emailtrue
params.roleStringNew user role (Admin, Organizer, Editor, Viewer)true
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.ws.users
    .add({
        wsId: 'Zoho ws id',
        email: 'new.user@mail.com',
        role: 'Admin',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with new workspase`s user
    });

ws.users.newRole

Change user`s role

Returns: Object - object with user`s id and new role

ParamTypeDescriptionRequired
paramsObject
params.userIdStringId of the desired usertrue
params.roleStringNew role of user (Admin, Organizer, Editor, Viewer)true
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.ws.users
    .newRole({
        userId: 'Zoho ws user`s id',
        role: 'Organizer',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with user`s id and new role
    });

ws.users.delete

Delete user

Returns: Object - object with message about delete user

ParamTypeDescriptionRequired
paramsObject
params.userIdStringId of the desired usertrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.ws.users
    .delete({
        userId: 'Zoho ws user`s id',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with message about delete user
    });

privatespace

ps.info

Return user`s privatespaces

Returns: Object[] - current user`s privatespaces array of objects

ParamTypeDescriptionRequired
paramsObject
params.userIdStringId user that desired privatespacetrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.ps
    .info({
        userId: 'Zoho team`s current user`s id',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with current user`s privatespaces
    });

ps.files

Return current privatespace`s files by id

Returns: Object[] - current privatespace`s files array of objects

ParamTypeDescriptionRequired
paramsObject
params.psIdStringId of the desired privatespacetrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.ps
    .files({
        psId: 'Zoho ps id',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with current privatespace`s files
    });

folder

folder.info

Return info about any folder by id

Returns: Object - current folder object

ParamTypeDescriptionRequired
paramsObject
params.folderIdStringId of the desired foldertrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.folder
    .info({
        folderId: 'Zoho folder`s id',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with current folder
    });

folder.create

Return info about new folder

Returns: Object - new folder object

ParamTypeDescriptionRequired
paramsObject
params.parentIdStringId of parent folder for newtrue
params.nameStringName of new foldertrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.folder
    .create({
        parentId: 'Zoho folder`s id',
        name: 'myNewFolder',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with new folder
    });

folder.rename

Rename current folder by id

Returns: Object - object with folder`s id and new name

ParamTypeDescriptionRequired
paramsObject
params.folderIdStringId of the desired foldertrue
params.nameStringNew name your foldertrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.folder
    .rename({
        folderId: 'Zoho folder`s id',
        name: 'renamedFolder',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with folder`s id and new name
    });

folder.copy

Copy current folder by id to folder with current id

Returns: Object - сopied folder object

ParamTypeDescriptionRequired
paramsObject
params.folderIdStringId of the desired foldertrue
params.parentIdStringId of the folder where will be copy current foldertrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.folder
    .copy({
        folderId: 'Zoho folder`s id',
        parentId: 'Zoho folder`s id',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with сopied folder
    });

folder.delete

Delete folder

Returns: Object - object with message about delete folder

ParamTypeDescriptionRequired
paramsObject
params.folderIdStringId of the desired foldertrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.folder
    .delete({
        folderId: 'Zoho folder`s id',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with message about delete folder
    });

files

files.info

Return info about any file by id

Returns: Object - current file object

ParamTypeDescriptionRequired
paramsObject
params.fileIdStringId of the desired filetrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.files
    .info({
        fileId: 'Zoho file`s id',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with current file
    });

files.create

Create file

Returns: Object - new file object

ParamTypeDescriptionRequired
paramsObject
params.parentIdStringId of the folder where will be filetrue
params.nameStringName of your new filetrue
params.zFileTypeStringType of your new file (zw - writer native, zohosheet - sheet native, zohoshow - show native )true
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.files
    .create({
        parentId: 'Zoho folder`s id',
        name: 'my_table',
        zFileType: 'zohosheet',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with new file
    });

files.upload

Upload file

Returns: Object - current file object

ParamTypeDescriptionRequired
paramsObject
params.parentIdStringId of the folder where will be filetrue
params.nameStringName of your new filetrue
params.overrideNameExistBooleanOverride if same file exist in a foldertrue
params.readableStreamfileReadable Stream with file's contenttrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.files
    .upload({
        parentId: 'Zoho folder`s id',
        name: 'myImg',
        overrideNameExist: 'true',
        readableStream: readableStream,
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with current file
    });

files.download

Download file by id

Returns: String - String, that simple transform to buffer

ParamTypeDescriptionRequired
paramsObject
params.fileIdStringId of the desired filetrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.files
    .download({
        fileId: 'Zoho file`s id',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with file in string format
    });

files.rename

Rename current file by id

Returns: Object - object with file`s id and new name

ParamTypeDescriptionRequired
paramsObject
params.fileIdStringId of the desired filetrue
params.nameStringNew name your filetrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.files
    .rename({
        fileId: 'Zoho file`s id',
        name: 'renamedFolder',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with files`s id and new name
    });

files.copy

Copy current files by id (more files) to folder with current id

Returns: Object[] - сopied files array of object

ParamTypeDescriptionRequired
paramsObject
params.idArrString[]Array with file`s id |true
params.parentIdStringId of the folder where will be copy current filestrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.files
    .copy({
        idArr: ['Zoho file`s id', 'Zoho file`s id', 'Zoho file`s id'],
        parentId: 'Zoho folder`s id',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with сopied files
    });

files.delete

Delete current files by id (more files)

Returns: Object - object with message about delete files

ParamTypeDescriptionRequired
paramsObject
params.idArrString[]Array with file`s id |true
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.files
    .delete({
        idArr: ['Zoho file`s id', 'Zoho file`s id', 'Zoho file`s id'],
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with message about delete files
    });

files.move

Move current files by id (more files) to folder with current id

Returns: Object[] - movied files array of object

ParamTypeDescriptionRequired
paramsObject
params.idArrObject[]Array with file`s id and new parentId | true
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.files
    .move({
        idArr: [
            { id: 'Zoho file`s id', parentId: 'Zoho folder`s id' },
            { id: 'Zoho file`s id', parentId: 'Zoho folder`s id' },
            { id: 'Zoho file`s id', parentId: 'Zoho folder`s id' },
        ],
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with movied files
    });

files.list

Return info about all files by parent folder id

Returns: Object[] - folder`s files array of object

ParamTypeDescriptionRequired
paramsObject
params.folderIdStringId of the parent foldertrue
params.accessTokenStringZoho WorkDrive access tokenfalse
params.domainStringZoho api domainfalse
zWDApi.files
    .list({
        folderId: 'Zoho folder`s id',
        accessToken: accessToken,
        domain: domain,
    })
    .then(data => {
        // console.log(data)
        // returns data with folder`s files
    });

url

Return result get operation for current link (Only GET operation)

Returns: Object - result object

ParamTypeDescriptionRequired
paramsObject
params.linkStringlink for requesttrue
params.accessTokenStringZoho WorkDrive access tokenfalse
zWDApi.files
    .list({
        link: 'https://workdrive.zoho.com/api/v1/files/<id>',
        accessToken: accessToken,
    })
    .then(data => {
        // console.log(data)
        // returns data with result object
    });
0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago