mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
✨ Add Clockify task resource (#2162)
* ✨ Add Task resource to Clockify Node * 🔨 Refactor Clockify expansion * 🔥 Remove logging * ⚡ Add defaults * ⚡ Improvements * ⚡ Minor improvements Co-authored-by: Frank Silver <dasylva.f@gmail.com> Co-authored-by: ricardo <ricardoespinoza105@gmail.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
@@ -39,6 +39,11 @@ import {
|
||||
tagOperations,
|
||||
} from './TagDescription';
|
||||
|
||||
import {
|
||||
taskFields,
|
||||
taskOperations,
|
||||
} from './TaskDescription';
|
||||
|
||||
import {
|
||||
timeEntryFields,
|
||||
timeEntryOperations,
|
||||
@@ -81,6 +86,10 @@ export class Clockify implements INodeType {
|
||||
name: 'Tag',
|
||||
value: 'tag',
|
||||
},
|
||||
{
|
||||
name: 'Task',
|
||||
value: 'task',
|
||||
},
|
||||
{
|
||||
name: 'Time Entry',
|
||||
value: 'timeEntry',
|
||||
@@ -91,6 +100,7 @@ export class Clockify implements INodeType {
|
||||
},
|
||||
...projectOperations,
|
||||
...tagOperations,
|
||||
...taskOperations,
|
||||
...timeEntryOperations,
|
||||
{
|
||||
displayName: 'Workspace ID',
|
||||
@@ -104,6 +114,7 @@ export class Clockify implements INodeType {
|
||||
},
|
||||
...projectFields,
|
||||
...tagFields,
|
||||
...taskFields,
|
||||
...timeEntryFields,
|
||||
],
|
||||
};
|
||||
@@ -457,6 +468,152 @@ export class Clockify implements INodeType {
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'task') {
|
||||
if (operation === 'create') {
|
||||
const workspaceId = this.getNodeParameter(
|
||||
'workspaceId',
|
||||
i,
|
||||
) as string;
|
||||
|
||||
const projectId = this.getNodeParameter('projectId', i) as string;
|
||||
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
|
||||
const additionalFields = this.getNodeParameter(
|
||||
'additionalFields',
|
||||
i,
|
||||
) as IDataObject;
|
||||
|
||||
const body: IDataObject = {
|
||||
name,
|
||||
};
|
||||
|
||||
Object.assign(body, additionalFields);
|
||||
|
||||
if (body.estimate) {
|
||||
const [hour, minute] = (body.estimate as string).split(':');
|
||||
body.estimate = `PT${hour}H${minute}M`;
|
||||
}
|
||||
|
||||
responseData = await clockifyApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/workspaces/${workspaceId}/projects/${projectId}/tasks`,
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
}
|
||||
|
||||
if (operation === 'delete') {
|
||||
const workspaceId = this.getNodeParameter(
|
||||
'workspaceId',
|
||||
i,
|
||||
) as string;
|
||||
|
||||
const projectId = this.getNodeParameter('projectId', i) as string;
|
||||
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
|
||||
responseData = await clockifyApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/workspaces/${workspaceId}/projects/${projectId}/tasks/${taskId}`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
}
|
||||
|
||||
if (operation === 'get') {
|
||||
const workspaceId = this.getNodeParameter(
|
||||
'workspaceId',
|
||||
i,
|
||||
) as string;
|
||||
|
||||
const projectId = this.getNodeParameter('projectId', i) as string;
|
||||
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
|
||||
responseData = await clockifyApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/workspaces/${workspaceId}/projects/${projectId}/tasks/${taskId}`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
}
|
||||
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
|
||||
const workspaceId = this.getNodeParameter(
|
||||
'workspaceId',
|
||||
i,
|
||||
) as string;
|
||||
|
||||
const projectId = this.getNodeParameter('projectId', i) as string;
|
||||
|
||||
const filters = this.getNodeParameter(
|
||||
'filters',
|
||||
i,
|
||||
) as IDataObject;
|
||||
|
||||
Object.assign(qs, filters);
|
||||
|
||||
if (returnAll) {
|
||||
responseData = await clockifyApiRequestAllItems.call(
|
||||
this,
|
||||
'GET',
|
||||
`/workspaces/${workspaceId}/projects/${projectId}/tasks`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs['page-size'] = this.getNodeParameter('limit', i) as number;
|
||||
|
||||
responseData = await clockifyApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/workspaces/${workspaceId}/projects/${projectId}/tasks`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (operation === 'update') {
|
||||
const workspaceId = this.getNodeParameter(
|
||||
'workspaceId',
|
||||
i,
|
||||
) as string;
|
||||
|
||||
const projectId = this.getNodeParameter('projectId', i) as string;
|
||||
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
|
||||
const updateFields = this.getNodeParameter(
|
||||
'updateFields',
|
||||
i,
|
||||
) as IDataObject;
|
||||
|
||||
const body: IDataObject = {};
|
||||
|
||||
Object.assign(body, updateFields);
|
||||
|
||||
if (body.estimate) {
|
||||
const [hour, minute] = (body.estimate as string).split(':');
|
||||
body.estimate = `PT${hour}H${minute}M`;
|
||||
}
|
||||
|
||||
responseData = await clockifyApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/workspaces/${workspaceId}/projects/${projectId}/tasks/${taskId}`,
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'timeEntry') {
|
||||
|
||||
if (operation === 'create') {
|
||||
|
||||
Reference in New Issue
Block a user