diff --git a/packages/nodes-base/nodes/Harvest/ClientDescription.ts b/packages/nodes-base/nodes/Harvest/ClientDescription.ts index 3950b35255..fe769b5ebf 100644 --- a/packages/nodes-base/nodes/Harvest/ClientDescription.ts +++ b/packages/nodes-base/nodes/Harvest/ClientDescription.ts @@ -23,6 +23,11 @@ export const clientOperations = [ value: 'getAll', description: 'Get data of all clients', }, + { + name: 'Delete', + value: 'delete', + description: `Delete a client`, + }, ], default: 'getAll', description: 'The operation to perform.', @@ -131,6 +136,28 @@ export const clientFields = [ }, }, description: 'The ID of the client you are retrieving.', +}, + +/* -------------------------------------------------------------------------- */ +/* client:delete */ +/* -------------------------------------------------------------------------- */ +{ + displayName: 'Client Id', + name: 'id', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'client', + ], + }, + }, + description: 'The ID of the client you want to delete.', } ] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/Harvest/ContactDescription.ts b/packages/nodes-base/nodes/Harvest/ContactDescription.ts index f4156eeb1c..1c1d645fe7 100644 --- a/packages/nodes-base/nodes/Harvest/ContactDescription.ts +++ b/packages/nodes-base/nodes/Harvest/ContactDescription.ts @@ -23,6 +23,11 @@ export const contactOperations = [ value: 'getAll', description: 'Get data of all contacts', }, + { + name: 'Delete', + value: 'delete', + description: `Delete a contact`, + }, ], default: 'getAll', description: 'The operation to perform.', @@ -131,6 +136,28 @@ export const contactFields = [ }, }, description: 'The ID of the contact you are retrieving.', +}, + +/* -------------------------------------------------------------------------- */ +/* contact:delete */ +/* -------------------------------------------------------------------------- */ +{ + displayName: 'Contact Id', + name: 'id', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'contact', + ], + }, + }, + description: 'The ID of the contact you want to delete.', } ] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/Harvest/EstimateDescription.ts b/packages/nodes-base/nodes/Harvest/EstimateDescription.ts index 60a24bdb80..cc0e3e02a3 100644 --- a/packages/nodes-base/nodes/Harvest/EstimateDescription.ts +++ b/packages/nodes-base/nodes/Harvest/EstimateDescription.ts @@ -23,6 +23,11 @@ export const estimateOperations = [ value: 'getAll', description: 'Get data of all estimates', }, + { + name: 'Delete', + value: 'delete', + description: `Delete an estimate`, + }, ], default: 'getAll', description: 'The operation to perform.', @@ -162,6 +167,28 @@ export const estimateFields = [ }, }, description: 'The ID of the estimate you are retrieving.', +}, + +/* -------------------------------------------------------------------------- */ +/* estimate:delete */ +/* -------------------------------------------------------------------------- */ +{ + displayName: 'Estimate Id', + name: 'id', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'estimate', + ], + }, + }, + description: 'The ID of the estimate want to delete.', } ] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/Harvest/ExpenseDescription.ts b/packages/nodes-base/nodes/Harvest/ExpenseDescription.ts index 54659e4a3a..96626056ac 100644 --- a/packages/nodes-base/nodes/Harvest/ExpenseDescription.ts +++ b/packages/nodes-base/nodes/Harvest/ExpenseDescription.ts @@ -23,6 +23,11 @@ export const expenseOperations = [ value: 'getAll', description: 'Get data of all expenses', }, + { + name: 'Delete', + value: 'delete', + description: `Delete an expense`, + }, ], default: 'getAll', description: 'The operation to perform.', @@ -176,6 +181,28 @@ export const expenseFields = [ }, }, description: 'The ID of the expense you are retrieving.', +}, + +/* -------------------------------------------------------------------------- */ +/* expense:delete */ +/* -------------------------------------------------------------------------- */ +{ + displayName: 'Expense Id', + name: 'id', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'expense', + ], + }, + }, + description: 'The ID of the expense you want to delete.', } ] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/Harvest/Harvest.node.ts b/packages/nodes-base/nodes/Harvest/Harvest.node.ts index d8bef6ea13..dba51023a4 100644 --- a/packages/nodes-base/nodes/Harvest/Harvest.node.ts +++ b/packages/nodes-base/nodes/Harvest/Harvest.node.ts @@ -306,6 +306,17 @@ export class Harvest implements INodeType { const responseData: IDataObject[] = await getAllResource.call(this, 'clients', i); returnData.push.apply(returnData, responseData); + } else if (operation === 'delete') { + // ---------------------------------- + // delete + // ---------------------------------- + + requestMethod = 'DELETE'; + const id = this.getNodeParameter('id', i) as string; + endpoint = `clients/${id}`; + + const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); + returnData.push(responseData); } else { throw new Error(`The resource "${resource}" is not known!`); } @@ -331,6 +342,17 @@ export class Harvest implements INodeType { const responseData: IDataObject[] = await getAllResource.call(this, 'projects', i); returnData.push.apply(returnData, responseData); + } else if (operation === 'delete') { + // ---------------------------------- + // delete + // ---------------------------------- + + requestMethod = 'DELETE'; + const id = this.getNodeParameter('id', i) as string; + endpoint = `projects/${id}`; + + const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); + returnData.push(responseData); } else { throw new Error(`The resource "${resource}" is not known!`); } @@ -368,7 +390,18 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); - } else { + } else if (operation === 'delete') { + // ---------------------------------- + // delete + // ---------------------------------- + + requestMethod = 'DELETE'; + const id = this.getNodeParameter('id', i) as string; + endpoint = `users/${id}`; + + const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); + returnData.push(responseData); + } else { throw new Error(`The resource "${resource}" is not known!`); } } else if (resource === 'contact') { @@ -393,7 +426,18 @@ export class Harvest implements INodeType { const responseData: IDataObject[] = await getAllResource.call(this, 'contacts', i); returnData.push.apply(returnData, responseData); - } else { + } else if (operation === 'delete') { + // ---------------------------------- + // delete + // ---------------------------------- + + requestMethod = 'DELETE'; + const id = this.getNodeParameter('id', i) as string; + endpoint = `contacts/${id}`; + + const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); + returnData.push(responseData); + } else { throw new Error(`The resource "${resource}" is not known!`); } } else if (resource === 'company') { @@ -433,6 +477,17 @@ export class Harvest implements INodeType { const responseData: IDataObject[] = await getAllResource.call(this, 'tasks', i); returnData.push.apply(returnData, responseData); + } else if (operation === 'delete') { + // ---------------------------------- + // delete + // ---------------------------------- + + requestMethod = 'DELETE'; + const id = this.getNodeParameter('id', i) as string; + endpoint = `tasks/${id}`; + + const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); + returnData.push(responseData); } else { throw new Error(`The resource "${resource}" is not known!`); } @@ -458,7 +513,18 @@ export class Harvest implements INodeType { const responseData: IDataObject[] = await getAllResource.call(this, 'invoices', i); returnData.push.apply(returnData, responseData); - } else { + } else if (operation === 'delete') { + // ---------------------------------- + // delete + // ---------------------------------- + + requestMethod = 'DELETE'; + const id = this.getNodeParameter('id', i) as string; + endpoint = `invoices/${id}`; + + const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); + returnData.push(responseData); + } else { throw new Error(`The resource "${resource}" is not known!`); } } else if (resource === 'expense') { @@ -483,7 +549,18 @@ export class Harvest implements INodeType { const responseData: IDataObject[] = await getAllResource.call(this, 'expenses', i); returnData.push.apply(returnData, responseData); - } else { + } else if (operation === 'delete') { + // ---------------------------------- + // delete + // ---------------------------------- + + requestMethod = 'DELETE'; + const id = this.getNodeParameter('id', i) as string; + endpoint = `expenses/${id}`; + + const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); + returnData.push(responseData); + } else { throw new Error(`The resource "${resource}" is not known!`); } } else if (resource === 'estimate') { @@ -508,7 +585,18 @@ export class Harvest implements INodeType { const responseData: IDataObject[] = await getAllResource.call(this, 'estimates', i); returnData.push.apply(returnData, responseData); - } else { + } else if (operation === 'delete') { + // ---------------------------------- + // delete + // ---------------------------------- + + requestMethod = 'DELETE'; + const id = this.getNodeParameter('id', i) as string; + endpoint = `estimates/${id}`; + + const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); + returnData.push(responseData); + } else { throw new Error(`The resource "${resource}" is not known!`); } } else { diff --git a/packages/nodes-base/nodes/Harvest/InvoiceDescription.ts b/packages/nodes-base/nodes/Harvest/InvoiceDescription.ts index cb876f872a..fe19a8463e 100644 --- a/packages/nodes-base/nodes/Harvest/InvoiceDescription.ts +++ b/packages/nodes-base/nodes/Harvest/InvoiceDescription.ts @@ -23,6 +23,11 @@ export const invoiceOperations = [ value: 'getAll', description: 'Get data of all invoices', }, + { + name: 'Delete', + value: 'delete', + description: `Delete a invoice`, + }, ], default: 'getAll', description: 'The operation to perform.', @@ -187,6 +192,28 @@ export const invoiceFields = [ }, }, description: 'The ID of the invoice you are retrieving.', +}, + +/* -------------------------------------------------------------------------- */ +/* invoice:delete */ +/* -------------------------------------------------------------------------- */ +{ + displayName: 'Invoice Id', + name: 'id', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'invoice', + ], + }, + }, + description: 'The ID of the invoice want to delete.', } ] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/Harvest/ProjectDescription.ts b/packages/nodes-base/nodes/Harvest/ProjectDescription.ts index a0c04531a8..7d039ccab9 100644 --- a/packages/nodes-base/nodes/Harvest/ProjectDescription.ts +++ b/packages/nodes-base/nodes/Harvest/ProjectDescription.ts @@ -23,6 +23,11 @@ export const projectOperations = [ value: 'getAll', description: 'Get data of all projects', }, + { + name: 'Delete', + value: 'delete', + description: `Delete a project`, + }, ], default: 'getAll', description: 'The operation to perform.', @@ -149,6 +154,28 @@ export const projectFields = [ }, }, description: 'The ID of the project you are retrieving.', +}, + +/* -------------------------------------------------------------------------- */ +/* project:delete */ +/* -------------------------------------------------------------------------- */ +{ + displayName: 'Project Id', + name: 'id', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'project', + ], + }, + }, + description: 'The ID of the project want to delete.', } ] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/Harvest/TaskDescription.ts b/packages/nodes-base/nodes/Harvest/TaskDescription.ts index ac35fc2076..b8aea2fcd6 100644 --- a/packages/nodes-base/nodes/Harvest/TaskDescription.ts +++ b/packages/nodes-base/nodes/Harvest/TaskDescription.ts @@ -23,6 +23,11 @@ export const taskOperations = [ value: 'getAll', description: 'Get data of all tasks', }, + { + name: 'Delete', + value: 'delete', + description: `Delete a task`, + }, ], default: 'getAll', description: 'The operation to perform.', @@ -141,6 +146,29 @@ export const taskFields = [ }, }, description: 'The ID of the task you are retrieving.', -} +}, + +/* -------------------------------------------------------------------------- */ +/* task:delete */ +/* -------------------------------------------------------------------------- */ +{ + displayName: 'Task Id', + name: 'id', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'task', + ], + }, + }, + description: 'The ID of the task you wan to delete.', +}, + ] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/Harvest/UserDescription.ts b/packages/nodes-base/nodes/Harvest/UserDescription.ts index 4e1c563c7d..0a69c8fc32 100644 --- a/packages/nodes-base/nodes/Harvest/UserDescription.ts +++ b/packages/nodes-base/nodes/Harvest/UserDescription.ts @@ -28,6 +28,11 @@ export const userOperations = [ value: 'getAll', description: 'Get data of all users', }, + { + name: 'Delete', + value: 'delete', + description: `Delete a user`, + }, ], default: 'me', description: 'The operation to perform.', @@ -146,6 +151,28 @@ export const userFields = [ }, }, description: 'The ID of the user you are retrieving.', +}, + +/* -------------------------------------------------------------------------- */ +/* user:delete */ +/* -------------------------------------------------------------------------- */ +{ + displayName: 'User Id', + name: 'id', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'user', + ], + }, + }, + description: 'The ID of the user you want to delete.', } ] as INodeProperties[];