diff --git a/lib/aspose-tasks.js b/lib/aspose-tasks.js index 0b63773..cc79e0f 100644 --- a/lib/aspose-tasks.js +++ b/lib/aspose-tasks.js @@ -136,6 +136,34 @@ AsposeTasks.prototype.getCalendars = function(fileName,callback){ }); }; +AsposeTasks.prototype.addCalendar = function(fileName,calendar,callback){ + + fileName = typeof fileName !== 'undefined' ? fileName : ''; + calendar = typeof calendar !== 'undefined' ? calendar : ''; + + if(fileName === '' || calendar === ''){ + throw new Error('missing required arguments.'); + } + + if(typeof calendar === 'object') + { + calendar = JSON.stringify(calendar); + } + + var strURI = this.baseURI + 'tasks/' + fileName + '/calendars'; + var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); + + Utils.ProcessCommand('POST',signedURI,calendar,function(data){ + if(typeof callback === 'function'){ + if(data.Status == 'Created'){ + callback.call(null,data.CalendarItem); + } else { + throw new Error(data); + } + } + }); +}; + AsposeTasks.prototype.getCalendar = function(fileName, calId, callback){ fileName = typeof fileName !== 'undefined' ? fileName : ''; @@ -463,6 +491,34 @@ AsposeTasks.prototype.getLinks = function(fileName,callback){ }); }; +AsposeTasks.prototype.addLink = function(fileName,taskData,callback){ + + fileName = typeof fileName !== 'undefined' ? fileName : ''; + taskData = typeof taskData !== 'undefined' ? taskData : ''; + + if(fileName === '' || taskData === ''){ + throw new Error('missing required arguments.'); + } + + if(typeof taskData === 'object') + { + taskData = JSON.stringify(taskData); + } + + var strURI = this.baseURI + 'tasks/' + fileName + '/taskLinks'; + var signedURI = Utils.Sign(strURI,this.appSID,this.appKey); + + Utils.ProcessCommand('POST',signedURI,taskData,function(data){ + if(typeof callback === 'function'){ + if(data.Status === 'OK'){ + callback.call(null,data); + } else { + throw new Error(data.Message); + } + } + }); +}; + AsposeTasks.prototype.deleteLink = function(fileName, linkIndex, callback){ fileName = typeof fileName !== 'undefined' ? fileName : ''; @@ -581,12 +637,8 @@ AsposeTasks.prototype.getExtendedAttribute = function(fileName, attrIndex, callb fileName = typeof fileName !== 'undefined' ? fileName : ''; - if(fileName === ''){ - throw new Error('Filename not defined.'); - } - - if(attrIndex === ''){ - throw new Error('attrIndex not defined.'); + if(fileName === '' || attrIndex === ''){ + throw new Error('missing required attributes.'); } var strURI = this.baseURI + 'tasks/' + fileName + '/extendedAttributes/' + attrIndex; @@ -607,12 +659,8 @@ AsposeTasks.prototype.deleteExtendedAttribute = function(fileName, attrIndex, ca fileName = typeof fileName !== 'undefined' ? fileName : ''; - if(fileName === ''){ - throw new Error('Filename not defined.'); - } - - if(attrIndex === ''){ - throw new Error('attrIndex not defined.'); + if(fileName === '' || attrIndex === ''){ + throw new Error('missing required parameters.'); } var strURI = this.baseURI + 'tasks/' + fileName + '/extendedAttributes/' + attrIndex; diff --git a/package.json b/package.json index 907c8b1..85d5e4c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "asposecloud", - "version": "1.2.0", + "version": "1.3.0", "description": "Aspose Cloud SDK for NodeJS", "main": "lib/aspose-cloud.js", "scripts": {