mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
Add other APIs
This commit is contained in:
parent
8027601283
commit
7b50a4bcfd
|
@ -1,9 +1,136 @@
|
|||
import { INodeProperties } from "n8n-workflow";
|
||||
|
||||
export const clientOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'client',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get data of a client',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get data of all clients',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
|
||||
] as INodeProperties[];
|
||||
|
||||
export const clientFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* client:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'client',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Returns a list of your clients.',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'client',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 100,
|
||||
description: 'How many results to return.',
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Filter',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'client',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Is Active',
|
||||
name: 'is_active',
|
||||
type: 'boolean',
|
||||
default: '',
|
||||
description: 'Pass true to only return active clients and false to return inactive clients.',
|
||||
},
|
||||
{
|
||||
displayName: 'Updated Since',
|
||||
name: 'updated_since',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Only return clients that have been updated since the given date and time.',
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* client:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Client Id',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: [
|
||||
'client',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the client you are retrieving.',
|
||||
}
|
||||
|
||||
] as INodeProperties[];
|
||||
|
|
26
packages/nodes-base/nodes/Harvest/CompanyDescription.ts
Normal file
26
packages/nodes-base/nodes/Harvest/CompanyDescription.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import { INodeProperties } from "n8n-workflow";
|
||||
|
||||
export const clientOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'company',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Retrieves the company for the currently authenticated user',
|
||||
},
|
||||
],
|
||||
default: 'get',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
|
||||
] as INodeProperties[];
|
136
packages/nodes-base/nodes/Harvest/ContactDescription.ts
Normal file
136
packages/nodes-base/nodes/Harvest/ContactDescription.ts
Normal file
|
@ -0,0 +1,136 @@
|
|||
import { INodeProperties } from "n8n-workflow";
|
||||
|
||||
export const contactOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'contact',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get data of a contact',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get data of all contacts',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
|
||||
] as INodeProperties[];
|
||||
|
||||
export const contactFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'contact',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Returns a list of your user contacts.',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'contact',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 100,
|
||||
description: 'How many results to return.',
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Filter',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'contact',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Is Active',
|
||||
name: 'is_active',
|
||||
type: 'boolean',
|
||||
default: '',
|
||||
description: 'Pass true to only return active clients and false to return inactive clients.',
|
||||
},
|
||||
{
|
||||
displayName: 'Updated Since',
|
||||
name: 'updated_since',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Only return clients that have been updated since the given date and time.',
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Client Id',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: [
|
||||
'contact',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the contact you are retrieving.',
|
||||
}
|
||||
|
||||
] as INodeProperties[];
|
178
packages/nodes-base/nodes/Harvest/ExpenseDescription.ts
Normal file
178
packages/nodes-base/nodes/Harvest/ExpenseDescription.ts
Normal file
|
@ -0,0 +1,178 @@
|
|||
import { INodeProperties } from "n8n-workflow";
|
||||
|
||||
export const expenseOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'expense',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get data of a expense',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get data of all expenses',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
|
||||
] as INodeProperties[];
|
||||
|
||||
export const expenseFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* expense:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'expense',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Returns a list of your expenses.',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'expense',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 100,
|
||||
description: 'How many results to return.',
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Filter',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'expense',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
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',
|
||||
name: 'client_id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
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: 'string',
|
||||
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',
|
||||
name: 'to',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Only return time entries with a spent_date on or before the given date.',
|
||||
},
|
||||
{
|
||||
displayName: 'Page',
|
||||
name: 'page',
|
||||
type: 'string',
|
||||
default: '',
|
||||
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)',
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* expense:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Client Id',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: [
|
||||
'expense',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the expense you are retrieving.',
|
||||
}
|
||||
|
||||
] as INodeProperties[];
|
|
@ -43,6 +43,26 @@ export class Harvest implements INodeType {
|
|||
name: 'Time Entries',
|
||||
value: 'timeEntry',
|
||||
},
|
||||
{
|
||||
name: "Client",
|
||||
value: "client"
|
||||
},
|
||||
{ name: "Project",
|
||||
value: "project"},
|
||||
{ name: "Contact",
|
||||
value: "contact"},
|
||||
{ name: "Company",
|
||||
value: "company"},
|
||||
{ name: "Invoice",
|
||||
value: "invoice"},
|
||||
{ name: "Task",
|
||||
value: "task"},
|
||||
{ name: "User",
|
||||
value: "user"},
|
||||
{ name: "Expense",
|
||||
value: "expense"},
|
||||
{ name: "Estimates",
|
||||
value: "estimate"}
|
||||
],
|
||||
default: 'timeEntry',
|
||||
description: 'The resource to operate on.',
|
||||
|
@ -50,6 +70,7 @@ export class Harvest implements INodeType {
|
|||
|
||||
// operations
|
||||
...timeEntryOperations,
|
||||
...compa
|
||||
|
||||
// fields
|
||||
...timeEntryFields
|
||||
|
@ -237,6 +258,337 @@ export class Harvest implements INodeType {
|
|||
throw new Error(`The operation "${operation}" is not known!`);
|
||||
}
|
||||
|
||||
} else if (resource === 'client') {
|
||||
if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// get
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'GET';
|
||||
const id = this.getNodeParameter('id', i) as string;
|
||||
|
||||
endpoint = `clients/${id}`;
|
||||
|
||||
try {
|
||||
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
returnData.push(responseData);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// getAll
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'GET';
|
||||
|
||||
endpoint = 'clients';
|
||||
|
||||
const additionalFields = this.getNodeParameter('filters', i) as IDataObject;
|
||||
const limit = this.getNodeParameter('limit', i) as string;
|
||||
qs.per_page = limit;
|
||||
Object.assign(qs, additionalFields);
|
||||
|
||||
try {
|
||||
let responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
returnData.push.apply(returnData, responseData.time_entries as IDataObject[]);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Error(`The resource "${resource}" is not known!`);
|
||||
}
|
||||
} else if (resource === 'project') {
|
||||
if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// get
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'GET';
|
||||
const id = this.getNodeParameter('id', i) as string;
|
||||
|
||||
endpoint = `projects/${id}`;
|
||||
|
||||
try {
|
||||
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
returnData.push(responseData);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// getAll
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'GET';
|
||||
|
||||
endpoint = 'projects';
|
||||
|
||||
const additionalFields = this.getNodeParameter('filters', i) as IDataObject;
|
||||
const limit = this.getNodeParameter('limit', i) as string;
|
||||
qs.per_page = limit;
|
||||
Object.assign(qs, additionalFields);
|
||||
|
||||
try {
|
||||
let responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
returnData.push.apply(returnData, responseData.time_entries as IDataObject[]);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Error(`The resource "${resource}" is not known!`);
|
||||
}
|
||||
} else if (resource === 'user') {
|
||||
if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// get
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'GET';
|
||||
const id = this.getNodeParameter('id', i) as string;
|
||||
|
||||
endpoint = `users/${id}`;
|
||||
|
||||
try {
|
||||
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
returnData.push(responseData);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// getAll
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'GET';
|
||||
|
||||
endpoint = 'users';
|
||||
|
||||
const additionalFields = this.getNodeParameter('filters', i) as IDataObject;
|
||||
const limit = this.getNodeParameter('limit', i) as string;
|
||||
qs.per_page = limit;
|
||||
Object.assign(qs, additionalFields);
|
||||
|
||||
try {
|
||||
let responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
returnData.push.apply(returnData, responseData.time_entries as IDataObject[]);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
} else if (operation === 'me') {
|
||||
// ----------------------------------
|
||||
// getAll
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'GET';
|
||||
|
||||
endpoint = 'users/me';
|
||||
|
||||
try {
|
||||
let responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
returnData.push.apply(responseData);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Error(`The resource "${resource}" is not known!`);
|
||||
}
|
||||
} else if (resource === 'contact') {
|
||||
if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// get
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'GET';
|
||||
const id = this.getNodeParameter('id', i) as string;
|
||||
|
||||
endpoint = `contacts/${id}`;
|
||||
|
||||
try {
|
||||
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
returnData.push(responseData);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// getAll
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'GET';
|
||||
|
||||
endpoint = 'contacts';
|
||||
|
||||
const additionalFields = this.getNodeParameter('filters', i) as IDataObject;
|
||||
const limit = this.getNodeParameter('limit', i) as string;
|
||||
qs.per_page = limit;
|
||||
Object.assign(qs, additionalFields);
|
||||
|
||||
try {
|
||||
let responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
returnData.push.apply(returnData, responseData.time_entries as IDataObject[]);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Error(`The resource "${resource}" is not known!`);
|
||||
}
|
||||
} else if (resource === 'company') {
|
||||
if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// get
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'GET';
|
||||
const id = this.getNodeParameter('id', i) as string;
|
||||
|
||||
endpoint = `company`;
|
||||
|
||||
try {
|
||||
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
returnData.push(responseData);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Error(`The resource "${resource}" is not known!`);
|
||||
}
|
||||
} else if (resource === 'task') {
|
||||
if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// get
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'GET';
|
||||
const id = this.getNodeParameter('id', i) as string;
|
||||
|
||||
endpoint = `tasks/${id}`;
|
||||
|
||||
try {
|
||||
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
returnData.push(responseData);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// getAll
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'GET';
|
||||
|
||||
endpoint = 'tasks';
|
||||
|
||||
const additionalFields = this.getNodeParameter('filters', i) as IDataObject;
|
||||
const limit = this.getNodeParameter('limit', i) as string;
|
||||
qs.per_page = limit;
|
||||
Object.assign(qs, additionalFields);
|
||||
|
||||
try {
|
||||
let responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
returnData.push.apply(returnData, responseData.time_entries as IDataObject[]);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Error(`The resource "${resource}" is not known!`);
|
||||
}
|
||||
} else if (resource === 'invoice') {
|
||||
if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// get
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'GET';
|
||||
const id = this.getNodeParameter('id', i) as string;
|
||||
|
||||
endpoint = `invoices/${id}`;
|
||||
|
||||
try {
|
||||
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
returnData.push(responseData);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// getAll
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'GET';
|
||||
|
||||
endpoint = 'invoices';
|
||||
|
||||
const additionalFields = this.getNodeParameter('filters', i) as IDataObject;
|
||||
const limit = this.getNodeParameter('limit', i) as string;
|
||||
qs.per_page = limit;
|
||||
Object.assign(qs, additionalFields);
|
||||
|
||||
try {
|
||||
let responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
returnData.push.apply(returnData, responseData.time_entries as IDataObject[]);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Error(`The resource "${resource}" is not known!`);
|
||||
}
|
||||
} else if (resource === 'expense') {
|
||||
if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// get
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'GET';
|
||||
const id = this.getNodeParameter('id', i) as string;
|
||||
|
||||
endpoint = `expenses/${id}`;
|
||||
|
||||
try {
|
||||
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
returnData.push(responseData);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// getAll
|
||||
// ----------------------------------
|
||||
|
||||
requestMethod = 'GET';
|
||||
|
||||
endpoint = 'expenses';
|
||||
|
||||
const additionalFields = this.getNodeParameter('filters', i) as IDataObject;
|
||||
const limit = this.getNodeParameter('limit', i) as string;
|
||||
qs.per_page = limit;
|
||||
Object.assign(qs, additionalFields);
|
||||
|
||||
try {
|
||||
let responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
returnData.push.apply(returnData, responseData.time_entries as IDataObject[]);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Error(`The resource "${resource}" is not known!`);
|
||||
}
|
||||
} else {
|
||||
throw new Error(`The resource "${resource}" is not known!`);
|
||||
}
|
||||
|
|
189
packages/nodes-base/nodes/Harvest/InvoiceDescription.ts
Normal file
189
packages/nodes-base/nodes/Harvest/InvoiceDescription.ts
Normal file
|
@ -0,0 +1,189 @@
|
|||
import { INodeProperties } from "n8n-workflow";
|
||||
|
||||
export const invoiceOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'invoice',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get data of a invoice',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get data of all invoices',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
|
||||
] as INodeProperties[];
|
||||
|
||||
export const invoiceFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* invoice:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'invoice',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Returns a list of your invoices.',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'invoice',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 100,
|
||||
description: 'How many results to return.',
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Filter',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'invoice',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Client ID',
|
||||
name: 'client_id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
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: 'Updated Since',
|
||||
name: 'updated_since',
|
||||
type: 'string',
|
||||
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',
|
||||
name: 'to',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Only return time entries with a spent_date on or before the given date.',
|
||||
},
|
||||
{
|
||||
displayName: 'State',
|
||||
name: 'state',
|
||||
type: 'multiOptions',
|
||||
options: [
|
||||
{
|
||||
name: 'draft',
|
||||
value: 'draft',
|
||||
},
|
||||
{
|
||||
name: 'open',
|
||||
value: 'open',
|
||||
},
|
||||
{
|
||||
name: 'paid',
|
||||
value: 'paid',
|
||||
},
|
||||
{
|
||||
name: 'closed',
|
||||
value: 'closed',
|
||||
},
|
||||
],
|
||||
default: [],
|
||||
description: 'Only return invoices with a state matching the value provided. Options: draft, open, paid, or closed.',
|
||||
},
|
||||
{
|
||||
displayName: 'Page',
|
||||
name: 'page',
|
||||
type: 'string',
|
||||
default: '',
|
||||
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)',
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* invoice:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Client Id',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: [
|
||||
'invoice',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the invoice you are retrieving.',
|
||||
}
|
||||
|
||||
] as INodeProperties[];
|
151
packages/nodes-base/nodes/Harvest/ProjectDescription.ts
Normal file
151
packages/nodes-base/nodes/Harvest/ProjectDescription.ts
Normal file
|
@ -0,0 +1,151 @@
|
|||
import { INodeProperties } from "n8n-workflow";
|
||||
|
||||
export const projectOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'project',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get data of a project',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get data of all projects',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
|
||||
] as INodeProperties[];
|
||||
|
||||
export const projectFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* projects:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'project',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Returns a list of your projects.',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'project',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 100,
|
||||
description: 'How many results to return.',
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Filter',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'project',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Is Active',
|
||||
name: 'is_active',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Pass true to only return active projects and false to return inactive projects.',
|
||||
},
|
||||
{
|
||||
displayName: 'Client Id',
|
||||
name: 'client_id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Only return projects belonging to the client with the given ID.',
|
||||
},
|
||||
{
|
||||
displayName: 'Updated Since',
|
||||
name: 'updated_since',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Only return projects by updated_since.',
|
||||
},
|
||||
{
|
||||
displayName: 'Page',
|
||||
name: 'page',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The page number to use in pagination.',
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* project:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Client Id',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: [
|
||||
'project',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the project you are retrieving.',
|
||||
}
|
||||
|
||||
] as INodeProperties[];
|
143
packages/nodes-base/nodes/Harvest/TaskDescription.ts
Normal file
143
packages/nodes-base/nodes/Harvest/TaskDescription.ts
Normal file
|
@ -0,0 +1,143 @@
|
|||
import { INodeProperties } from "n8n-workflow";
|
||||
|
||||
export const taskOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get data of a task',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get data of all tasks',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
|
||||
] as INodeProperties[];
|
||||
|
||||
export const taskFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Returns a list of your tasks.',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 100,
|
||||
description: 'How many results to return.',
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Filter',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Is Active',
|
||||
name: 'is_active',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Pass true to only return active tasks and false to return inactive tasks.',
|
||||
},
|
||||
{
|
||||
displayName: 'Updated Since',
|
||||
name: 'updated_since',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Only return tasks belonging to the task with the given ID.',
|
||||
},
|
||||
{
|
||||
displayName: 'Page',
|
||||
name: 'page',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The page number to use in pagination.',
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Client Id',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the task you are retrieving.',
|
||||
}
|
||||
|
||||
] as INodeProperties[];
|
148
packages/nodes-base/nodes/Harvest/UserDescription.ts
Normal file
148
packages/nodes-base/nodes/Harvest/UserDescription.ts
Normal file
|
@ -0,0 +1,148 @@
|
|||
import { INodeProperties } from "n8n-workflow";
|
||||
|
||||
export const userOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Me',
|
||||
value: 'me',
|
||||
description: 'Get data of authenticated user',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get data of a user',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get data of all users',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
|
||||
] as INodeProperties[];
|
||||
|
||||
export const userFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* user:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Returns a list of your users.',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 100,
|
||||
description: 'How many results to return.',
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Filter',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Is Active',
|
||||
name: 'is_active',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Only return users belonging to the user with the given ID.',
|
||||
},
|
||||
{
|
||||
displayName: 'Updated Since',
|
||||
name: 'updated_since',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Only return users belonging to the user with the given ID.',
|
||||
},
|
||||
{
|
||||
displayName: 'Page',
|
||||
name: 'page',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The page number to use in pagination..',
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* user:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Client Id',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the user you are retrieving.',
|
||||
}
|
||||
|
||||
] as INodeProperties[];
|
Loading…
Reference in a new issue