mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 20:54:07 -08:00
✨ Add Harvest update task operations (#1603)
* Add create/update task in Harvest node
* ⚡ Small improvements
Co-authored-by: dali <servfrdali@yahoo.fr>
This commit is contained in:
parent
aab6946e9e
commit
7995bd610d
|
@ -1,6 +1,10 @@
|
|||
import { INodeProperties } from 'n8n-workflow';
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
const resource = ['client'];
|
||||
const resource = [
|
||||
'client',
|
||||
];
|
||||
|
||||
export const clientOperations = [
|
||||
{
|
||||
|
@ -49,7 +53,7 @@ export const clientOperations = [
|
|||
export const clientFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* client:getAll */
|
||||
/* client:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
|
@ -122,7 +126,7 @@ export const clientFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* client:get */
|
||||
/* client:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Client Id',
|
||||
|
@ -142,7 +146,7 @@ export const clientFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* client:delete */
|
||||
/* client:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Client Id',
|
||||
|
@ -162,7 +166,7 @@ export const clientFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* client:create */
|
||||
/* client:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Name',
|
||||
|
@ -220,7 +224,7 @@ export const clientFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* client:update */
|
||||
/* client:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Client Id',
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { INodeProperties } from 'n8n-workflow';
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
const resource = ['company'];
|
||||
const resource = [
|
||||
'company',
|
||||
];
|
||||
|
||||
export const companyOperations = [
|
||||
{
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { INodeProperties } from 'n8n-workflow';
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
const resource = ['contact'];
|
||||
const resource = [
|
||||
'contact',
|
||||
];
|
||||
|
||||
export const contactOperations = [
|
||||
{
|
||||
|
@ -48,7 +52,7 @@ export const contactOperations = [
|
|||
export const contactFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:getAll */
|
||||
/* contact:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
|
@ -121,7 +125,7 @@ export const contactFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:get */
|
||||
/* contact:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Contact Id',
|
||||
|
@ -141,7 +145,7 @@ export const contactFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:delete */
|
||||
/* contact:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Contact Id',
|
||||
|
@ -161,7 +165,7 @@ export const contactFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:create */
|
||||
/* contact:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'First Name',
|
||||
|
@ -256,7 +260,7 @@ export const contactFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:update */
|
||||
/* contact:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Contact Id',
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { INodeProperties } from 'n8n-workflow';
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
const resource = ['estimate'];
|
||||
const resource = [
|
||||
'estimate',
|
||||
];
|
||||
|
||||
export const estimateOperations = [
|
||||
{
|
||||
|
@ -48,7 +52,7 @@ export const estimateOperations = [
|
|||
export const estimateFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* estimate:getAll */
|
||||
/* estimate:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
|
@ -152,7 +156,7 @@ export const estimateFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* estimate:get */
|
||||
/* estimate:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Estimate Id',
|
||||
|
@ -172,7 +176,7 @@ export const estimateFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* estimate:delete */
|
||||
/* estimate:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Estimate Id',
|
||||
|
@ -192,7 +196,7 @@ export const estimateFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* estimate:create */
|
||||
/* estimate:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Client Id',
|
||||
|
@ -292,7 +296,7 @@ export const estimateFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* estimate:update */
|
||||
/* estimate:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Invoice Id',
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { INodeProperties } from 'n8n-workflow';
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
const resource = ['expense'];
|
||||
const resource = [
|
||||
'expense',
|
||||
];
|
||||
|
||||
export const expenseOperations = [
|
||||
{
|
||||
|
@ -48,7 +52,7 @@ export const expenseOperations = [
|
|||
export const expenseFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* expense:getAll */
|
||||
/* expense:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
|
@ -166,7 +170,7 @@ export const expenseFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* expense:get */
|
||||
/* expense:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Expense Id',
|
||||
|
@ -186,7 +190,7 @@ export const expenseFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* expense:delete */
|
||||
/* expense:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Expense Id',
|
||||
|
@ -206,7 +210,7 @@ export const expenseFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* expense:create */
|
||||
/* expense:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Project Id',
|
||||
|
@ -310,7 +314,7 @@ export const expenseFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* invoice:update */
|
||||
/* invoice:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Invoice Id',
|
||||
|
|
|
@ -54,6 +54,7 @@ import {
|
|||
taskFields,
|
||||
taskOperations,
|
||||
} from './TaskDescription';
|
||||
|
||||
import {
|
||||
timeEntryFields,
|
||||
timeEntryOperations,
|
||||
|
@ -693,6 +694,37 @@ export class Harvest implements INodeType {
|
|||
const responseData: IDataObject[] = await getAllResource.call(this, 'tasks', i);
|
||||
returnData.push.apply(returnData, responseData);
|
||||
|
||||
} else if (operation === 'create') {
|
||||
// ----------------------------------
|
||||
// create
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'POST';
|
||||
endpoint = 'tasks';
|
||||
|
||||
body.name = this.getNodeParameter('name', i) as string;
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
Object.assign(body, additionalFields);
|
||||
|
||||
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body);
|
||||
returnData.push(responseData);
|
||||
|
||||
} else if (operation === 'update') {
|
||||
// ----------------------------------
|
||||
// update
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'PATCH';
|
||||
const id = this.getNodeParameter('id', i) as string;
|
||||
endpoint = `tasks/${id}`;
|
||||
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
Object.assign(qs, updateFields);
|
||||
|
||||
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body);
|
||||
returnData.push(responseData);
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
// ----------------------------------
|
||||
// delete
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { INodeProperties } from 'n8n-workflow';
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
const resource = ['invoice'];
|
||||
const resource = [
|
||||
'invoice',
|
||||
];
|
||||
|
||||
export const invoiceOperations = [
|
||||
{
|
||||
|
@ -48,7 +52,7 @@ export const invoiceOperations = [
|
|||
export const invoiceFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* invoice:getAll */
|
||||
/* invoice:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
|
@ -177,7 +181,7 @@ export const invoiceFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* invoice:get */
|
||||
/* invoice:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Invoice Id',
|
||||
|
@ -197,7 +201,7 @@ export const invoiceFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* invoice:delete */
|
||||
/* invoice:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Invoice Id',
|
||||
|
@ -217,7 +221,7 @@ export const invoiceFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* invoice:create */
|
||||
/* invoice:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Client Id',
|
||||
|
@ -345,7 +349,7 @@ export const invoiceFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* invoice:update */
|
||||
/* invoice:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Invoice Id',
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { INodeProperties } from 'n8n-workflow';
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
const resource = ['project'];
|
||||
const resource = [
|
||||
'project',
|
||||
];
|
||||
|
||||
export const projectOperations = [
|
||||
{
|
||||
|
@ -48,7 +52,7 @@ export const projectOperations = [
|
|||
export const projectFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* projects:getAll */
|
||||
/* projects:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
|
@ -138,7 +142,7 @@ export const projectFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* project:get */
|
||||
/* project:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Project Id',
|
||||
|
@ -158,7 +162,7 @@ export const projectFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* project:delete */
|
||||
/* project:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Project Id',
|
||||
|
@ -178,7 +182,7 @@ export const projectFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* project:create */
|
||||
/* project:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Name',
|
||||
|
@ -399,7 +403,7 @@ export const projectFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* project:update */
|
||||
/* project:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Project Id',
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
import { INodeProperties } from 'n8n-workflow';
|
||||
const resource = ['task'];
|
||||
import {
|
||||
INodeProperties
|
||||
} from 'n8n-workflow';
|
||||
|
||||
const resource = [
|
||||
'task',
|
||||
];
|
||||
|
||||
export const taskOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
|
@ -46,7 +52,7 @@ export const taskOperations = [
|
|||
export const taskFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:getAll */
|
||||
/* task:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Return All',
|
||||
|
@ -128,7 +134,7 @@ export const taskFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:get */
|
||||
/* task:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Task Id',
|
||||
|
@ -148,7 +154,7 @@ export const taskFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:delete */
|
||||
/* task:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Task Id',
|
||||
|
@ -164,11 +170,11 @@ export const taskFields = [
|
|||
resource,
|
||||
},
|
||||
},
|
||||
description: 'The ID of the task you wan to delete.',
|
||||
description: 'The ID of the task you want to delete.',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:create */
|
||||
/* task:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Name',
|
||||
|
@ -205,14 +211,14 @@ export const taskFields = [
|
|||
displayName: 'Billable By Default',
|
||||
name: 'billable_by_default',
|
||||
type: 'boolean',
|
||||
default: '',
|
||||
default: true,
|
||||
description: 'Used in determining whether default tasks should be marked billable when creating a new project. Defaults to true.',
|
||||
},
|
||||
{
|
||||
displayName: 'Default Hourly Rate',
|
||||
name: 'default_hourly_rate',
|
||||
type: 'string',
|
||||
default: '0',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
description: 'The default hourly rate to use for this task when it is added to a project. Defaults to 0.',
|
||||
},
|
||||
{
|
||||
|
@ -232,8 +238,24 @@ export const taskFields = [
|
|||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:update */
|
||||
/* task:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Task ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource,
|
||||
},
|
||||
},
|
||||
description: 'The ID of the task you want to update.',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
|
@ -260,8 +282,8 @@ export const taskFields = [
|
|||
{
|
||||
displayName: 'Default Hourly Rate',
|
||||
name: 'default_hourly_rate',
|
||||
type: 'string',
|
||||
default: '0',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
description: 'The default hourly rate to use for this task when it is added to a project. Defaults to 0.',
|
||||
},
|
||||
{
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
import { INodeProperties } from 'n8n-workflow';
|
||||
export const resource = ['timeEntry'];
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const resource = [
|
||||
'timeEntry',
|
||||
];
|
||||
|
||||
export const timeEntryOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { INodeProperties } from 'n8n-workflow';
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
const resource = ['user'];
|
||||
const resource = [
|
||||
'user',
|
||||
];
|
||||
|
||||
export const userOperations = [
|
||||
{
|
||||
|
@ -54,7 +58,7 @@ export const userOperations = [
|
|||
export const userFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* user:getAll */
|
||||
/* user:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
|
@ -137,7 +141,7 @@ export const userFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* user:get */
|
||||
/* user:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'User Id',
|
||||
|
@ -157,7 +161,7 @@ export const userFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* user:delete */
|
||||
/* user:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'User Id',
|
||||
|
@ -177,7 +181,7 @@ export const userFields = [
|
|||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* user:create */
|
||||
/* user:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'First Name',
|
||||
|
@ -344,7 +348,7 @@ export const userFields = [
|
|||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* user:update */
|
||||
/* user:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Time Entry Id',
|
||||
|
|
Loading…
Reference in a new issue