1.0.0 • Published 3 years ago

zoho-wd-pools v1.0.0

Weekly downloads
22
License
MIT
Repository
github
Last release
3 years ago

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
});
ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.clientIdStringZoho app clientIdtrue
params.clientSecretStringZoho app clientSecrettrue
params.refreshTokenStringZoho app refreshTokentrue
params.domainStringZoho api domaintrue

team

team.all

Return all user`s teams info

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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.zuidStringZoho 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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.teamIdStringId of the desired teamtrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.teamIdStringId 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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.teamIdStringId 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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.teamIdStringId of the desired team`s ws | true
params.wsIdStringId of the desired wstrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
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
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.wsIdStringId of the desired wstrue
params.nameStringNew name your workspacetrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.wsIdStringId of the desired wstrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.wsIdStringId of the desired wstrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.wsIdStringId of the desired wstrue
params.emailStringNew user emailtrue
params.roleStringNew 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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.userIdStringId of the desired usertrue
params.roleStringNew 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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.userIdStringId of the desired usertrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.userIdStringId user that desired privatespacetrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.psIdStringId of the desired privatespacetrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.folderIdStringId of the desired foldertrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.parentIdStringId of parent folder for newtrue
params.nameStringName of new foldertrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.folderIdStringId of the desired foldertrue
params.nameStringNew name your foldertrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.folderIdStringId of the desired foldertrue
params.parentIdStringId of the folder where will be copy current foldertrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.folderIdStringId of the desired foldertrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.fileIdStringId of the desired filetrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
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
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
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
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.fileIdStringId of the desired filetrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.fileIdStringId of the desired filetrue
params.nameStringNew name your filetrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.idArrString[]Array with file`s id | true
params.parentIdStringId of the folder where will be copy current filestrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.idArrString[]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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.idArrObject[]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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.folderIdStringId of the parent foldertrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.linkStringlink for requesttrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.resourceIdStringId of the filetrue
params.nameStringName of new linktrue
params.allowDownloadBooleandownload Possibletrue
params.roleStringroletrue
params.requestUserDataBooleanRequest User Datafalse
params.passwordStringpasswordfalse
params.expiredDateStringExpired datefalse
params.inputFieldsString[]fields arrayfalse
params.inputFields.field_nameStringfield nametrue
params.inputFields.field_typeStringfield typetrue
params.inputFields.is_name_fieldBooleanis field namefalse
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.resourceIdStringId of the filetrue
params.nameStringName of new linktrue
params.requestUserDataBooleanRequest User Datafalse
params.expiredDateStringExpired datefalse
params.downloadLimitNumbercount downloadsfalse
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.linkIdStringlink Idtrue
params.attributesObjecttrue
params.attributes.expiredDateStringExpired datefalse
params.attributes.allowDownloadBooleandownload Possiblefalse
params.attributes.isPasswordProtectedBooleanRequest User Datafalse
params.attributes.passwordStringpasswordfalse
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.linkIdStringlink Idtrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.teamIdStringZoho 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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.teamIdStringId your zoho teamtrue
params.nameStringName of new templatetrue
params.descriptionStringfalse
zWDApi.customMeta.dataTemp
    .create('myPool', {
        teamId,
        name,
        description,
    })
    .then(data => {
        // console.log(data)
    });

customMeta.dataTemp.update

Update customData template

Returns: Object - updated template object

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.templateIdStringTemplate idtrue
params.nameStringName templatetrue
params.descriptionStringfalse
zWDApi.customMeta.dataTemp
    .update('myPool', {
        templateId,
        name,
        description,
    })
    .then(data => {
        // console.log(data)
    });

customMeta.dataTemp.delete

Delete customData template

Returns: Object

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.templateIdStringtemplate Idtrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.templateIdStringTemplate idtrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.templateIdStringTemplate idtrue
params.nameStringName of new custom fieldtrue
params.propertiesObjectfalse
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.fieldIdStringcustom field idtrue
params.nameStringName of fieldfalse
zWDApi.customMeta.fields
    .update('myPool', {
        fieldId,
        name,
    })
    .then(data => {
        // console.log(data)
    });

customMeta.fields.delete

Delete custom field

Returns: Object

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.fieldIdStringcustom field Idtrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.templateIdStringTemplate idtrue
params.resourceIdStringfile idtrue
params.customDataObjecttrue
params.customData.custom_field_idStringcustom field idtrue
params.customData.valueStringsaved datatrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.metadataIdStringfile metadataId idtrue
params.customDataObjecttrue
params.customData.custom_field_idStringcustom field idtrue
params.customData.valueStringsaved datatrue
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

ParamTypeDescriptionRequired
poolstringname of the pool you would like, of usetrue
paramsObject
params.metadataIdStringfile metadataId idtrue
zWDApi.customMeta.meta
    .delete('myPool', {
        metadataId,
    })
    .then(data => {
        // console.log(data)
    });
1.0.0

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.3

4 years ago

0.2.4

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.2

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago