Skip to content

Commit

Permalink
feat: v2.0 (#17)
Browse files Browse the repository at this point in the history
* chore(package.json): update dependencies (#13)

* feat: update endpoints to latest (#14)

* 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.

* fix(Tasks): indicate client is private (#15)

- updated to be consistent with rest of lib naming scheme

* feat(docs): update to latest (#16)

* 2.0.0
  • Loading branch information
ComfortablyCoding authored Jan 3, 2021
1 parent 2c46499 commit c785b95
Show file tree
Hide file tree
Showing 31 changed files with 1,092 additions and 233 deletions.
4 changes: 2 additions & 2 deletions docs/Authorization.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/Checklists.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/Clickup.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/Comments.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/Folders.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/Goals.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/KeyResults.html

Large diffs are not rendered by default.

458 changes: 456 additions & 2 deletions docs/Lists.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/Spaces.html

Large diffs are not rendered by default.

471 changes: 367 additions & 104 deletions docs/Tasks.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/Teams.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/Views.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/Webhooks.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/index.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/routes_Authorization.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/routes_Checklists.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/routes_Comments.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/routes_Folders.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/routes_Goals.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/routes_KeyResults.js.html

Large diffs are not rendered by default.

39 changes: 37 additions & 2 deletions docs/routes_Lists.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/routes_Spaces.js.html

Large diffs are not rendered by default.

106 changes: 71 additions & 35 deletions docs/routes_Tasks.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/routes_Teams.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/routes_Views.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/routes_Webhooks.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "clickup.js",
"version": "1.1.0",
"version": "2.0.0",
"description": "A Node.js wrapper for the Clickup API",
"main": "./src/index.js",
"dependencies": {
"form-data": "^3.0.0",
"got": "^11.6.2"
"got": "^11.8.1"
},
"keywords": [
"clickup",
Expand All @@ -19,14 +19,14 @@
"devDependencies": {
"chai": "^4.2.0",
"docdash": "^1.2.0",
"eslint": "^7.9.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-prettier": "^3.1.4",
"jsdoc": "^3.6.5",
"mocha": "^8.1.3",
"prettier": "^2.1.2"
"eslint": "^7.16.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.3.0",
"jsdoc": "^3.6.6",
"mocha": "^8.2.1",
"prettier": "^2.2.1"
},
"scripts": {
"test": "mocha",
Expand Down
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;
102 changes: 69 additions & 33 deletions src/routes/Tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Tasks {
* @param {Client} client A client instance
*/
constructor(client) {
this.client = client;
this._client = client;
this.route = 'task';
}

Expand All @@ -18,7 +18,7 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async get(taskId, options) {
return this.client.get({
return this._client.get({
endpoint: `${this.route}/${taskId}`,
params: options,
});
Expand All @@ -32,7 +32,7 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async update(taskId, data, options) {
return this.client.put({
return this._client.put({
endpoint: `${this.route}/${taskId}`,
params: options,
data,
Expand All @@ -46,7 +46,7 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async delete(taskId, options) {
return this.client.delete({
return this._client.delete({
endpoint: `${this.route}/${taskId}`,
params: options,
});
Expand All @@ -56,21 +56,34 @@ 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();
headers.authorization = this.client._token;
headers.authorization = this._client._token;

return this.client.post({
return this._client.post({
endpoint: `${this.route}/${taskId}/attachment`,
params: options,
data: form,
Expand All @@ -86,7 +99,7 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async addComment(taskId, data, options) {
return this.client.post({
return this._client.post({
endpoint: `${this.route}/${taskId}/comment`,
params: options,
data,
Expand All @@ -100,7 +113,7 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async getComments(taskId, options) {
return this.client.get({
return this._client.get({
endpoint: `${this.route}/${taskId}/comment`,
params: options,
});
Expand All @@ -114,7 +127,7 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async createChecklist(taskId, data, options) {
return this.client.post({
return this._client.post({
endpoint: `${this.route}/${taskId}/checklist`,
params: options,
data,
Expand All @@ -130,7 +143,7 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async setCustomFieldValue(taskId, fieldId, data, options) {
return this.client.post({
return this._client.post({
endpoint: `${this.route}/${taskId}/field/${fieldId}`,
params: options,
data,
Expand All @@ -145,7 +158,7 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async deleteCustomFieldValue(taskId, fieldId, options) {
return this.client.delete({
return this._client.delete({
endpoint: `${this.route}/${taskId}/field/${fieldId}`,
params: options,
});
Expand All @@ -159,7 +172,7 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async addDependency(taskId, data, options) {
return this.client.post({
return this._client.post({
endpoint: `${this.route}/${taskId}/dependency`,
params: options,
data,
Expand All @@ -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) {
return this.client.delete({
async deleteDependency(taskId, options) {
return this._client.delete({
endpoint: `${this.route}/${taskId}/dependency`,
params: options,
data,
});
}

Expand All @@ -189,7 +200,7 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async addTaskLink(taskId, linksTo, options) {
return this.client.post({
return this._client.post({
endpoint: `${this.route}/${taskId}/link/${linksTo}`,
params: options,
});
Expand All @@ -203,7 +214,7 @@ class Tasks {
* @param {String} [options] The parameter options to pass in
*/
async deleteTaskLink(taskId, linksTo, options) {
return this.client.delete({
return this._client.delete({
endpoint: `${this.route}/${taskId}/link/${linksTo}`,
params: options,
});
Expand All @@ -218,7 +229,7 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async addGuest(taskId, guestId, data, options) {
return this.client.post({
return this._client.post({
endpoint: `${this.route}/${taskId}/guest/${guestId}`,
params: options,
data,
Expand All @@ -233,7 +244,7 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async removeGuest(taskId, guestId, options) {
return this.client.delete({
return this._client.delete({
endpoint: `${this.route}/${taskId}/guest/${guestId}`,
params: options,
});
Expand All @@ -245,7 +256,7 @@ class Tasks {
* @param {String} taskId The task id
*/
async getMembers(taskId) {
return this.client.get({
return this._client.get({
endpoint: `${this.route}/${taskId}/member`,
});
}
Expand All @@ -258,7 +269,7 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async addTag(taskId, tagName, options) {
return this.client.post({
return this._client.post({
endpoint: `${this.route}/${taskId}/tag/${tagName}`,
params: options,
});
Expand All @@ -272,7 +283,7 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async removeTag(taskId, tagName, options) {
return this.client.delete({
return this._client.delete({
endpoint: `${this.route}/${taskId}/tag/${tagName}`,
params: options,
});
Expand All @@ -286,7 +297,7 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async trackTime(taskId, data, options) {
return this.client.post({
return this._client.post({
endpoint: `${this.route}/${taskId}/time`,
params: options,
data,
Expand All @@ -300,7 +311,7 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async getTrackedTime(taskId, options) {
return this.client.get({
return this._client.get({
endpoint: `${this.route}/${taskId}/time`,
params: options,
});
Expand All @@ -315,7 +326,7 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async editTrackedTime(taskId, intervalId, data, options) {
return this.client.put({
return this._client.put({
endpoint: `${this.route}/${taskId}/time/${intervalId}`,
params: options,
data,
Expand All @@ -330,11 +341,36 @@ class Tasks {
* @param {Object} [options] The parameter options to pass in
*/
async deleteTrackedTime(taskId, intervalId, options) {
return this.client.delete({
return this._client.delete({
endpoint: `${this.route}/${taskId}/time/${intervalId}`,
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 c785b95

Please sign in to comment.