linshare-api-client
v0.0.21
Published
JS library for Linshare APIs
Downloads
102
Readme
linshare-api-client
JS library for Linshare APIs
Installation
NPM:
npm install linagora/linshare-api-client
Bower:
bower install linshare-api-client
Usage
const { Client } = require('linshare-api-client');
const client = new Client({
baseUrl: 'https://files.linshare.local/linshare/webservice/rest',
auth: {
type: 'basic',
username: '<username>',
password: '<password>'
// OR by JWT
// type: 'jwt',
// token: '<token>'
}
});
client.user.workgroup.list()
.then(data => console.log(data))
.catch(err => console.error(err));
On browser:
const Client = window.LinshareApiClient.Client;
...
APIs
User API
Authentication
Get authorized user
client.user.authentication.authorized().then(...)
Workgroup
Create document in a node of work group from URL
client.user.workgroup.createDocumentFromUrl('work-group-uuid', documentInfo, options)
.then(...)
documentInfo
: an object contains- url (required): file url
- fileName (optional): file name
- size (optional): file size
options
(optional):{ parent: 'parentNodeUuid', async: true/false, strict: true/false }
Delete a node in workgroup
client.user.workgroup.deleteNode('work-group-uuid', 'node-uuid')
.then(...)
List workgroups
client.user.workgroup.list().then(...)
List nodes in a workgroup
client.user.workgroup.listNodes(workgroupUuid, options).then(...)
options
(optional):{ parent: 'parentNodeUuid', type: 'FOLDER | DOCUMENT' }
Update a node in workgroup
client.user.workgroup.updateNode('work-group-uuid', 'node-uuid', modified)
.then(...)
Documents
Get a document
client.user.documents.get('documentUuid').then(...)
List documents
client.user.documents.list().then(...)
Create a document
Upload a file to My space
var options = {
async: false,
onUploadProgress: function(progressEvent) {
var processedPercent = Math.round((progressEvent.loaded * 100) / progressEvent.total);
console.log('Uploading...', processedPercent);
}
};
var formData = new FormData();
formData.append('file', file);
formData.append('filesize', fileSize);
client.user.documents.create(formData, options).then(...)
Share
Share documents
client.user.shares.shareDocuments({
documents: ['documentUuid1', 'documentUuid2'],
recipients: [{
mail: '[email protected]'
}, {
mail: '[email protected]'
}]
}).then(...)
Download document
Accept different response type with default value being blob
. You are advised to use different response types based on running environment:
blob
is for browserarrayBuffer
is for nodejs environment
client.user.workgroup.downloadDocument('work-group-uuid', 'node-uuid', { responseType: 'blob' })
.then(function(blob) {
const file = new File([blob], 'documentname');
})
Get a node in workgroup
client.user.workgroup.getNode('work-group-uuid', 'node-uuid')
.then(...)
Shared space nodes
Get a member of a shared space node
client.user.sharedSpaceNodes.findMemberByAccountUuid('shared-space-node-uuid', 'member-uuid')
.then(...)
Shared space roles
Get a shared space role by uuid
client.user.sharedSpaceRoles.findAllPermissions('shared-space-role-uuid')
.then(...)
Release
Assume that you are in master
branch and you have write access to the origin
remote, type the following command to release a new version:
./scripts/release.sh x.y.z
In case your Git remote is NOT origin
:
./scripts/release.sh x.y.z my-remote