Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update endpoints to latest #14

Merged
merged 4 commits into from
Jan 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;