zoho-wd-pools

1.0.0 • Public • Published

zoho-wd-pools

onix

ZohoWorkDrive module, which makes communication with ZohoWorkDrive API easier, based in 'zoho-workdrive-api' and have auto set tokens mechanism

Install

npm i zoho-wd-pools

API

Methods

Examples

Require module

const ZohoWorkDriveApi = require('zoho-wd-pools');
const ZWDApi = new ZohoWorkDriveApi(options);

ZWDApi.addConection('myPool', {
    clientId,
    clientSecret,
    refreshToken,
    domain,
}).then(res => {
    // console.log(res); //return true
});
Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.clientId String Zoho app clientId true
params.clientSecret String Zoho app clientSecret true
params.refreshToken String Zoho app refreshToken true
params.domain String Zoho api domain true

team

team.all

Return all user`s teams info

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

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.zuid String Zoho user`s account id true

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

team.info

Return user`s team by id

Returns: Object - User`s team object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.teamId String Id of the desired team true

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

team.currentUser

Return current user for team

Returns: Object - current user object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.teamId String Id of the desired team`s user true
zWDApi.team
    .currentUser('myPool', {
        teamId: 'Zoho team`s id',
    })
    .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

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.teamId String Id of the desired team`s ws true

zWDApi.ws
    .all('myPool', {
        teamId: 'Zoho team`s id',
    })
    .then(data => {
        // console.log(data)
        // returns data with current team`s workspases
    });

ws.info

Return current workspase by id

Returns: Object - current workspase object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.teamId String Id of the desired team`s ws true
params.wsId String Id of the desired ws true

zWDApi.ws
    .info('myPool', {
        teamId: 'Zoho team`s id',
        wsId: 'Zoho ws id',
    })
    .then(data => {
        // console.log(data)
        // returns data with current workspace
    });

ws.create

Create new workspace

Returns: Object - new workspase object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.teamId String Id of the desired team`s ws true
params.name String Name your new workspace true
params.isPublicTeam Boolean Is public within team false
params.description String description for your new workspace false

zWDApi.ws
    .create('myPool', {
        teamId: 'Zoho team`s id',
        name: 'myWs',
        isPublicTeam: 'true',
        description: 'new workspace for example',
    })
    .then(data => {
        // console.log(data)
        // returns data with new workspace
    });

ws.rename

Rename current workspace

Returns: Object - object with workspase id and new name

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.wsId String Id of the desired ws true
params.name String New name your workspace true

zWDApi.ws
    .rename('myPool', {
        wsId: 'Zoho ws id',
        name: 'renamedWs',
    })
    .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

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.wsId String Id of the desired ws true

zWDApi.ws
    .delete('myPool', {
        wsId: 'Zoho ws id',
    })
    .then(data => {
        // console.log(data)
        // returns undefined
    });

ws.users

ws.users.all

Return current workspase`s users

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

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.wsId String Id of the desired ws true

zWDApi.ws.users
    .all('myPool', {
        wsId: 'Zoho ws id',
    })
    .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

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.wsId String Id of the desired ws true
params.email String New user email true
params.role String New user role (Admin, Organizer, Editor, Viewer) true

zWDApi.ws.users
    .add('myPool', {
        wsId: 'Zoho ws id',
        email: 'new.user@mail.com',
        role: 'Admin',
    })
    .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

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.userId String Id of the desired user true
params.role String New role of user (Admin, Organizer, Editor, Viewer) true

zWDApi.ws.users
    .newRole('myPool', {
        userId: 'Zoho ws user`s id',
        role: 'Organizer',
    })
    .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

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.userId String Id of the desired user true

zWDApi.ws.users
    .delete('myPool', {
        userId: 'Zoho ws user`s id',
    })
    .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

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.userId String Id user that desired privatespace true

zWDApi.ps
    .info('myPool', {
        userId: 'Zoho team`s current user`s id',
    })
    .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

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.psId String Id of the desired privatespace true

zWDApi.ps
    .files('myPool', {
        psId: 'Zoho ps id',
    })
    .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

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.folderId String Id of the desired folder true

zWDApi.folder
    .info('myPool', {
        folderId: 'Zoho folder`s id',
    })
    .then(data => {
        // console.log(data)
        // returns data with current folder
    });

folder.create

Return info about new folder

Returns: Object - new folder object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.parentId String Id of parent folder for new true
params.name String Name of new folder true

zWDApi.folder
    .create('myPool', {
        parentId: 'Zoho folder`s id',
        name: 'myNewFolder',
    })
    .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

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.folderId String Id of the desired folder true
params.name String New name your folder true

zWDApi.folder
    .rename('myPool', {
        folderId: 'Zoho folder`s id',
        name: 'renamedFolder',
    })
    .then(data => {
        // console.log(data)
        // returns data with folder
    });

folder.copy

Copy current folder by id to folder with current id

Returns: Object - сopied folder object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.folderId String Id of the desired folder true
params.parentId String Id of the folder where will be copy current folder true

zWDApi.folder
    .copy('myPool', {
        folderId: 'Zoho folder`s id',
        parentId: 'Zoho folder`s id',
    })
    .then(data => {
        // console.log(data)
        // returns data with сopied folder
    });

folder.delete

Delete folder

Returns: Object - object with message about delete folder

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.folderId String Id of the desired folder true

zWDApi.folder
    .delete('myPool', {
        folderId: 'Zoho folder`s id',
    })
    .then(data => {
        // console.log(data)
        // returns undefined
    });

files

files.info

Return info about any file by id

Returns: Object - current file object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.fileId String Id of the desired file true

zWDApi.files
    .info('myPool', {
        fileId: 'Zoho file`s id',
    })
    .then(data => {
        // console.log(data)
        // returns data with current file
    });

files.create

Create file

Returns: Object - new file object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.parentId String Id of the folder where will be file true
params.name String Name of your new file true
params.zFileType String Type of your new file (zw - writer native, zohosheet - sheet native, zohoshow - show native ) true

zWDApi.files
    .create('myPool', {
        parentId: 'Zoho folder`s id',
        name: 'my_table',
        zFileType: 'zohosheet',
    })
    .then(data => {
        // console.log(data)
        // returns data with new file
    });

files.upload

Upload file

Returns: Object - current file object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.parentId String Id of the folder where will be file true
params.name String Name of your new file true
params.overrideNameExist Boolean Override if same file exist in a folder true
params.readableStream file Readable Stream with file's content true

zWDApi.files
    .upload('myPool', {
        parentId: 'Zoho folder`s id',
        name: 'myImg',
        overrideNameExist: 'true',
        readableStream: readableStream,
    })
    .then(data => {
        // console.log(data)
        // returns data with current file
    });

files.download

Download file by id

Returns: String - String, that simple transform to buffer

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.fileId String Id of the desired file true

zWDApi.files
    .download('myPool', {
        fileId: 'Zoho file`s id',
    })
    .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

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.fileId String Id of the desired file true
params.name String New name your file true

zWDApi.files
    .rename('myPool', {
        fileId: 'Zoho file`s id',
        name: 'renamedFolder',
    })
    .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

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.idArr String[] Array with file`s id true
params.parentId String Id of the folder where will be copy current files true

zWDApi.files
    .copy('myPool', {
        idArr: ['Zoho file`s id', 'Zoho file`s id', 'Zoho file`s id'],
        parentId: 'Zoho folder`s id',
    })
    .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

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.idArr String[] Array with file`s id true

zWDApi.files
    .delete('myPool', {
        idArr: ['Zoho file`s id', 'Zoho file`s id', 'Zoho file`s id'],
    })
    .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

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.idArr Object[] Array with file`s id and new parentId true

zWDApi.files
    .move('myPool', {
        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' },
        ],
    })
    .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

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.folderId String Id of the parent folder true

zWDApi.files
    .list('myPool', {
        folderId: 'Zoho folder`s id',
    })
    .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

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.link String link for request true

zWDApi
    .url('myPool', {
        link: 'https://workdrive.zoho.com/api/v1/files/<id>',
    })
    .then(data => {
        // console.log(data)
        // returns data with result object
    });

share

share.createShare

Create Share Link

Returns: Object - new Share Link object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.resourceId String Id of the file true
params.name String Name of new link true
params.allowDownload Boolean download Possible true
params.role String role true
params.requestUserData Boolean Request User Data false
params.password String password false
params.expiredDate String Expired date false
params.inputFields String[] fields array false
params.inputFields.field_name String field name true
params.inputFields.field_type String field type true
params.inputFields.is_name_field Boolean is field name false

zWDApi
    .share.createShare('myPool', {
        name,
        inputFields: [{"field_name":"Name","field_type": "TEXT",
        "is_name_field" : true
        }],
        requestUserData: true,
        allowDownload: true,
        password: 'pass',
        expiredDate: "2020-09-26",
        role: 'edit',
    })
    .then(data => {
        // console.log(data)
    });

share.createDownLoad

Create Download Link

Returns: Object - new Download Link object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.resourceId String Id of the file true
params.name String Name of new link true
params.requestUserData Boolean Request User Data false
params.expiredDate String Expired date false
params.downloadLimit Number count downloads false

zWDApi.share
    .createDownLoad('myPool', {
        resourceId: 'fileId',
        name: 'linkName',
        requestUserData: true,
        expiredDate: '2020-09-26',
        downloadLimit: 5,
    })
    .then(data => {
        // console.log(data)
    });

share.update

Update Link

Returns: Object - updated Link object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.linkId String link Id true
params.attributes Object true
params.attributes.expiredDate String Expired date false
params.attributes.allowDownload Boolean download Possible false
params.attributes.isPasswordProtected Boolean Request User Data false
params.attributes.password String password false

zWDApi.share
    .update('myPool', {
        attributes: {
            allowDownload: false,
            password: 'updatepassword1',
            isPasswordProtected: true,
            expiredDate: '2020-09-30',
        },
        linkId: 'Link id',
    })
    .then(data => {
        // console.log(data)
    });

share.delete

Delete Shared Link

Returns: Object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.linkId String link Id true

zWDApi.share
    .delete('myPool', {
        linkId: 'Link id',
    })
    .then(data => {
        // console.log(data)
    });

customMeta

customMeta.dataTemp

customMeta.dataTemp.list

Return info about all templates for your team

Returns: Object[] - templates array of object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.teamId String Zoho team`s id true

zWDApi.customMeta.dataTemp
    .list('myPool', {
        teamId: 'Zoho team`s id',
    })
    .then(data => {
        // console.log(data)
        // returns data with all templates for your team
    });

customMeta.dataTemp.create

Create customData template

Returns: Object - new template object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.teamId String Id your zoho team true
params.name String Name of new template true
params.description String false

zWDApi.customMeta.dataTemp
    .create('myPool', {
        teamId,
        name,
        description,
    })
    .then(data => {
        // console.log(data)
    });

customMeta.dataTemp.update

Update customData template

Returns: Object - updated template object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.templateId String Template id true
params.name String Name template true
params.description String false

zWDApi.customMeta.dataTemp
    .update('myPool', {
        templateId,
        name,
        description,
    })
    .then(data => {
        // console.log(data)
    });

customMeta.dataTemp.delete

Delete customData template

Returns: Object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.templateId String template Id true

zWDApi.customMeta.dataTemp
    .delete('myPool', {
        templateId,
    })
    .then(data => {
        // console.log(data)
    });

customMeta.fields

customMeta.fields.list

Return info about all custom fields for your template

Returns: Object[] - fields array of object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.templateId String Template id true

zWDApi.customMeta.fields
    .list('myPool', {
        templateId,
    })
    .then(data => {
        // console.log(data)
        // returns data with all custom fields for your template
    });

customMeta.fields.create

Create custom field

Returns: Object - new custom field object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.templateId String Template id true
params.name String Name of new custom field true
params.properties Object false

zWDApi.customMeta.fields
    .create('myPool', {
        name: 'c-field',
        templateId,
        index: 0,
        type: 'multiline_text',
        properties: {
            description: `my Custom field`,
            is_mandatory: false,
        },
    })
    .then(data => {
        // console.log(data)
    });

Note : index attribute represents position of Custom Field inside Data Template.

Other Custom Field types with

supported field properties:

  1. text field_properties:

    1. description
    2. default_value
    3. max_char_length
    4. is_mandatory
  2. multiline_text field_properties:

    1. description
    2. is_mandatory
    3. number field_properties:
    4. description
    5. default_value
    6. min_value
    7. max_value
    8. is_mandatory
  3. datetime field_properties:

    1. description
    2. default_value - (in milli seconds)
    3. is_mandatory
  4. date field_properties:

    1. description
    2. default_value - (in milli seconds)
    3. is_mandatory
  5. yes_or_no field_properties:

    1. description
    2. default_value - (in boolean)
    3. is_mandatory
  6. dropdown / radio / checkbox options: Example: ["One","Two", "Three"] field_properties:

    1. description
    2. default_value
    3. is_mandatory
  7. email field_properties:

    1. description
    2. is_mandatory

customMeta.fields.update

Update custom field

Returns: Object - updated custom field object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.fieldId String custom field id true
params.name String Name of field false

zWDApi.customMeta.fields
    .update('myPool', {
        fieldId,
        name,
    })
    .then(data => {
        // console.log(data)
    });

customMeta.fields.delete

Delete custom field

Returns: Object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.fieldId String custom field Id true

zWDApi.customMeta.fields
    .delete('myPool', {
        fieldId: 'field id',
    })
    .then(data => {
        // console.log(data)
    });

customMeta.meta

customMeta.meta.create

Create meta data for file

Returns: Object - new meta object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.templateId String Template id true
params.resourceId String file id true
params.customData Object true
params.customData.custom_field_id String custom field id true
params.customData.value String saved data true

zWDApi.customMeta.meta
    .create('myPool', {
        templateId,
        resourceId,
        customData: [
            {
                custom_field_id,
                value,
            },
            {
                custom_field_id,
                value,
            },
        ],
    })
    .then(data => {
        // console.log(data)
    });

customMeta.meta.update

Update meta data

Returns: Object - updated meta object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.metadataId String file metadataId id true
params.customData Object true
params.customData.custom_field_id String custom field id true
params.customData.value String saved data true

zWDApi.customMeta.meta
    .update('myPool', {
        metadataId,
        customData: [
            {
                custom_field_id,
                value,
            },
            {
                custom_field_id,
                value,
            },
        ],
    })
    .then(data => {
        // console.log(data)
    });

customMeta.meta.delete

Delete file meta data

Returns: Object

Param Type Description Required
pool string name of the pool you would like, of use true
params Object
params.metadataId String file metadataId id true

zWDApi.customMeta.meta
    .delete('myPool', {
        metadataId,
    })
    .then(data => {
        // console.log(data)
    });

Readme

Keywords

Package Sidebar

Install

npm i zoho-wd-pools

Weekly Downloads

24

Version

1.0.0

License

MIT

Unpacked Size

86.7 kB

Total Files

18

Last publish

Collaborators

  • ya_myn