From 7afdd505a331e2e897a419f4b83a401970e66143 Mon Sep 17 00:00:00 2001 From: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> Date: Mon, 21 Dec 2020 23:02:53 -0500 Subject: [PATCH 1/4] feat(addAttachment): add fileSettings param - increase ease of use - it is a required param BREAKING CHANGE pathToFile and fileName have been condensed into one param. To migrate change your projects to use the supported fileSettings param. --- src/routes/Tasks.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/routes/Tasks.js b/src/routes/Tasks.js index 3432dc4..7c5bd03 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(); From 5a3d5fcd551e023ec9d6adbaabc8b511b4697232 Mon Sep 17 00:00:00 2001 From: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> Date: Mon, 21 Dec 2020 23:04:37 -0500 Subject: [PATCH 2/4] feat(tasks) add new task endpoints - get tasks time in status - get bulk tasks time in status --- src/routes/Tasks.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/routes/Tasks.js b/src/routes/Tasks.js index 7c5bd03..cb021c8 100644 --- a/src/routes/Tasks.js +++ b/src/routes/Tasks.js @@ -348,6 +348,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; From 047ccb5e9f1c8d51a7e49ab0c884eec292b2d8e5 Mon Sep 17 00:00:00 2001 From: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> Date: Mon, 21 Dec 2020 23:06:05 -0500 Subject: [PATCH 3/4] feat(lists): add new list endpoints - add task to list - remove task from list --- src/routes/Lists.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) 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; From e523185ec5337ebf73579c54539a11603dd89b63 Mon Sep 17 00:00:00 2001 From: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> Date: Mon, 21 Dec 2020 23:11:20 -0500 Subject: [PATCH 4/4] fix(deleteDependency): remove data param - no data required for endpoint - parameter options have required properties and is therefore now required. --- src/routes/Tasks.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/routes/Tasks.js b/src/routes/Tasks.js index cb021c8..a57c733 100644 --- a/src/routes/Tasks.js +++ b/src/routes/Tasks.js @@ -183,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, }); }