diff --git a/src/routes/Lists.js b/src/routes/Lists.js index 0d00a63..2c64bad 100644 --- a/src/routes/Lists.js +++ b/src/routes/Lists.js @@ -180,6 +180,41 @@ class Lists { endpoint: `${this.route}/${listId}/view`, }); } + + /** + * Add task to a list + * + * @param {String} listId The list id + * @param {String} taskId The task id + */ + async addTaskToList(listId, taskId) { + return this._client.post({ + endpoint: `${this.route}/${listId}/task/${taskId}`, + }); + } + + /** + * Remove a task from a list + * + * @param {Sting} listId The list id + * @param {String} taskId The task id + */ + async removeTaskFromList(listId, taskId) { + return this._client.delete({ + endpoint: `${this.route}/${listId}/task/${taskId}`, + }); + } + + /** + * Get list members + * + * @param {String} listId The list id + */ + async getListMembers(listId) { + return this._client.get({ + endpoint: `${this.route}/${listId}/member`, + }); + } } module.exports = Lists; diff --git a/src/routes/Tasks.js b/src/routes/Tasks.js index 3432dc4..a57c733 100644 --- a/src/routes/Tasks.js +++ b/src/routes/Tasks.js @@ -56,15 +56,28 @@ class Tasks { * Add an attachment to a task * * @param {String} taskId The task id - * @param {String} pathToFile The path to the file - * @param {String} [fileName='attachment'] The file name + * @param {Object} fileSettings The file settings + * @param {String} fileSettings.filePath The path to the file + * @param {String} fileSettings.fileName The name of the attachment file along with its extension type. Example: 'notes.txt' * @param {Object} [options] The parameter options to pass in */ - async addAttachment(taskId, pathToFile, fileName = 'attachment', options) { + async addAttachment(taskId, fileSettings, options) { + // ensure fileSettings are provided + if (fileSettings) { + if (!fileSettings.filePath) { + throw new Error('A file path must be provided'); + } + if (!fileSettings.fileName) { + throw new Error('A file name must be provided'); + } + } else { + throw new Error('File settings must be provided'); + } + // building form-data const form = new FormData(); - form.append('filename', fileName); - form.append('attachment', createReadStream(pathToFile)); + form.append('filename', fileSettings.fileName); + form.append('attachment', createReadStream(fileSettings.filePath)); // setting headers const headers = form.getHeaders(); @@ -170,14 +183,12 @@ class Tasks { * Delete a dependancy for a task * * @param {String} taskId The task id - * @param {Object} data The dependency data - * @param {Object} [options] The parameter options to pass in + * @param {Object} options The parameter options to pass in */ - async deleteDependency(taskId, data, options) { + async deleteDependency(taskId, options) { return this.client.delete({ endpoint: `${this.route}/${taskId}/dependency`, params: options, - data, }); } @@ -335,6 +346,31 @@ class Tasks { params: options, }); } + + /** + * Get tasks time in status + * + * @param {String} taskId The task id + * @param {Object} options The parameter options to pass in + */ + async getTimeInStatus(taskId, options) { + return this.client.get({ + endpoint: `${this.route}/${taskId}/time_in_status`, + params: options, + }); + } + + /** + * Get bulk tasks time in status + * + * @param {Object} options The parameter options to pass in + */ + async getBulkTimeInStatus(options) { + return this.client.get({ + endpoint: `${this.route}/bulk_time_in_status/task_ids`, + params: options, + }); + } } module.exports = Tasks;