Fix and revert changes on Harvest-Node to not break for existing

users
This commit is contained in:
Jan Oberhauser 2020-02-07 20:38:13 -08:00
parent 19301d8004
commit 101df5882d
11 changed files with 879 additions and 837 deletions

View file

@ -1,6 +1,6 @@
import { INodeProperties } from "n8n-workflow"; import { INodeProperties } from 'n8n-workflow';
const resource = ['clients']; const resource = ['client'];
export const clientOperations = [ export const clientOperations = [
{ {
@ -13,6 +13,16 @@ export const clientOperations = [
}, },
}, },
options: [ options: [
{
name: 'Create',
value: 'create',
description: `Create a client`,
},
{
name: 'Delete',
value: 'delete',
description: `Delete a client`,
},
{ {
name: 'Get', name: 'Get',
value: 'get', value: 'get',
@ -23,21 +33,12 @@ export const clientOperations = [
value: 'getAll', value: 'getAll',
description: 'Get data of all clients', description: 'Get data of all clients',
}, },
{
name: 'Create',
value: 'create',
description: `Create a client`,
},
{ {
name: 'Update', name: 'Update',
value: 'update', value: 'update',
description: `Update a client`, description: `Update a client`,
}, },
{
name: 'Delete',
value: 'delete',
description: `Delete a client`,
},
], ],
default: 'getAll', default: 'getAll',
description: 'The operation to perform.', description: 'The operation to perform.',
@ -252,20 +253,6 @@ export const clientFields = [
}, },
default: {}, default: {},
options: [ options: [
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
description: 'Whether the client is active, or archived. Defaults to true.'
},
{
displayName: 'Is Active',
name: 'is_active',
type: 'string',
default: '',
description: 'Whether the client is active, or archived. Defaults to true.'
},
{ {
displayName: 'Address', displayName: 'Address',
name: 'address', name: 'address',
@ -280,6 +267,20 @@ export const clientFields = [
default: '', default: '',
description: 'The currency used by the estimate. If not provided, the clients currency will be used. See a list of supported currencies' description: 'The currency used by the estimate. If not provided, the clients currency will be used. See a list of supported currencies'
}, },
{
displayName: 'Is Active',
name: 'is_active',
type: 'boolean',
default: true,
description: 'Whether the client is active, or archived. Defaults to true.'
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
description: 'Whether the client is active, or archived. Defaults to true.'
},
], ],
}, },

View file

@ -1,6 +1,6 @@
import { INodeProperties } from "n8n-workflow"; import { INodeProperties } from 'n8n-workflow';
const resource = [ 'companies' ]; const resource = [ 'company' ];
export const companyOperations = [ export const companyOperations = [
{ {

View file

@ -1,6 +1,6 @@
import { INodeProperties } from "n8n-workflow"; import { INodeProperties } from 'n8n-workflow';
const resource = ['contacts']; const resource = ['contact'];
export const contactOperations = [ export const contactOperations = [
{ {
@ -13,6 +13,16 @@ export const contactOperations = [
}, },
}, },
options: [ options: [
{
name: 'Create',
value: 'create',
description: `Create a contact`,
},
{
name: 'Delete',
value: 'delete',
description: `Delete a contact`,
},
{ {
name: 'Get', name: 'Get',
value: 'get', value: 'get',
@ -23,21 +33,11 @@ export const contactOperations = [
value: 'getAll', value: 'getAll',
description: 'Get data of all contacts', description: 'Get data of all contacts',
}, },
{
name: 'Create',
value: 'create',
description: `Create a contact`,
},
{ {
name: 'Update', name: 'Update',
value: 'update', value: 'update',
description: `Update a contact`, description: `Update a contact`,
}, },
{
name: 'Delete',
value: 'delete',
description: `Delete a contact`,
},
], ],
default: 'getAll', default: 'getAll',
description: 'The operation to perform.', description: 'The operation to perform.',
@ -107,7 +107,7 @@ export const contactFields = [
displayName: 'Is Active', displayName: 'Is Active',
name: 'is_active', name: 'is_active',
type: 'boolean', type: 'boolean',
default: '', default: true,
description: 'Pass true to only return active clients and false to return inactive clients.', description: 'Pass true to only return active clients and false to return inactive clients.',
}, },
{ {
@ -164,8 +164,8 @@ export const contactFields = [
/* contact:create */ /* contact:create */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'First name', displayName: 'First Name',
name: 'first_name', name: 'firstName',
type: 'string', type: 'string',
displayOptions: { displayOptions: {
show: { show: {
@ -181,7 +181,7 @@ export const contactFields = [
}, },
{ {
displayName: 'Client Id', displayName: 'Client Id',
name: 'client_id', name: 'clientId',
type: 'string', type: 'string',
displayOptions: { displayOptions: {
show: { show: {
@ -297,7 +297,7 @@ export const contactFields = [
description: 'The ID of the client associated with this contact.', description: 'The ID of the client associated with this contact.',
}, },
{ {
displayName: 'First name', displayName: 'First Name',
name: 'first_name', name: 'first_name',
type: 'string', type: 'string',
default: '', default: '',

View file

@ -1,6 +1,6 @@
import { INodeProperties } from "n8n-workflow"; import { INodeProperties } from 'n8n-workflow';
const resource = [ 'estimates' ]; const resource = [ 'estimate' ];
export const estimateOperations = [ export const estimateOperations = [
{ {
@ -13,6 +13,16 @@ export const estimateOperations = [
}, },
}, },
options: [ options: [
{
name: 'Create',
value: 'create',
description: `Create a estimate`,
},
{
name: 'Delete',
value: 'delete',
description: `Delete an estimate`,
},
{ {
name: 'Get', name: 'Get',
value: 'get', value: 'get',
@ -23,21 +33,11 @@ export const estimateOperations = [
value: 'getAll', value: 'getAll',
description: 'Get data of all estimates', description: 'Get data of all estimates',
}, },
{
name: 'Create',
value: 'create',
description: `Create a estimate`,
},
{ {
name: 'Update', name: 'Update',
value: 'update', value: 'update',
description: `Update a estimate`, description: `Update a estimate`,
}, },
{
name: 'Delete',
value: 'delete',
description: `Delete an estimate`,
},
], ],
default: 'getAll', default: 'getAll',
description: 'The operation to perform.', description: 'The operation to perform.',
@ -110,13 +110,6 @@ export const estimateFields = [
default: '', default: '',
description: 'Only return time entries belonging to the client with the given ID.', description: 'Only return time entries belonging to the client with the given ID.',
}, },
{
displayName: 'Updated Since',
name: 'updated_since',
type: 'dateTime',
default: '',
description: 'Only return time entries that have been updated since the given date and time.',
},
{ {
displayName: 'From', displayName: 'From',
name: 'from', name: 'from',
@ -124,6 +117,13 @@ export const estimateFields = [
default: '', default: '',
description: 'Only return time entries with a spent_date on or after the given date.', description: 'Only return time entries with a spent_date on or after the given date.',
}, },
{
displayName: 'State',
name: 'state',
type: 'string',
default: '',
description: 'Only return estimates with a state matching the value provided. Options: draft, sent, accepted, or declined.',
},
{ {
displayName: 'To', displayName: 'To',
name: 'to', name: 'to',
@ -132,11 +132,11 @@ export const estimateFields = [
description: 'Only return time entries with a spent_date on or before the given date.', description: 'Only return time entries with a spent_date on or before the given date.',
}, },
{ {
displayName: 'State', displayName: 'Updated Since',
name: 'state', name: 'updated_since',
type: 'string', type: 'dateTime',
default: '', default: '',
description: 'Only return estimates with a state matching the value provided. Options: draft, sent, accepted, or declined.', description: 'Only return time entries that have been updated since the given date and time.',
}, },
{ {
displayName: 'Page', displayName: 'Page',
@ -196,7 +196,7 @@ export const estimateFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Client Id', displayName: 'Client Id',
name: 'client_id', name: 'clientId',
type: 'string', type: 'string',
displayOptions: { displayOptions: {
show: { show: {
@ -225,6 +225,34 @@ export const estimateFields = [
}, },
default: {}, default: {},
options: [ options: [
{
displayName: 'Currency',
name: 'currency',
type: 'string',
default: '',
description: 'The currency used by the estimate. If not provided, the clients currency will be used. See a list of supported currencies'
},
{
displayName: 'Discount',
name: 'over_budget_notification_percentage',
type: 'string',
default: '',
description: 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.'
},
{
displayName: 'Issue Date',
name: 'issue_date',
type: 'dateTime',
default: '',
description: 'Date the invoice was issued. Defaults to todays date.'
},
{
displayName: 'Notes',
name: 'notes',
type: 'string',
default: '',
description: 'Any additional notes to include on the estimate.'
},
{ {
displayName: 'Number', displayName: 'Number',
name: 'number', name: 'number',
@ -239,6 +267,13 @@ export const estimateFields = [
default: '', default: '',
description: 'The purchase order number.' description: 'The purchase order number.'
}, },
{
displayName: 'Subject',
name: 'subject',
type: 'string',
default: '',
description: 'The estimate subject.'
},
{ {
displayName: 'Tax', displayName: 'Tax',
name: 'tax', name: 'tax',
@ -253,42 +288,6 @@ export const estimateFields = [
default: '', default: '',
description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.' description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.'
}, },
{
displayName: 'Discount',
name: 'over_budget_notification_percentage',
type: 'string',
default: '',
description: 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.'
},
{
displayName: 'Subject',
name: 'subject',
type: 'string',
default: '',
description: 'The estimate subject.'
},
{
displayName: 'Currency',
name: 'currency',
type: 'string',
default: '',
description: 'The currency used by the estimate. If not provided, the clients currency will be used. See a list of supported currencies'
},
{
displayName: 'Notes',
name: 'notes',
type: 'string',
default: '',
description: 'Any additional notes to include on the estimate.'
},
{
displayName: 'Issue Date',
name: 'issue_date',
type: 'dateTime',
default: '',
description: 'Date the invoice was issued. Defaults to todays date.'
},
], ],
}, },
@ -333,6 +332,27 @@ export const estimateFields = [
default: '', default: '',
description: 'The ID of the retainer associated with this invoice..', description: 'The ID of the retainer associated with this invoice..',
}, },
{
displayName: 'Currency',
name: 'currency',
type: 'string',
default: '',
description: 'The currency used by the estimate. If not provided, the clients currency will be used. See a list of supported currencies'
},
{
displayName: 'Discount',
name: 'over_budget_notification_percentage',
type: 'string',
default: '',
description: 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.'
},
{
displayName: 'Issue Date',
name: 'issue_date',
type: 'dateTime',
default: '',
description: 'Date the invoice was issued. Defaults to todays date.'
},
{ {
displayName: 'Number', displayName: 'Number',
name: 'number', name: 'number',
@ -340,6 +360,13 @@ export const estimateFields = [
default: '', default: '',
description: 'If no value is set, the number will be automatically generated.' description: 'If no value is set, the number will be automatically generated.'
}, },
{
displayName: 'Notes',
name: 'notes',
type: 'string',
default: '',
description: 'Any additional notes to include on the estimate.'
},
{ {
displayName: 'Purchase Order', displayName: 'Purchase Order',
name: 'purchase_order', name: 'purchase_order',
@ -347,6 +374,13 @@ export const estimateFields = [
default: '', default: '',
description: 'The purchase order number.' description: 'The purchase order number.'
}, },
{
displayName: 'Subject',
name: 'subject',
type: 'string',
default: '',
description: 'The estimate subject.'
},
{ {
displayName: 'Tax', displayName: 'Tax',
name: 'tax', name: 'tax',
@ -361,42 +395,6 @@ export const estimateFields = [
default: '', default: '',
description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.' description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.'
}, },
{
displayName: 'Discount',
name: 'over_budget_notification_percentage',
type: 'string',
default: '',
description: 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.'
},
{
displayName: 'Subject',
name: 'subject',
type: 'string',
default: '',
description: 'The estimate subject.'
},
{
displayName: 'Currency',
name: 'currency',
type: 'string',
default: '',
description: 'The currency used by the estimate. If not provided, the clients currency will be used. See a list of supported currencies'
},
{
displayName: 'Notes',
name: 'notes',
type: 'string',
default: '',
description: 'Any additional notes to include on the estimate.'
},
{
displayName: 'Issue Date',
name: 'issue_date',
type: 'dateTime',
default: '',
description: 'Date the invoice was issued. Defaults to todays date.'
},
], ],
}, },

View file

@ -1,6 +1,6 @@
import { INodeProperties } from "n8n-workflow"; import { INodeProperties } from 'n8n-workflow';
const resource = [ 'expenses' ]; const resource = [ 'expense' ];
export const expenseOperations = [ export const expenseOperations = [
{ {
@ -103,13 +103,6 @@ export const expenseFields = [
}, },
}, },
options: [ options: [
{
displayName: 'User ID',
name: 'user_id',
type: 'string',
default: '',
description: 'Only return time entries belonging to the user with the given ID.',
},
{ {
displayName: 'Client ID', displayName: 'Client ID',
name: 'client_id', name: 'client_id',
@ -117,27 +110,6 @@ export const expenseFields = [
default: '', default: '',
description: 'Only return time entries belonging to the client with the given ID.', description: 'Only return time entries belonging to the client with the given ID.',
}, },
{
displayName: 'Project ID',
name: 'project_id',
type: 'string',
default: '',
description: 'Only return time entries belonging to the client with the given ID.',
},
{
displayName: 'Is Billed',
name: 'is_billed',
type: 'boolean',
default: '',
description: 'Pass true to only return time entries that have been invoiced and false to return time entries that have not been invoiced.',
},
{
displayName: 'Updated Since',
name: 'updated_since',
type: 'dateTime',
default: '',
description: 'Only return time entries that have been updated since the given date and time.',
},
{ {
displayName: 'From', displayName: 'From',
name: 'from', name: 'from',
@ -146,11 +118,11 @@ export const expenseFields = [
description: 'Only return time entries with a spent_date on or after the given date.', description: 'Only return time entries with a spent_date on or after the given date.',
}, },
{ {
displayName: 'To', displayName: 'Is Billed',
name: 'to', name: 'is_billed',
type: 'dateTime', type: 'boolean',
default: '', default: false,
description: 'Only return time entries with a spent_date on or before the given date.', description: 'Pass true to only return time entries that have been invoiced and false to return time entries that have not been invoiced.',
}, },
{ {
displayName: 'Page', displayName: 'Page',
@ -161,7 +133,35 @@ export const expenseFields = [
}, },
default: 1, default: 1,
description: 'The page number to use in pagination. For instance, if you make a list request and receive 100 records, your subsequent call can include page=2 to retrieve the next page of the list. (Default: 1)', description: 'The page number to use in pagination. For instance, if you make a list request and receive 100 records, your subsequent call can include page=2 to retrieve the next page of the list. (Default: 1)',
} },
{
displayName: 'Project ID',
name: 'project_id',
type: 'string',
default: '',
description: 'Only return time entries belonging to the client with the given ID.',
},
{
displayName: 'To',
name: 'to',
type: 'dateTime',
default: '',
description: 'Only return time entries with a spent_date on or before the given date.',
},
{
displayName: 'Updated Since',
name: 'updated_since',
type: 'dateTime',
default: '',
description: 'Only return time entries that have been updated since the given date and time.',
},
{
displayName: 'User ID',
name: 'user_id',
type: 'string',
default: '',
description: 'Only return time entries belonging to the user with the given ID.',
},
] ]
}, },
@ -210,7 +210,7 @@ export const expenseFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Project Id', displayName: 'Project Id',
name: 'project_id', name: 'projectId',
type: 'string', type: 'string',
displayOptions: { displayOptions: {
show: { show: {
@ -226,7 +226,7 @@ export const expenseFields = [
}, },
{ {
displayName: 'Expense Category Id', displayName: 'Expense Category Id',
name: 'expense_category_id', name: 'expenseCategoryId',
type: 'string', type: 'string',
displayOptions: { displayOptions: {
show: { show: {
@ -242,7 +242,7 @@ export const expenseFields = [
}, },
{ {
displayName: 'Spent Date', displayName: 'Spent Date',
name: 'spent_date', name: 'spentDate',
type: 'dateTime', type: 'dateTime',
displayOptions: { displayOptions: {
show: { show: {
@ -271,32 +271,11 @@ export const expenseFields = [
}, },
default: {}, default: {},
options: [ options: [
{
displayName: 'User Id',
name: 'user_id',
type: 'boolean',
default: true,
description: 'The ID of the user associated with this expense. Defaults to the ID of the currently authenticated user.'
},
{
displayName: 'Units',
name: 'units',
type: 'string',
default: '',
description: 'The quantity of units to use in calculating the total_cost of the expense.'
},
{
displayName: 'Total Cost',
name: 'total_cost',
type: 'string',
default: '',
description: 'The total amount of the expense.'
},
{ {
displayName: 'Billable', displayName: 'Billable',
name: 'billable', name: 'billable',
type: 'string', type: 'boolean',
default: '', default: true,
description: 'Whether this expense is billable or not. Defaults to true.' description: 'Whether this expense is billable or not. Defaults to true.'
}, },
{ {
@ -306,7 +285,27 @@ export const expenseFields = [
default: '', default: '',
description: 'Notes about the expense.' description: 'Notes about the expense.'
}, },
{
displayName: 'Total Cost',
name: 'total_cost',
type: 'string',
default: '',
description: 'The total amount of the expense.'
},
{
displayName: 'Units',
name: 'units',
type: 'string',
default: '',
description: 'The quantity of units to use in calculating the total_cost of the expense.'
},
{
displayName: 'User Id',
name: 'user_id',
type: 'boolean',
default: true,
description: 'The ID of the user associated with this expense. Defaults to the ID of the currently authenticated user.'
},
], ],
}, },
@ -345,11 +344,11 @@ export const expenseFields = [
default: {}, default: {},
options: [ options: [
{ {
displayName: 'Project Id', displayName: 'Billable',
name: 'project_id', name: 'billable',
type: 'string', type: 'boolean',
default: '', default: true,
description: 'The ID of the project associated with this expense.', description: 'Whether this expense is billable or not. Defaults to true.'
}, },
{ {
displayName: 'Expense Category Id', displayName: 'Expense Category Id',
@ -358,6 +357,20 @@ export const expenseFields = [
default: '', default: '',
description: 'The ID of the expense category this expense is being tracked against.', description: 'The ID of the expense category this expense is being tracked against.',
}, },
{
displayName: 'Notes',
name: 'notes',
type: 'string',
default: '',
description: 'Notes about the expense.'
},
{
displayName: 'Project Id',
name: 'project_id',
type: 'string',
default: '',
description: 'The ID of the project associated with this expense.',
},
{ {
displayName: 'Spent Date', displayName: 'Spent Date',
name: 'spent_date', name: 'spent_date',
@ -365,20 +378,6 @@ export const expenseFields = [
default: '', default: '',
description: 'Date the expense occurred.', description: 'Date the expense occurred.',
}, },
{
displayName: 'User Id',
name: 'user_id',
type: 'boolean',
default: true,
description: 'The ID of the user associated with this expense. Defaults to the ID of the currently authenticated user.'
},
{
displayName: 'Units',
name: 'units',
type: 'string',
default: '',
description: 'The quantity of units to use in calculating the total_cost of the expense.'
},
{ {
displayName: 'Total Cost', displayName: 'Total Cost',
name: 'total_cost', name: 'total_cost',
@ -387,20 +386,19 @@ export const expenseFields = [
description: 'The total amount of the expense.' description: 'The total amount of the expense.'
}, },
{ {
displayName: 'Billable', displayName: 'Units',
name: 'billable', name: 'units',
type: 'string', type: 'string',
default: '', default: '',
description: 'Whether this expense is billable or not. Defaults to true.' description: 'The quantity of units to use in calculating the total_cost of the expense.'
}, },
{ {
displayName: 'Notes', displayName: 'User Id',
name: 'notes', name: 'user_id',
type: 'string', type: 'boolean',
default: '', default: true,
description: 'Notes about the expense.' description: 'The ID of the user associated with this expense. Defaults to the ID of the currently authenticated user.'
}, },
], ],
}, },

View file

@ -8,17 +8,17 @@ import {
INodeType, INodeType,
} from 'n8n-workflow'; } from 'n8n-workflow';
import { harvestApiRequest, harvestApiRequestAllItems } from './GenericFunctions';
import { timeEntryOperations, timeEntryFields } from './TimeEntryDescription';
import { clientOperations, clientFields } from './ClientDescription'; import { clientOperations, clientFields } from './ClientDescription';
import { companyOperations } from './CompanyDescription';
import { contactOperations, contactFields } from './ContactDescription'; import { contactOperations, contactFields } from './ContactDescription';
import { companyOperations } from './CompanyDescription';
import { estimateOperations, estimateFields } from './EstimateDescription';
import { expenseOperations, expenseFields } from './ExpenseDescription'; import { expenseOperations, expenseFields } from './ExpenseDescription';
import { harvestApiRequest, harvestApiRequestAllItems } from './GenericFunctions';
import { invoiceOperations, invoiceFields } from './InvoiceDescription'; import { invoiceOperations, invoiceFields } from './InvoiceDescription';
import { projectOperations, projectFields } from './ProjectDescription'; import { projectOperations, projectFields } from './ProjectDescription';
import { taskOperations, taskFields } from './TaskDescription'; import { taskOperations, taskFields } from './TaskDescription';
import { timeEntryOperations, timeEntryFields } from './TimeEntryDescription';
import { userOperations, userFields } from './UserDescription'; import { userOperations, userFields } from './UserDescription';
import { estimateOperations, estimateFields } from './EstimateDescription';
/** /**
* fetch All resource using paginated calls * fetch All resource using paginated calls
@ -75,46 +75,46 @@ export class Harvest implements INodeType {
{ {
name: 'Client', name: 'Client',
value: 'clients', value: 'client',
}, },
{ {
name: 'Company', name: 'Company',
value: 'companies', value: 'company',
}, },
{ {
name: 'Contact', name: 'Contact',
value: 'contacts', value: 'contact',
}, },
{ {
name: 'Estimates', name: 'Estimate',
value: 'estimates', value: 'estimate',
}, },
{ {
name: 'Expense', name: 'Expense',
value: 'expenses', value: 'expense',
}, },
{ {
name: 'Invoice', name: 'Invoice',
value: 'invoices', value: 'invoice',
}, },
{ {
name: 'Project', name: 'Project',
value: 'projects', value: 'project',
}, },
{ {
name: 'Task', name: 'Task',
value: 'tasks', value: 'task',
}, },
{ {
name: 'Time Entries', name: 'Time Entries',
value: 'time_entries', value: 'timeEntry',
}, },
{ {
name: 'User', name: 'User',
value: 'users', value: 'user',
}, },
], ],
default: 'tasks', default: 'task',
description: 'The resource to operate on.', description: 'The resource to operate on.',
}, },
@ -147,7 +147,6 @@ export class Harvest implements INodeType {
const items = this.getInputData(); const items = this.getInputData();
const returnData: IDataObject[] = []; const returnData: IDataObject[] = [];
const resource = this.getNodeParameter('resource', 0) as string; const resource = this.getNodeParameter('resource', 0) as string;
const operation = this.getNodeParameter('operation', 0) as string; const operation = this.getNodeParameter('operation', 0) as string;
@ -156,12 +155,11 @@ export class Harvest implements INodeType {
let body: IDataObject | Buffer; let body: IDataObject | Buffer;
let qs: IDataObject; let qs: IDataObject;
for (let i = 0; i < items.length; i++) { for (let i = 0; i < items.length; i++) {
body = {}; body = {};
qs = {}; qs = {};
if (resource === 'time_entries') { if (resource === 'timeEntry') {
if (operation === 'get') { if (operation === 'get') {
// ---------------------------------- // ----------------------------------
// get // get
@ -170,7 +168,7 @@ export class Harvest implements INodeType {
requestMethod = 'GET'; requestMethod = 'GET';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `time_entries/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
@ -179,7 +177,7 @@ export class Harvest implements INodeType {
// ---------------------------------- // ----------------------------------
// getAll // getAll
// ---------------------------------- // ----------------------------------
const responseData: IDataObject[] = await getAllResource.call(this, resource, i); const responseData: IDataObject[] = await getAllResource.call(this, 'time_entries', i);
returnData.push.apply(returnData, responseData); returnData.push.apply(returnData, responseData);
} else if (operation === 'createByStartEnd') { } else if (operation === 'createByStartEnd') {
@ -188,7 +186,7 @@ export class Harvest implements INodeType {
// ---------------------------------- // ----------------------------------
requestMethod = 'POST'; requestMethod = 'POST';
endpoint = resource; endpoint = 'time_entries';
body.project_id = this.getNodeParameter('projectId', i) as string; body.project_id = this.getNodeParameter('projectId', i) as string;
body.task_id = this.getNodeParameter('taskId', i) as string; body.task_id = this.getNodeParameter('taskId', i) as string;
@ -206,7 +204,7 @@ export class Harvest implements INodeType {
// ---------------------------------- // ----------------------------------
requestMethod = 'POST'; requestMethod = 'POST';
endpoint = resource; endpoint = 'time_entries';
body.project_id = this.getNodeParameter('projectId', i) as string; body.project_id = this.getNodeParameter('projectId', i) as string;
body.task_id = this.getNodeParameter('taskId', i) as string; body.task_id = this.getNodeParameter('taskId', i) as string;
@ -225,7 +223,7 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE'; requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `time_entries/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
@ -236,7 +234,7 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE'; requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}/external_reference`; endpoint = `time_entries/${id}/external_reference`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
@ -248,7 +246,7 @@ export class Harvest implements INodeType {
requestMethod = 'PATCH'; requestMethod = 'PATCH';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}/restart`; endpoint = `time_entries/${id}/restart`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
@ -260,7 +258,7 @@ export class Harvest implements INodeType {
requestMethod = 'PATCH'; requestMethod = 'PATCH';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}/stop`; endpoint = `time_entries/${id}/stop`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
@ -272,7 +270,7 @@ export class Harvest implements INodeType {
requestMethod = 'PATCH'; requestMethod = 'PATCH';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `time_entries/${id}`;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
@ -284,7 +282,7 @@ export class Harvest implements INodeType {
throw new Error(`The operation "${operation}" is not known!`); throw new Error(`The operation "${operation}" is not known!`);
} }
} else if (resource === 'clients') { } else if (resource === 'client') {
if (operation === 'get') { if (operation === 'get') {
// ---------------------------------- // ----------------------------------
// get // get
@ -293,7 +291,7 @@ export class Harvest implements INodeType {
requestMethod = 'GET'; requestMethod = 'GET';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `clients/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
@ -303,7 +301,7 @@ export class Harvest implements INodeType {
// getAll // getAll
// ---------------------------------- // ----------------------------------
const responseData: IDataObject[] = await getAllResource.call(this, resource, i); const responseData: IDataObject[] = await getAllResource.call(this, 'clients', i);
returnData.push.apply(returnData, responseData); returnData.push.apply(returnData, responseData);
} else if (operation === 'create') { } else if (operation === 'create') {
@ -312,7 +310,7 @@ export class Harvest implements INodeType {
// ---------------------------------- // ----------------------------------
requestMethod = 'POST'; requestMethod = 'POST';
endpoint = resource; endpoint = 'clients';
body.name = this.getNodeParameter('name', i) as string; body.name = this.getNodeParameter('name', i) as string;
@ -329,7 +327,7 @@ export class Harvest implements INodeType {
requestMethod = 'PATCH'; requestMethod = 'PATCH';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `clients/${id}`;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
Object.assign(qs, updateFields); Object.assign(qs, updateFields);
@ -344,14 +342,14 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE'; requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `clients/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
} else { } else {
throw new Error(`The resource "${resource}" is not known!`); throw new Error(`The resource "${resource}" is not known!`);
} }
} else if (resource === 'projects') { } else if (resource === 'project') {
if (operation === 'get') { if (operation === 'get') {
// ---------------------------------- // ----------------------------------
// get // get
@ -360,7 +358,7 @@ export class Harvest implements INodeType {
requestMethod = 'GET'; requestMethod = 'GET';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `projects/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
@ -370,7 +368,7 @@ export class Harvest implements INodeType {
// getAll // getAll
// ---------------------------------- // ----------------------------------
const responseData: IDataObject[] = await getAllResource.call(this, resource, i); const responseData: IDataObject[] = await getAllResource.call(this, 'projects', i);
returnData.push.apply(returnData, responseData); returnData.push.apply(returnData, responseData);
} else if (operation === 'create') { } else if (operation === 'create') {
@ -379,13 +377,13 @@ export class Harvest implements INodeType {
// ---------------------------------- // ----------------------------------
requestMethod = 'POST'; requestMethod = 'POST';
endpoint = resource; endpoint = 'projects';
body.client_id = this.getNodeParameter('client_id', i) as string; body.client_id = this.getNodeParameter('clientId', i) as string;
body.name = this.getNodeParameter('name', i) as string; body.name = this.getNodeParameter('name', i) as string;
body.is_billable = this.getNodeParameter('is_billable', i) as string; body.is_billable = this.getNodeParameter('isBillable', i) as string;
body.bill_by = this.getNodeParameter('bill_by', i) as string; body.bill_by = this.getNodeParameter('billBy', i) as string;
body.budget_by = this.getNodeParameter('budget_by', i) as string; body.budget_by = this.getNodeParameter('budgetBy', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
Object.assign(body, additionalFields); Object.assign(body, additionalFields);
@ -400,7 +398,7 @@ export class Harvest implements INodeType {
requestMethod = 'PATCH'; requestMethod = 'PATCH';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `projects/${id}`;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
@ -415,14 +413,14 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE'; requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `projects/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
} else { } else {
throw new Error(`The resource "${resource}" is not known!`); throw new Error(`The resource "${resource}" is not known!`);
} }
} else if (resource === 'users') { } else if (resource === 'user') {
if (operation === 'get') { if (operation === 'get') {
// ---------------------------------- // ----------------------------------
// get // get
@ -431,7 +429,7 @@ export class Harvest implements INodeType {
requestMethod = 'GET'; requestMethod = 'GET';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `users/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
@ -441,7 +439,7 @@ export class Harvest implements INodeType {
// getAll // getAll
// ---------------------------------- // ----------------------------------
const responseData: IDataObject[] = await getAllResource.call(this, resource, i); const responseData: IDataObject[] = await getAllResource.call(this, 'users', i);
returnData.push.apply(returnData, responseData); returnData.push.apply(returnData, responseData);
} else if (operation === 'me') { } else if (operation === 'me') {
@ -451,24 +449,23 @@ export class Harvest implements INodeType {
requestMethod = 'GET'; requestMethod = 'GET';
endpoint = `${resource}/me`; endpoint = `users/me`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
} else if (operation === 'create') { } else if (operation === 'create') {
// ---------------------------------- // ----------------------------------
// createByDuration // create
// ---------------------------------- // ----------------------------------
requestMethod = 'POST'; requestMethod = 'POST';
endpoint = resource; endpoint = 'users';
body.first_name = this.getNodeParameter('first_name', i) as string; body.first_name = this.getNodeParameter('firstName', i) as string;
body.last_name = this.getNodeParameter('last_name', i) as string; body.last_name = this.getNodeParameter('lastName', i) as string;
body.email = this.getNodeParameter('email', i) as string; body.email = this.getNodeParameter('email', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
Object.assign(body, additionalFields); Object.assign(body, additionalFields);
@ -482,7 +479,7 @@ export class Harvest implements INodeType {
requestMethod = 'PATCH'; requestMethod = 'PATCH';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `users/${id}`;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
Object.assign(qs, updateFields); Object.assign(qs, updateFields);
@ -497,14 +494,14 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE'; requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `users/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
} else { } else {
throw new Error(`The resource "${resource}" is not known!`); throw new Error(`The resource "${resource}" is not known!`);
} }
} else if (resource === 'contacts') { } else if (resource === 'contact') {
if (operation === 'get') { if (operation === 'get') {
// ---------------------------------- // ----------------------------------
// get // get
@ -513,7 +510,7 @@ export class Harvest implements INodeType {
requestMethod = 'GET'; requestMethod = 'GET';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `contacts/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
@ -523,7 +520,7 @@ export class Harvest implements INodeType {
// getAll // getAll
// ---------------------------------- // ----------------------------------
const responseData: IDataObject[] = await getAllResource.call(this, resource, i); const responseData: IDataObject[] = await getAllResource.call(this, 'contacts', i);
returnData.push.apply(returnData, responseData); returnData.push.apply(returnData, responseData);
} else if (operation === 'create') { } else if (operation === 'create') {
@ -532,10 +529,10 @@ export class Harvest implements INodeType {
// ---------------------------------- // ----------------------------------
requestMethod = 'POST'; requestMethod = 'POST';
endpoint = resource; endpoint = 'contacts';
body.client_id = this.getNodeParameter('client_id', i) as string; body.client_id = this.getNodeParameter('clientId', i) as string;
body.first_name = this.getNodeParameter('first_name', i) as string; body.first_name = this.getNodeParameter('firstName', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
Object.assign(body, additionalFields); Object.assign(body, additionalFields);
@ -550,7 +547,7 @@ export class Harvest implements INodeType {
requestMethod = 'PATCH'; requestMethod = 'PATCH';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `contacts/${id}`;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
Object.assign(qs, updateFields); Object.assign(qs, updateFields);
@ -565,14 +562,14 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE'; requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `contacts/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
} else { } else {
throw new Error(`The resource "${resource}" is not known!`); throw new Error(`The resource "${resource}" is not known!`);
} }
} else if (resource === 'companies') { } else if (resource === 'company') {
if (operation === 'get') { if (operation === 'get') {
// ---------------------------------- // ----------------------------------
// get // get
@ -587,7 +584,7 @@ export class Harvest implements INodeType {
} else { } else {
throw new Error(`The resource "${resource}" is not known!`); throw new Error(`The resource "${resource}" is not known!`);
} }
} else if (resource === 'tasks') { } else if (resource === 'task') {
if (operation === 'get') { if (operation === 'get') {
// ---------------------------------- // ----------------------------------
// get // get
@ -596,7 +593,7 @@ export class Harvest implements INodeType {
requestMethod = 'GET'; requestMethod = 'GET';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `tasks/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
@ -606,7 +603,7 @@ export class Harvest implements INodeType {
// getAll // getAll
// ---------------------------------- // ----------------------------------
const responseData: IDataObject[] = await getAllResource.call(this, resource, i); const responseData: IDataObject[] = await getAllResource.call(this, 'tasks', i);
returnData.push.apply(returnData, responseData); returnData.push.apply(returnData, responseData);
} else if (operation === 'delete') { } else if (operation === 'delete') {
@ -616,14 +613,14 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE'; requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `tasks/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
} else { } else {
throw new Error(`The resource "${resource}" is not known!`); throw new Error(`The resource "${resource}" is not known!`);
} }
} else if (resource === 'invoices') { } else if (resource === 'invoice') {
if (operation === 'get') { if (operation === 'get') {
// ---------------------------------- // ----------------------------------
// get // get
@ -632,7 +629,7 @@ export class Harvest implements INodeType {
requestMethod = 'GET'; requestMethod = 'GET';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `invoices/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
@ -642,7 +639,7 @@ export class Harvest implements INodeType {
// getAll // getAll
// ---------------------------------- // ----------------------------------
const responseData: IDataObject[] = await getAllResource.call(this, resource, i); const responseData: IDataObject[] = await getAllResource.call(this, 'invoices', i);
returnData.push.apply(returnData, responseData); returnData.push.apply(returnData, responseData);
} else if (operation === 'create') { } else if (operation === 'create') {
@ -651,9 +648,9 @@ export class Harvest implements INodeType {
// ---------------------------------- // ----------------------------------
requestMethod = 'POST'; requestMethod = 'POST';
endpoint = resource; endpoint = 'invoices';
body.client_id = this.getNodeParameter('client_id', i) as string; body.client_id = this.getNodeParameter('clientId', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
Object.assign(body, additionalFields); Object.assign(body, additionalFields);
@ -668,7 +665,7 @@ export class Harvest implements INodeType {
requestMethod = 'PATCH'; requestMethod = 'PATCH';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `invoices/${id}`;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
Object.assign(qs, updateFields); Object.assign(qs, updateFields);
@ -683,14 +680,14 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE'; requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `invoices/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
} else { } else {
throw new Error(`The resource "${resource}" is not known!`); throw new Error(`The resource "${resource}" is not known!`);
} }
} else if (resource === 'expenses') { } else if (resource === 'expense') {
if (operation === 'get') { if (operation === 'get') {
// ---------------------------------- // ----------------------------------
// get // get
@ -699,7 +696,7 @@ export class Harvest implements INodeType {
requestMethod = 'GET'; requestMethod = 'GET';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `expenses/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
@ -709,7 +706,7 @@ export class Harvest implements INodeType {
// getAll // getAll
// ---------------------------------- // ----------------------------------
const responseData: IDataObject[] = await getAllResource.call(this, resource, i); const responseData: IDataObject[] = await getAllResource.call(this, 'expenses', i);
returnData.push.apply(returnData, responseData); returnData.push.apply(returnData, responseData);
} else if (operation === 'create') { } else if (operation === 'create') {
@ -718,12 +715,11 @@ export class Harvest implements INodeType {
// ---------------------------------- // ----------------------------------
requestMethod = 'POST'; requestMethod = 'POST';
endpoint = resource; endpoint = 'expenses';
body.project_id = this.getNodeParameter('project_id', i) as string;
body.expense_category_id = this.getNodeParameter('expense_category_id', i) as string;
body.spent_date = this.getNodeParameter('spent_date', i) as string;
body.project_id = this.getNodeParameter('projectId', i) as string;
body.expense_category_id = this.getNodeParameter('expenseCategoryId', i) as string;
body.spent_date = this.getNodeParameter('spentDate', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
Object.assign(body, additionalFields); Object.assign(body, additionalFields);
@ -738,7 +734,7 @@ export class Harvest implements INodeType {
requestMethod = 'PATCH'; requestMethod = 'PATCH';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `expenses/${id}`;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
Object.assign(qs, updateFields); Object.assign(qs, updateFields);
@ -753,14 +749,14 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE'; requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `expenses/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
} else { } else {
throw new Error(`The resource "${resource}" is not known!`); throw new Error(`The resource "${resource}" is not known!`);
} }
} else if (resource === 'estimates') { } else if (resource === 'estimate') {
if (operation === 'get') { if (operation === 'get') {
// ---------------------------------- // ----------------------------------
// get // get
@ -769,7 +765,7 @@ export class Harvest implements INodeType {
requestMethod = 'GET'; requestMethod = 'GET';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `estimates/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);
@ -779,7 +775,7 @@ export class Harvest implements INodeType {
// getAll // getAll
// ---------------------------------- // ----------------------------------
const responseData: IDataObject[] = await getAllResource.call(this, resource, i); const responseData: IDataObject[] = await getAllResource.call(this, 'estimates', i);
returnData.push.apply(returnData, responseData); returnData.push.apply(returnData, responseData);
} else if (operation === 'create') { } else if (operation === 'create') {
@ -788,9 +784,9 @@ export class Harvest implements INodeType {
// ---------------------------------- // ----------------------------------
requestMethod = 'POST'; requestMethod = 'POST';
endpoint = resource; endpoint = 'estimates';
body.client_id = this.getNodeParameter('client_id', i) as string; body.client_id = this.getNodeParameter('clientId', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
Object.assign(body, additionalFields); Object.assign(body, additionalFields);
@ -805,7 +801,7 @@ export class Harvest implements INodeType {
requestMethod = 'PATCH'; requestMethod = 'PATCH';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `estimates/${id}`;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
Object.assign(qs, updateFields); Object.assign(qs, updateFields);
@ -820,7 +816,7 @@ export class Harvest implements INodeType {
requestMethod = 'DELETE'; requestMethod = 'DELETE';
const id = this.getNodeParameter('id', i) as string; const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`; endpoint = `estimates/${id}`;
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
returnData.push(responseData); returnData.push(responseData);

View file

@ -1,6 +1,6 @@
import { INodeProperties } from "n8n-workflow"; import { INodeProperties } from 'n8n-workflow';
const resource = [ 'invoices' ]; const resource = [ 'invoice' ];
export const invoiceOperations = [ export const invoiceOperations = [
{ {
@ -221,7 +221,7 @@ export const invoiceFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Client Id', displayName: 'Client Id',
name: 'client_id', name: 'clientId',
type: 'string', type: 'string',
displayOptions: { displayOptions: {
show: { show: {
@ -251,11 +251,25 @@ export const invoiceFields = [
default: {}, default: {},
options: [ options: [
{ {
displayName: 'Retainer Id', displayName: 'Currency',
name: 'retainer_id', name: 'currency',
type: 'boolean', type: 'string',
default: true, default: '',
description: 'The ID of the retainer associated with this invoice.' description: 'The currency used by the invoice. If not provided, the clients currency will be used. See a list of supported currencies'
},
{
displayName: 'Discount',
name: 'over_budget_notification_percentage',
type: 'string',
default: '',
description: 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.'
},
{
displayName: 'Due Date',
name: 'ends_on',
type: 'dateTime',
default: '',
description: 'Date the invoice is due. Defaults to the issue_date if no payment_term is specified.'
}, },
{ {
displayName: 'Estimate Id', displayName: 'Estimate Id',
@ -264,6 +278,20 @@ export const invoiceFields = [
default: '', default: '',
description: 'The ID of the estimate associated with this invoice.' description: 'The ID of the estimate associated with this invoice.'
}, },
{
displayName: 'Issue Date',
name: 'issue_date',
type: 'dateTime',
default: '',
description: 'Date the invoice was issued. Defaults to todays date.'
},
{
displayName: 'Notes',
name: 'notes',
type: 'string',
default: '',
description: 'Notes about the project.'
},
{ {
displayName: 'Number', displayName: 'Number',
name: 'number', name: 'number',
@ -271,6 +299,13 @@ export const invoiceFields = [
default: '', default: '',
description: 'If no value is set, the number will be automatically generated.' description: 'If no value is set, the number will be automatically generated.'
}, },
{
displayName: 'Payment Term',
name: 'payment_term',
type: 'string',
default: '',
description: 'The timeframe in which the invoice should be paid. Defaults to custom. Options: upon receipt, net 15, net 30, net 45, or net 60.'
},
{ {
displayName: 'Purchase Order', displayName: 'Purchase Order',
name: 'purchase_order', name: 'purchase_order',
@ -278,6 +313,20 @@ export const invoiceFields = [
default: '', default: '',
description: 'The purchase order number.' description: 'The purchase order number.'
}, },
{
displayName: 'Retainer Id',
name: 'retainer_id',
type: 'boolean',
default: true,
description: 'The ID of the retainer associated with this invoice.'
},
{
displayName: 'Subject',
name: 'subject',
type: 'string',
default: '',
description: 'The invoice subject.'
},
{ {
displayName: 'Tax', displayName: 'Tax',
name: 'tax', name: 'tax',
@ -292,56 +341,6 @@ export const invoiceFields = [
default: '', default: '',
description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.' description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.'
}, },
{
displayName: 'Discount',
name: 'over_budget_notification_percentage',
type: 'string',
default: '',
description: 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.'
},
{
displayName: 'Subject',
name: 'subject',
type: 'string',
default: '',
description: 'The invoice subject.'
},
{
displayName: 'Currency',
name: 'currency',
type: 'string',
default: '',
description: 'The currency used by the invoice. If not provided, the clients currency will be used. See a list of supported currencies'
},
{
displayName: 'Payment Term',
name: 'payment_term',
type: 'string',
default: '',
description: 'The timeframe in which the invoice should be paid. Defaults to custom. Options: upon receipt, net 15, net 30, net 45, or net 60.'
},
{
displayName: 'Notes',
name: 'notes',
type: 'string',
default: '',
description: 'Notes about the project.'
},
{
displayName: 'Issue Date',
name: 'issue_date',
type: 'dateTime',
default: '',
description: 'Date the invoice was issued. Defaults to todays date.'
},
{
displayName: 'Due Date',
name: 'ends_on',
type: 'dateTime',
default: '',
description: 'Date the invoice is due. Defaults to the issue_date if no payment_term is specified.'
},
], ],
}, },
@ -387,11 +386,25 @@ export const invoiceFields = [
description: 'The ID of the retainer associated with this invoice..', description: 'The ID of the retainer associated with this invoice..',
}, },
{ {
displayName: 'Retainer Id', displayName: 'Currency',
name: 'retainer_id', name: 'currency',
type: 'boolean', type: 'string',
default: true, default: '',
description: 'The ID of the retainer associated with this invoice.' description: 'The currency used by the invoice. If not provided, the clients currency will be used. See a list of supported currencies'
},
{
displayName: 'Discount',
name: 'over_budget_notification_percentage',
type: 'string',
default: '',
description: 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.'
},
{
displayName: 'Due Date',
name: 'ends_on',
type: 'dateTime',
default: '',
description: 'Date the invoice is due. Defaults to the issue_date if no payment_term is specified.'
}, },
{ {
displayName: 'Estimate Id', displayName: 'Estimate Id',
@ -400,6 +413,20 @@ export const invoiceFields = [
default: '', default: '',
description: 'The ID of the estimate associated with this invoice.' description: 'The ID of the estimate associated with this invoice.'
}, },
{
displayName: 'Issue Date',
name: 'issue_date',
type: 'dateTime',
default: '',
description: 'Date the invoice was issued. Defaults to todays date.'
},
{
displayName: 'Notes',
name: 'notes',
type: 'string',
default: '',
description: 'Notes about the project.'
},
{ {
displayName: 'Number', displayName: 'Number',
name: 'number', name: 'number',
@ -407,6 +434,13 @@ export const invoiceFields = [
default: '', default: '',
description: 'If no value is set, the number will be automatically generated.' description: 'If no value is set, the number will be automatically generated.'
}, },
{
displayName: 'Payment Term',
name: 'payment_term',
type: 'string',
default: '',
description: 'The timeframe in which the invoice should be paid. Defaults to custom. Options: upon receipt, net 15, net 30, net 45, or net 60.'
},
{ {
displayName: 'Purchase Order', displayName: 'Purchase Order',
name: 'purchase_order', name: 'purchase_order',
@ -414,6 +448,20 @@ export const invoiceFields = [
default: '', default: '',
description: 'The purchase order number.' description: 'The purchase order number.'
}, },
{
displayName: 'Retainer Id',
name: 'retainer_id',
type: 'boolean',
default: true,
description: 'The ID of the retainer associated with this invoice.'
},
{
displayName: 'Subject',
name: 'subject',
type: 'string',
default: '',
description: 'The invoice subject.'
},
{ {
displayName: 'Tax', displayName: 'Tax',
name: 'tax', name: 'tax',
@ -428,56 +476,6 @@ export const invoiceFields = [
default: '', default: '',
description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.' description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.'
}, },
{
displayName: 'Discount',
name: 'over_budget_notification_percentage',
type: 'string',
default: '',
description: 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.'
},
{
displayName: 'Subject',
name: 'subject',
type: 'string',
default: '',
description: 'The invoice subject.'
},
{
displayName: 'Currency',
name: 'currency',
type: 'string',
default: '',
description: 'The currency used by the invoice. If not provided, the clients currency will be used. See a list of supported currencies'
},
{
displayName: 'Payment Term',
name: 'payment_term',
type: 'string',
default: '',
description: 'The timeframe in which the invoice should be paid. Defaults to custom. Options: upon receipt, net 15, net 30, net 45, or net 60.'
},
{
displayName: 'Notes',
name: 'notes',
type: 'string',
default: '',
description: 'Notes about the project.'
},
{
displayName: 'Issue Date',
name: 'issue_date',
type: 'dateTime',
default: '',
description: 'Date the invoice was issued. Defaults to todays date.'
},
{
displayName: 'Due Date',
name: 'ends_on',
type: 'dateTime',
default: '',
description: 'Date the invoice is due. Defaults to the issue_date if no payment_term is specified.'
},
], ],
}, },
] as INodeProperties[]; ] as INodeProperties[];

View file

@ -1,6 +1,6 @@
import { INodeProperties } from "n8n-workflow"; import { INodeProperties } from 'n8n-workflow';
const resource = ['projects']; const resource = ['project'];
export const projectOperations = [ export const projectOperations = [
{ {
@ -13,6 +13,16 @@ export const projectOperations = [
}, },
}, },
options: [ options: [
{
name: 'Create',
value: 'create',
description: `Create a project`,
},
{
name: 'Delete',
value: 'delete',
description: `Delete a project`,
},
{ {
name: 'Get', name: 'Get',
value: 'get', value: 'get',
@ -23,21 +33,11 @@ export const projectOperations = [
value: 'getAll', value: 'getAll',
description: 'Get data of all projects', description: 'Get data of all projects',
}, },
{
name: 'Create',
value: 'create',
description: `Create a project`,
},
{ {
name: 'Update', name: 'Update',
value: 'update', value: 'update',
description: `Update a project`, description: `Update a project`,
}, },
{
name: 'Delete',
value: 'delete',
description: `Delete a project`,
},
], ],
default: 'getAll', default: 'getAll',
description: 'The operation to perform.', description: 'The operation to perform.',
@ -103,13 +103,6 @@ export const projectFields = [
}, },
}, },
options: [ options: [
{
displayName: 'Is Active',
name: 'is_active',
type: 'boolean',
default: true,
description: 'Pass true to only return active projects and false to return inactive projects.',
},
{ {
displayName: 'Client Id', displayName: 'Client Id',
name: 'client_id', name: 'client_id',
@ -118,11 +111,11 @@ export const projectFields = [
description: 'Only return projects belonging to the client with the given ID.', description: 'Only return projects belonging to the client with the given ID.',
}, },
{ {
displayName: 'Updated Since', displayName: 'Is Active',
name: 'updated_since', name: 'is_active',
type: 'dateTime', type: 'boolean',
default: '', default: true,
description: 'Only return projects by updated_since.', description: 'Pass true to only return active projects and false to return inactive projects.',
}, },
{ {
displayName: 'Page', displayName: 'Page',
@ -134,7 +127,13 @@ export const projectFields = [
default: 1, default: 1,
description: 'The page number to use in pagination.', description: 'The page number to use in pagination.',
}, },
{
displayName: 'Updated Since',
name: 'updated_since',
type: 'dateTime',
default: '',
description: 'Only return projects by updated_since.',
},
] ]
}, },
@ -199,7 +198,7 @@ export const projectFields = [
}, },
{ {
displayName: 'Client Id', displayName: 'Client Id',
name: 'client_id', name: 'clientId',
type: 'string', type: 'string',
displayOptions: { displayOptions: {
show: { show: {
@ -215,8 +214,8 @@ export const projectFields = [
}, },
{ {
displayName: 'Is Billable', displayName: 'Is Billable',
name: 'is_billable', name: 'isBillable',
type: 'string', type: 'boolean',
displayOptions: { displayOptions: {
show: { show: {
operation: [ operation: [
@ -225,14 +224,14 @@ export const projectFields = [
resource, resource,
}, },
}, },
default: '', default: true,
required: true, required: true,
description: 'Whether the project is billable or not.', description: 'Whether the project is billable or not.',
}, },
{ {
displayName: 'Bill By', displayName: 'Bill By',
name: 'bill_by', name: 'billBy',
type: 'string', type: 'options',
displayOptions: { displayOptions: {
show: { show: {
operation: [ operation: [
@ -241,13 +240,31 @@ export const projectFields = [
resource, resource,
}, },
}, },
default: '', options: [
{
name: 'none',
value: 'none',
},
{
name: 'People',
value: 'People',
},
{
name: 'Project',
value: 'Project',
},
{
name: 'Tasks',
value: 'Tasks',
},
],
default: 'none',
required: true, required: true,
description: 'The method by which the project is invoiced. Options: Project, Tasks, People, or none.', description: 'The method by which the project is invoiced.',
}, },
{ {
displayName: 'Budget By', displayName: 'Budget By',
name: 'budget_by', name: 'budgetBy',
type: 'string', type: 'string',
displayOptions: { displayOptions: {
show: { show: {
@ -257,9 +274,10 @@ export const projectFields = [
resource, resource,
}, },
}, },
default: '', default: 'none',
placeholder: '',
required: true, required: true,
description: 'The email of the user.', description: 'The email of the user or "none".',
}, },
{ {
displayName: 'Additional Fields', displayName: 'Additional Fields',
@ -277,18 +295,49 @@ export const projectFields = [
default: {}, default: {},
options: [ options: [
{ {
displayName: 'Is Active', displayName: 'Budget',
name: 'is_active', name: 'budget',
type: 'boolean', type: 'number',
default: true, typeOptions: {
description: 'Whether the project is active or archived. Defaults to true' minValue: 0,
},
default: 0,
description: 'The budget in hours for the project when budgeting by time.'
}, },
{ {
displayName: 'Is Fixed Fee', displayName: 'Budget Is Monthly',
name: 'is_fixed_fee', name: 'budget_is_monthly',
type: 'boolean',
default: false,
description: 'Option to have the budget reset every month. Defaults to false.'
},
{
displayName: 'Cost Budget',
name: 'cost_budget',
type: 'string', type: 'string',
default: '', default: '',
description: 'Whether the project is a fixed-fee project or not.' description: 'The monetary budget for the project when budgeting by money.'
},
{
displayName: 'Cost Budget Include Expenses',
name: 'cost_budget_include_expenses',
type: 'boolean',
default: false,
description: 'Option for budget of Total Project Fees projects to include tracked expenses. Defaults to false.'
},
{
displayName: 'Ends On',
name: 'ends_on',
type: 'dateTime',
default: '',
description: 'Date the project will end.'
},
{
displayName: 'Fee',
name: 'fee',
type: 'string',
default: '',
description: 'The amount you plan to invoice for the project. Only used by fixed-fee projects.'
}, },
{ {
displayName: 'Hourly Rate', displayName: 'Hourly Rate',
@ -298,24 +347,31 @@ export const projectFields = [
description: 'Rate for projects billed by Project Hourly Rate.' description: 'Rate for projects billed by Project Hourly Rate.'
}, },
{ {
displayName: 'Budget', displayName: 'Is Active',
name: 'budget', name: 'is_active',
type: 'string', type: 'boolean',
default: '', default: true,
description: 'The budget in hours for the project when budgeting by time.' description: 'Whether the project is active or archived. Defaults to true'
}, },
{ {
displayName: 'Budget Is Monthly', displayName: 'Is Fixed Fee',
name: 'budget_is_monthly', name: 'is_fixed_fee',
type: 'boolean',
default: false,
description: 'Whether the project is a fixed-fee project or not.'
},
{
displayName: 'Notes',
name: 'notes',
type: 'string', type: 'string',
default: '', default: '',
description: 'Option to have the budget reset every month. Defaults to false.' description: 'Notes about the project.'
}, },
{ {
displayName: 'Notify When Over Budget', displayName: 'Notify When Over Budget',
name: 'notify_when_over_budget', name: 'notify_when_over_budget',
type: 'string', type: 'boolean',
default: '', default: false,
description: 'Whether project managers should be notified when the project goes over budget. Defaults to false.' description: 'Whether project managers should be notified when the project goes over budget. Defaults to false.'
}, },
{ {
@ -328,38 +384,10 @@ export const projectFields = [
{ {
displayName: 'Show Budget To All', displayName: 'Show Budget To All',
name: 'show_budget_to_all', name: 'show_budget_to_all',
type: 'string', type: 'boolean',
default: '', default: false,
description: 'Option to show project budget to all employees. Does not apply to Total Project Fee projects. Defaults to false.' description: 'Option to show project budget to all employees. Does not apply to Total Project Fee projects. Defaults to false.'
}, },
{
displayName: 'Cost Budget',
name: 'cost_budget',
type: 'string',
default: '',
description: 'The monetary budget for the project when budgeting by money.'
},
{
displayName: 'Cost Budget Include Expenses',
name: 'cost_budget_include_expenses',
type: 'string',
default: '',
description: 'Option for budget of Total Project Fees projects to include tracked expenses. Defaults to false.'
},
{
displayName: 'Fee',
name: 'fee',
type: 'string',
default: '',
description: 'The amount you plan to invoice for the project. Only used by fixed-fee projects.'
},
{
displayName: 'Notes',
name: 'notes',
type: 'string',
default: '',
description: 'Notes about the project.'
},
{ {
displayName: 'Starts On', displayName: 'Starts On',
name: 'starts_on', name: 'starts_on',
@ -367,14 +395,6 @@ export const projectFields = [
default: '', default: '',
description: 'Date the project was started.' description: 'Date the project was started.'
}, },
{
displayName: 'Ends On',
name: 'ends_on',
type: 'dateTime',
default: '',
description: 'Date the project will end.'
},
], ],
}, },
@ -412,61 +432,30 @@ export const projectFields = [
}, },
default: {}, default: {},
options: [ options: [
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
description: 'The name of the project.',
},
{
displayName: 'Client Id',
name: 'client_id',
type: 'string',
default: '',
description: 'The ID of the client to associate this project with.',
},
{
displayName: 'Is Billable',
name: 'is_billable',
type: 'string',
default: '',
description: 'Whether the project is billable or not.',
},
{ {
displayName: 'Bill By', displayName: 'Bill By',
name: 'bill_by', name: 'bill_by',
type: 'string', type: 'options',
default: '', options: [
description: 'The method by which the project is invoiced. Options: Project, Tasks, People, or none.', {
name: 'none',
value: 'none',
}, },
{ {
displayName: 'Budget By', name: 'People',
name: 'budget_by', value: 'People',
type: 'string',
default: '',
description: 'The email of the user.',
}, },
{ {
displayName: 'Is Active', name: 'Project',
name: 'is_active', value: 'Project',
type: 'boolean',
default: true,
description: 'Whether the project is active or archived. Defaults to true'
}, },
{ {
displayName: 'Is Fixed Fee', name: 'Tasks',
name: 'is_fixed_fee', value: 'Tasks',
type: 'string',
default: '',
description: 'Whether the project is a fixed-fee project or not.'
}, },
{ ],
displayName: 'Hourly Rate', default: 'none',
name: 'hourly_rate', description: 'The method by which the project is invoiced.',
type: 'string',
default: '',
description: 'Rate for projects billed by Project Hourly Rate.'
}, },
{ {
displayName: 'Budget', displayName: 'Budget',
@ -476,17 +465,101 @@ export const projectFields = [
description: 'The budget in hours for the project when budgeting by time.' description: 'The budget in hours for the project when budgeting by time.'
}, },
{ {
displayName: 'Budget Is Monthly', displayName: 'Budget By',
name: 'budget_is_monthly', name: 'budget_by',
type: 'string', type: 'string',
default: '', default: '',
description: 'The email of the user or "none".',
},
{
displayName: 'Budget Is Monthly',
name: 'budget_is_monthly',
type: 'boolean',
default: false,
description: 'Option to have the budget reset every month. Defaults to false.' description: 'Option to have the budget reset every month. Defaults to false.'
}, },
{
displayName: 'Client Id',
name: 'client_id',
type: 'string',
default: '',
description: 'The ID of the client to associate this project with.',
},
{
displayName: 'Cost Budget',
name: 'cost_budget',
type: 'string',
default: '',
description: 'The monetary budget for the project when budgeting by money.'
},
{
displayName: 'Cost Budget Include Expenses',
name: 'cost_budget_include_expenses',
type: 'boolean',
default: false,
description: 'Option for budget of Total Project Fees projects to include tracked expenses. Defaults to false.'
},
{
displayName: 'Ends On',
name: 'ends_on',
type: 'dateTime',
default: '',
description: 'Date the project will end.'
},
{
displayName: 'Fee',
name: 'fee',
type: 'string',
default: '',
description: 'The amount you plan to invoice for the project. Only used by fixed-fee projects.'
},
{
displayName: 'Hourly Rate',
name: 'hourly_rate',
type: 'string',
default: '',
description: 'Rate for projects billed by Project Hourly Rate.'
},
{
displayName: 'Is Active',
name: 'is_active',
type: 'boolean',
default: true,
description: 'Whether the project is active or archived. Defaults to true'
},
{
displayName: 'Is Billable',
name: 'is_billable',
type: 'boolean',
default: true,
description: 'Whether the project is billable or not.',
},
{
displayName: 'Is Fixed Fee',
name: 'is_fixed_fee',
type: 'boolean',
default: false,
description: 'Whether the project is a fixed-fee project or not.'
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
description: 'The name of the project.',
},
{
displayName: 'Notes',
name: 'notes',
type: 'string',
default: '',
description: 'Notes about the project.'
},
{ {
displayName: 'Notify When Over Budget', displayName: 'Notify When Over Budget',
name: 'notify_when_over_budget', name: 'notify_when_over_budget',
type: 'string', type: 'boolean',
default: '', default: false,
description: 'Whether project managers should be notified when the project goes over budget. Defaults to false.' description: 'Whether project managers should be notified when the project goes over budget. Defaults to false.'
}, },
{ {
@ -499,38 +572,11 @@ export const projectFields = [
{ {
displayName: 'Show Budget To All', displayName: 'Show Budget To All',
name: 'show_budget_to_all', name: 'show_budget_to_all',
type: 'string', type: 'boolean',
default: '', default: false,
description: 'Option to show project budget to all employees. Does not apply to Total Project Fee projects. Defaults to false.' description: 'Option to show project budget to all employees. Does not apply to Total Project Fee projects. Defaults to false.'
}, },
{
displayName: 'Cost Budget',
name: 'cost_budget',
type: 'string',
default: '',
description: 'The monetary budget for the project when budgeting by money.'
},
{
displayName: 'Cost Budget Include Expenses',
name: 'cost_budget_include_expenses',
type: 'string',
default: '',
description: 'Option for budget of Total Project Fees projects to include tracked expenses. Defaults to false.'
},
{
displayName: 'Fee',
name: 'fee',
type: 'string',
default: '',
description: 'The amount you plan to invoice for the project. Only used by fixed-fee projects.'
},
{
displayName: 'Notes',
name: 'notes',
type: 'string',
default: '',
description: 'Notes about the project.'
},
{ {
displayName: 'Starts On', displayName: 'Starts On',
name: 'starts_on', name: 'starts_on',
@ -538,16 +584,7 @@ export const projectFields = [
default: '', default: '',
description: 'Date the project was started.' description: 'Date the project was started.'
}, },
{
displayName: 'Ends On',
name: 'ends_on',
type: 'dateTime',
default: '',
description: 'Date the project will end.'
},
], ],
}, },
] as INodeProperties[]; ] as INodeProperties[];

View file

@ -1,5 +1,5 @@
import { INodeProperties } from "n8n-workflow"; import { INodeProperties } from 'n8n-workflow';
const resource = ['tasks']; const resource = ['task'];
export const taskOperations = [ export const taskOperations = [
{ {
displayName: 'Operation', displayName: 'Operation',
@ -11,6 +11,16 @@ export const taskOperations = [
}, },
}, },
options: [ options: [
{
name: 'Create',
value: 'create',
description: `Create a task`,
},
{
name: 'Delete',
value: 'delete',
description: `Delete a task`,
},
{ {
name: 'Get', name: 'Get',
value: 'get', value: 'get',
@ -21,21 +31,11 @@ export const taskOperations = [
value: 'getAll', value: 'getAll',
description: 'Get data of all tasks', description: 'Get data of all tasks',
}, },
{
name: 'Create',
value: 'create',
description: `Create a task`,
},
{ {
name: 'Update', name: 'Update',
value: 'update', value: 'update',
description: `Update a task`, description: `Update a task`,
}, },
{
name: 'Delete',
value: 'delete',
description: `Delete a task`,
},
], ],
default: 'getAll', default: 'getAll',
description: 'The operation to perform.', description: 'The operation to perform.',
@ -108,13 +108,6 @@ export const taskFields = [
default: true, default: true,
description: 'Pass true to only return active tasks and false to return inactive tasks.', description: 'Pass true to only return active tasks and false to return inactive tasks.',
}, },
{
displayName: 'Updated Since',
name: 'updated_since',
type: 'dateTime',
default: '',
description: 'Only return tasks belonging to the task with the given ID.',
},
{ {
displayName: 'Page', displayName: 'Page',
name: 'page', name: 'page',
@ -124,7 +117,14 @@ export const taskFields = [
}, },
default: 1, default: 1,
description: 'The page number to use in pagination.', description: 'The page number to use in pagination.',
} },
{
displayName: 'Updated Since',
name: 'updated_since',
type: 'dateTime',
default: '',
description: 'Only return tasks belonging to the task with the given ID.',
},
] ]
}, },
@ -250,13 +250,7 @@ export const taskFields = [
}, },
default: {}, default: {},
options: [ options: [
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
description: 'Name of the task.'
},
{ {
displayName: 'Billable By Default', displayName: 'Billable By Default',
name: 'billable_by_default', name: 'billable_by_default',
@ -271,6 +265,13 @@ export const taskFields = [
default: '0', default: '0',
description: 'The default hourly rate to use for this task when it is added to a project. Defaults to 0.' description: 'The default hourly rate to use for this task when it is added to a project. Defaults to 0.'
}, },
{
displayName: 'Is Active',
name: 'is_active',
type: 'boolean',
default: true,
description: 'Whether this task is active or archived. Defaults to true'
},
{ {
displayName: 'Is Default', displayName: 'Is Default',
name: 'is_default', name: 'is_default',
@ -279,12 +280,12 @@ export const taskFields = [
description: 'Whether this task should be automatically added to future projects. Defaults to false.' description: 'Whether this task should be automatically added to future projects. Defaults to false.'
}, },
{ {
displayName: 'Is Active', displayName: 'Name',
name: 'is_active', name: 'name',
type: 'boolean', type: 'string',
default: true, default: '',
description: 'Whether this task is active or archived. Defaults to true' description: 'Name of the task.'
} },
], ],
}, },

View file

@ -1,5 +1,5 @@
import { INodeProperties } from "n8n-workflow"; import { INodeProperties } from 'n8n-workflow';
export const resource = [ 'time_entries' ] export const resource = [ 'timeEntry' ];
export const timeEntryOperations = [ export const timeEntryOperations = [
{ {
displayName: 'Operation', displayName: 'Operation',
@ -119,13 +119,6 @@ export const timeEntryFields = [
}, },
}, },
options: [ options: [
{
displayName: 'User ID',
name: 'user_id',
type: 'string',
default: '',
description: 'Only return time entries belonging to the user with the given ID.',
},
{ {
displayName: 'Client ID', displayName: 'Client ID',
name: 'client_id', name: 'client_id',
@ -133,6 +126,13 @@ export const timeEntryFields = [
default: '', default: '',
description: 'Only return time entries belonging to the client with the given ID.', description: 'Only return time entries belonging to the client with the given ID.',
}, },
{
displayName: 'From',
name: 'from',
type: 'dateTime',
default: '',
description: 'Only return time entries with a spent_date on or after the given date.',
},
{ {
displayName: 'Is Billed', displayName: 'Is Billed',
name: 'is_billed', name: 'is_billed',
@ -147,20 +147,6 @@ export const timeEntryFields = [
default: true, default: true,
description: 'Pass true to only return running time entries and false to return non-running time entries.', description: 'Pass true to only return running time entries and false to return non-running time entries.',
}, },
{
displayName: 'Updated Since',
name: 'updated_since',
type: 'dateTime',
default: '',
description: 'Only return time entries that have been updated since the given date and time.',
},
{
displayName: 'From',
name: 'from',
type: 'dateTime',
default: '',
description: 'Only return time entries with a spent_date on or after the given date.',
},
{ {
displayName: 'To', displayName: 'To',
name: 'to', name: 'to',
@ -168,6 +154,13 @@ export const timeEntryFields = [
default: '', default: '',
description: 'Only return time entries with a spent_date on or before the given date.', description: 'Only return time entries with a spent_date on or before the given date.',
}, },
{
displayName: 'Updated Since',
name: 'updated_since',
type: 'dateTime',
default: '',
description: 'Only return time entries that have been updated since the given date and time.',
},
{ {
displayName: 'Page', displayName: 'Page',
name: 'page', name: 'page',
@ -177,8 +170,15 @@ export const timeEntryFields = [
}, },
default: 1, default: 1,
description: 'The page number to use in pagination. For instance, if you make a list request and receive 100 records, your subsequent call can include page=2 to retrieve the next page of the list. (Default: 1)', description: 'The page number to use in pagination. For instance, if you make a list request and receive 100 records, your subsequent call can include page=2 to retrieve the next page of the list. (Default: 1)',
} },
] {
displayName: 'User ID',
name: 'user_id',
type: 'string',
default: '',
description: 'Only return time entries belonging to the user with the given ID.',
},
],
}, },
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */

View file

@ -1,6 +1,6 @@
import { INodeProperties } from "n8n-workflow"; import { INodeProperties } from 'n8n-workflow';
const resource = ['users']; const resource = ['user'];
export const userOperations = [ export const userOperations = [
{ {
@ -14,9 +14,14 @@ export const userOperations = [
}, },
options: [ options: [
{ {
name: 'Me', name: 'Create',
value: 'me', value: 'create',
description: 'Get data of authenticated user', description: `Create a user`,
},
{
name: 'Delete',
value: 'delete',
description: `Delete a user`,
}, },
{ {
name: 'Get', name: 'Get',
@ -28,21 +33,17 @@ export const userOperations = [
value: 'getAll', value: 'getAll',
description: 'Get data of all users', description: 'Get data of all users',
}, },
{ {
name: 'Create', name: 'Me',
value: 'create', value: 'me',
description: `Create a user`, description: 'Get data of authenticated user',
}, },
{ {
name: 'Update', name: 'Update',
value: 'update', value: 'update',
description: `Update a user`, description: `Update a user`,
}, },
{
name: 'Delete',
value: 'delete',
description: `Delete a user`,
},
], ],
default: 'me', default: 'me',
description: 'The operation to perform.', description: 'The operation to perform.',
@ -180,7 +181,7 @@ export const userFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'First Name', displayName: 'First Name',
name: 'first_name', name: 'firstName',
type: 'string', type: 'string',
displayOptions: { displayOptions: {
show: { show: {
@ -196,7 +197,7 @@ export const userFields = [
}, },
{ {
displayName: 'Last Name', displayName: 'Last Name',
name: 'last_name', name: 'lastName',
type: 'string', type: 'string',
displayOptions: { displayOptions: {
show: { show: {
@ -241,96 +242,102 @@ export const userFields = [
}, },
default: {}, default: {},
options: [ options: [
{
displayName: 'Timezone',
name: 'timezone',
type: 'string',
default: '',
description: 'The users timezone. Defaults to the companys timezone. See a list of <a href="/api-v2/introduction/overview/supported-timezones/">supported time zones</a>.</td>'
},
{
displayName: 'Has Access To All Future Projects',
name: 'has_access_to_all_future_projects',
type: 'string',
default: '',
description: 'Whether the user should be automatically added to future projects. Defaults to <code class="language-plaintext highlighter-rouge">false</code>.</td>'
},
{
displayName: 'Is Contractor',
name: 'is_contractor',
type: 'string',
default: '',
description: 'Whether the user is a contractor or an employee. Defaults to <code class="language-plaintext highlighter-rouge">false</code>.</td>'
},
{
displayName: 'Is Admin',
name: 'is_admin',
type: 'string',
default: '',
description: 'Whether the user has Admin permissions. Defaults to <code class="language-plaintext highlighter-rouge">false</code>.</td>'
},
{
displayName: 'Is Project Manager',
name: 'is_project_manager',
type: 'string',
default: '',
description: 'Whether the user has Project Manager permissions. Defaults to <code class="language-plaintext highlighter-rouge">false</code>.</td>'
},
{
displayName: 'Can See Rates',
name: 'can_see_rates',
type: 'string',
default: '',
description: 'Whether the user can see billable rates on projects. Only applicable to Project Managers. Defaults to <code class="language-plaintext highlighter-rouge">false</code>.</td>'
},
{ {
displayName: 'Can Create Projects', displayName: 'Can Create Projects',
name: 'can_create_projects', name: 'can_create_projects',
type: 'string', type: 'boolean',
default: '', default: false,
description: 'Whether the user can create projects. Only applicable to Project Managers. Defaults to <code class="language-plaintext highlighter-rouge">false</code>.</td>' description: 'Whether the user can create projects. Only applicable to Project Managers.'
}, },
{ {
displayName: 'Can Create Invoices', displayName: 'Can Create Invoices',
name: 'can_create_invoices', name: 'can_create_invoices',
type: 'string', type: 'boolean',
default: '', default: false,
description: 'Whether the user can create invoices. Only applicable to Project Managers. Defaults to <code class="language-plaintext highlighter-rouge">false</code>.</td>' description: 'Whether the user can create invoices. Only applicable to Project Managers.'
}, },
{ {
displayName: 'Is Active', displayName: 'Can See Rates',
name: 'is_active', name: 'can_see_rates',
type: 'string', type: 'boolean',
default: '', default: false,
description: 'Whether the user is active or archived. Defaults to <code class="language-plaintext highlighter-rouge">true</code>.</td>' description: 'Whether the user can see billable rates on projects. Only applicable to Project Managers.'
}, },
{ {
displayName: 'Weekly Capacity', displayName: 'Cost Rate',
name: 'weekly_capacity', name: 'cost_rate',
type: 'string', type: 'number',
default: '', typeOptions: {
description: 'The number of hours per week this person is available to work in seconds. Defaults to <code class="language-plaintext highlighter-rouge">126000</code> seconds (35 hours).</td>' minValue: 0,
},
default: 0,
description: 'The cost rate to use for this user when calculating a projects costs vs billable amount.'
}, },
{ {
displayName: 'Default Hourly Rate', displayName: 'Default Hourly Rate',
name: 'default_hourly_rate', name: 'default_hourly_rate',
type: 'string', type: 'string',
default: '', default: '0',
description: 'The billable rate to use for this user when they are added to a project. Defaults to <code class="language-plaintext highlighter-rouge">0</code>.</td>' description: 'The billable rate to use for this user when they are added to a project.'
}, },
{ {
displayName: 'Cost Rate', displayName: 'Has Access To All Future Projects',
name: 'cost_rate', name: 'has_access_to_all_future_projects',
type: 'string', type: 'boolean',
default: '', default: false,
description: 'The cost rate to use for this user when calculating a projects costs vs billable amount. Defaults to <code class="language-plaintext highlighter-rouge">0</code>.</td>' description: 'Whether the user should be automatically added to future projects.'
},
{
displayName: 'Is Active',
name: 'is_active',
type: 'boolean',
default: true,
description: 'Whether the user is active or archived.'
},
{
displayName: 'Is Admin',
name: 'is_admin',
type: 'boolean',
default: false,
description: 'Whether the user has Admin permissions.'
},
{
displayName: 'Is Contractor',
name: 'is_contractor',
type: 'boolean',
default: false,
description: 'Whether the user is a contractor or an employee.'
},
{
displayName: 'Is Project Manager',
name: 'is_project_manager',
type: 'boolean',
default: false,
description: 'Whether the user has Project Manager permissions.'
}, },
{ {
displayName: 'Roles', displayName: 'Roles',
name: 'roles', name: 'roles',
type: 'string', type: 'string',
default: '', default: '',
description: 'The role names assigned to this person.</td>' description: 'The role names assigned to this person.'
},
{
displayName: 'Timezone',
name: 'timezone',
type: 'string',
default: '',
description: 'The users timezone. Defaults to the companys timezone. See a list of <a href="/api-v2/introduction/overview/supported-timezones/">supported time zones</a>.'
},
{
displayName: 'Weekly Capacity',
name: 'weekly_capacity',
type: 'number',
typeOptions: {
minValue: 0,
},
default: 126000,
description: 'The number of hours per week this person is available to work in seconds. Defaults to <code class="language-plaintext highlighter-rouge">126000</code> seconds (35 hours).'
}, },
], ],
}, },
@ -371,18 +378,42 @@ export const userFields = [
default: {}, default: {},
options: [ options: [
{ {
displayName: 'First Name', displayName: 'Can Create Projects',
name: 'first_name', name: 'can_create_projects',
type: 'string', type: 'boolean',
default: '', default: false,
description: 'The user first name' description: 'Whether the user can create projects. Only applicable to Project Managers.'
}, },
{ {
displayName: 'Last Name', displayName: 'Can Create Invoices',
name: 'last_name', name: 'can_create_invoices',
type: 'boolean',
default: false,
description: 'Whether the user can create invoices. Only applicable to Project Managers.'
},
{
displayName: 'Can See Rates',
name: 'can_see_rates',
type: 'boolean',
default: false,
description: 'Whether the user can see billable rates on projects. Only applicable to Project Managers.'
},
{
displayName: 'Cost Rate',
name: 'cost_rate',
type: 'number',
typeOptions: {
minValue: 0,
},
default: 0,
description: 'The cost rate to use for this user when calculating a projects costs vs billable amount.'
},
{
displayName: 'Default Hourly Rate',
name: 'default_hourly_rate',
type: 'string', type: 'string',
default: '', default: '0',
description: 'The user last name' description: 'The billable rate to use for this user when they are added to a project.'
}, },
{ {
displayName: 'Email', displayName: 'Email',
@ -392,95 +423,77 @@ export const userFields = [
description: 'The user email' description: 'The user email'
}, },
{ {
displayName: 'Timezone', displayName: 'First Name',
name: 'timezone', name: 'first_name',
type: 'string', type: 'string',
default: '', default: '',
description: 'The users timezone. Defaults to the companys timezone. See a list of <a href="/api-v2/introduction/overview/supported-timezones/">supported time zones</a>.</td>' description: 'The user first name'
}, },
{ {
displayName: 'Has Access To All Future Projects', displayName: 'Has Access To All Future Projects',
name: 'has_access_to_all_future_projects', name: 'has_access_to_all_future_projects',
type: 'string', type: 'boolean',
default: '', default: false,
description: 'Whether the user should be automatically added to future projects. Defaults to <code class="language-plaintext highlighter-rouge">false</code>.</td>' description: 'Whether the user should be automatically added to future projects.'
},
{
displayName: 'Is Contractor',
name: 'is_contractor',
type: 'string',
default: '',
description: 'Whether the user is a contractor or an employee. Defaults to <code class="language-plaintext highlighter-rouge">false</code>.</td>'
},
{
displayName: 'Is Admin',
name: 'is_admin',
type: 'string',
default: '',
description: 'Whether the user has Admin permissions. Defaults to <code class="language-plaintext highlighter-rouge">false</code>.</td>'
},
{
displayName: 'Is Project Manager',
name: 'is_project_manager',
type: 'string',
default: '',
description: 'Whether the user has Project Manager permissions. Defaults to <code class="language-plaintext highlighter-rouge">false</code>.</td>'
},
{
displayName: 'Can See Rates',
name: 'can_see_rates',
type: 'string',
default: '',
description: 'Whether the user can see billable rates on projects. Only applicable to Project Managers. Defaults to <code class="language-plaintext highlighter-rouge">false</code>.</td>'
},
{
displayName: 'Can Create Projects',
name: 'can_create_projects',
type: 'string',
default: '',
description: 'Whether the user can create projects. Only applicable to Project Managers. Defaults to <code class="language-plaintext highlighter-rouge">false</code>.</td>'
},
{
displayName: 'Can Create Invoices',
name: 'can_create_invoices',
type: 'string',
default: '',
description: 'Whether the user can create invoices. Only applicable to Project Managers. Defaults to <code class="language-plaintext highlighter-rouge">false</code>.</td>'
}, },
{ {
displayName: 'Is Active', displayName: 'Is Active',
name: 'is_active', name: 'is_active',
type: 'string', type: 'boolean',
default: '', default: true,
description: 'Whether the user is active or archived. Defaults to <code class="language-plaintext highlighter-rouge">true</code>.</td>' description: 'Whether the user is active or archived.'
}, },
{ {
displayName: 'Weekly Capacity', displayName: 'Is Admin',
name: 'weekly_capacity', name: 'is_admin',
type: 'string', type: 'boolean',
default: '', default: false,
description: 'The number of hours per week this person is available to work in seconds. Defaults to <code class="language-plaintext highlighter-rouge">126000</code> seconds (35 hours).</td>' description: 'Whether the user has Admin permissions.'
}, },
{ {
displayName: 'Default Hourly Rate', displayName: 'Is Contractor',
name: 'default_hourly_rate', name: 'is_contractor',
type: 'string', type: 'boolean',
default: '', default: false,
description: 'The billable rate to use for this user when they are added to a project. Defaults to <code class="language-plaintext highlighter-rouge">0</code>.</td>' description: 'Whether the user is a contractor or an employee.'
}, },
{ {
displayName: 'Cost Rate', displayName: 'Is Project Manager',
name: 'cost_rate', name: 'is_project_manager',
type: 'boolean',
default: false,
description: 'Whether the user has Project Manager permissions.'
},
{
displayName: 'Last Name',
name: 'last_name',
type: 'string', type: 'string',
default: '', default: '',
description: 'The cost rate to use for this user when calculating a projects costs vs billable amount. Defaults to <code class="language-plaintext highlighter-rouge">0</code>.</td>' description: 'The user last name'
}, },
{ {
displayName: 'Roles', displayName: 'Roles',
name: 'roles', name: 'roles',
type: 'string', type: 'string',
default: '', default: '',
description: 'The role names assigned to this person.</td>' description: 'The role names assigned to this person.'
},
{
displayName: 'Timezone',
name: 'timezone',
type: 'string',
default: '',
description: 'The users timezone. Defaults to the companys timezone. See a list of <a href="/api-v2/introduction/overview/supported-timezones/">supported time zones</a>.'
},
{
displayName: 'Weekly Capacity',
name: 'weekly_capacity',
type: 'number',
typeOptions: {
minValue: 0,
},
default: 126000,
description: 'The number of hours per week this person is available to work in seconds. Defaults to <code class="language-plaintext highlighter-rouge">126000</code> seconds (35 hours).'
}, },
], ],
}, },