Skip to content

Commit

Permalink
feat: update endpoints to latest (#14)
Browse files Browse the repository at this point in the history
* 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.

* feat(tasks) add new task endpoints

- get tasks time in status
- get bulk tasks time in status

* feat(lists): add new list endpoints

- add task to list
- remove task from list

* fix(deleteDependency): remove data param

- no data required for endpoint
- parameter options have required properties and is therefore now required.
  • Loading branch information
ComfortablyCoding authored Jan 3, 2021
1 parent 0c16590 commit 5f60c20
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 9 deletions.
35 changes: 35 additions & 0 deletions src/routes/Lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
54 changes: 45 additions & 9 deletions src/routes/Tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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,
});
}

Expand Down Expand Up @@ -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;

0 comments on commit 5f60c20

Please sign in to comment.