mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -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 = [
|
||||
{
|
||||
|
|
|
@ -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 = [
|
||||
{
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { INodeProperties } from 'n8n-workflow';
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
const resource = ['estimate'];
|
||||
const resource = [
|
||||
'estimate',
|
||||
];
|
||||
|
||||
export const estimateOperations = [
|
||||
{
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { INodeProperties } from 'n8n-workflow';
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
const resource = ['expense'];
|
||||
const resource = [
|
||||
'expense',
|
||||
];
|
||||
|
||||
export const expenseOperations = [
|
||||
{
|
||||
|
|
|
@ -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 = [
|
||||
{
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { INodeProperties } from 'n8n-workflow';
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
const resource = ['project'];
|
||||
const resource = [
|
||||
'project',
|
||||
];
|
||||
|
||||
export const projectOperations = [
|
||||
{
|
||||
|
|
|
@ -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',
|
||||
|
@ -164,7 +170,7 @@ export const taskFields = [
|
|||
resource,
|
||||
},
|
||||
},
|
||||
description: 'The ID of the task you wan to delete.',
|
||||
description: 'The ID of the task you want to delete.',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -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.',
|
||||
},
|
||||
{
|
||||
|
@ -234,6 +240,22 @@ export const taskFields = [
|
|||
/* -------------------------------------------------------------------------- */
|
||||
/* 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 = [
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue