updated api endpoint to v1.10 and fixed projects resource

This commit is contained in:
Joel Sanguenza 2022-09-13 01:17:24 +08:00
commit 03cb3bbce3
22 changed files with 8413 additions and 0 deletions

View file

@ -0,0 +1,95 @@
import {
OptionsWithUri,
} from 'request';
import {
IExecuteFunctions,
ILoadOptionsFunctions,
} from 'n8n-core';
import {
IDataObject, NodeApiError
} from 'n8n-workflow';
// Rest API for generating access token
async function plutioApiRequestToken(this: IExecuteFunctions | ILoadOptionsFunctions): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('plutioApi');
const clientId = `${credentials.clientId}`;
const clientSecret = `${credentials.clientSecret}`;
const business = `${credentials.business}`;
const endpoint = 'api.plutio.com/v1.10';
const returnData: IDataObject[] = [];
let responseData;
const options: OptionsWithUri = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'business': business,
},
method: 'POST',
body: {
'client_id': clientId,
'client_secret': clientSecret,
'grant_type': 'client_credentials',
},
uri: `https://${endpoint}/oauth/token`,
json: true,
};
try {
responseData = await this.helpers.request!(options);
if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData as IDataObject[]);
} else {
if (responseData === undefined) {
responseData = {
success: true,
};
}
returnData.push(responseData as IDataObject);
}
if (returnData[0].accessToken) {
return returnData[0].accessToken;
}
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}
}
// Rest API function for plutio node.
export async function plutioApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const endpoint = 'api.plutio.com/v1.10';
const credentials = await this.getCredentials('plutioApi');
const plutioApiToken = await plutioApiRequestToken.call(this);
const business = `${credentials.business}`;
let options: OptionsWithUri = {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${Buffer.from(plutioApiToken).toString()}`,
'Business': business,
},
method,
body,
qs: query,
uri: uri || `https://${endpoint}${resource}`,
json: true,
};
if (!Object.keys(body).length) {
delete options.body;
}
if (!Object.keys(query).length) {
delete options.qs;
}
options = Object.assign({}, options, option);
try {
return await this.helpers.request!(options);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}
}
export function capitalize(s: string): string {
if (typeof s !== 'string') return '';
return s.charAt(0).toUpperCase() + s.slice(1);
}

1057
nodes/Plutio/Plutio.node.ts Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,137 @@
import {
INodeProperties,
} from 'n8n-workflow';
export const commentOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
required: true,
displayOptions: {
show: {
resource: [
'comment',
],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new comment',
action: 'Create a comment',
},
{
name: 'Get',
value: 'get',
description: 'Get Comments',
action: 'Get a comment',
},
{
name: 'Update',
value: 'update',
description: 'Update a comment',
action: 'Update a comment',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a comment',
action: 'Delete a comment',
},
],
default: 'create',
},
];
export const commentDescription: INodeProperties[] = [
{
displayName: 'Entity ID',
name: 'entityId',
type: 'string',
default: '',
displayOptions: {
show: {
resource: [
'comment',
],
operation: [
'create',
'get',
],
},
},
description: 'Entity ID of comment(could be task ID, conversation ID or file ID)',
},
{
displayName: 'Entity Type',
name: 'entityType',
type: 'options',
displayOptions: {
show: {
resource: [
'comment',
],
operation: [
'create',
'get',
],
},
},
options: [
{
name: 'File',
value: 'file',
},
{
name: 'Conversation',
value: 'conversation',
},
{
name: 'Task',
value: 'task',
},
],
default: 'task',
},
{
displayName: 'Comment ID',
name: '_id',
required: true,
type: 'string',
default: '',
displayOptions: {
show: {
resource: [
'comment',
],
operation: [
'update',
'delete',
],
},
},
description: 'For GET operation Comment ID or entityType & entityID is required',
},
{
displayName: 'Body',
name: 'bodyHTML',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
resource: [
'comment',
],
operation: [
'update',
'create',
],
},
},
description: 'Comment Body',
},
];

View file

@ -0,0 +1,377 @@
import {
INodeProperties,
} from 'n8n-workflow';
export const invoiceOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
required: true,
displayOptions: {
show: {
resource: [
'invoice',
],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new invoice',
action: 'Create an invoice',
},
{
name: 'Get',
value: 'get',
description: 'Get invoices',
action: 'Get an invoice',
},
{
name: 'Update',
value: 'update',
description: 'Update an invoice',
action: 'Update an invoice',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete an invoice',
action: 'Delete an invoice',
},
],
default: 'create',
},
];
export const invoiceDescription: INodeProperties[] = [
{
displayName: 'Invoice ID',
name: '_id',
type: 'string',
default: '',
displayOptions: {
show: {
resource: [
'invoice',
],
operation: [
'update',
'delete',
],
},
},
description: 'Should be a number or string for discount percentage',
},
{
displayName: 'Tax',
name: 'taxUi',
type: 'fixedCollection',
placeholder: 'Add Tax',
description: 'Key value pairs containing the title and value of the tax',
displayOptions: {
show: {
resource: [
'invoice',
],
operation: [
'create',
'update',
],
},
},
typeOptions: {
multipleValues: true,
},
default: [],
options: [
{
displayName: 'Tax',
name: 'tax',
values: [
{
displayName: 'Title',
name: 'title',
type: 'string',
default: '',
description: 'Tax title',
},
{
displayName: 'Value',
name: 'value',
type: 'number',
default: '',
description: 'Tax value',
},
],
},
],
},
{
displayName: 'Client',
name: 'clientUi',
type: 'fixedCollection',
placeholder: 'Add Client',
description: 'Key value pairs containing the title and value of the tax',
default: [],
displayOptions: {
show: {
resource: [
'invoice',
],
operation: [
'create',
'update',
],
},
},
options: [
{
displayName: 'Client',
name: 'client',
values: [
{
displayName: 'Entity Type',
name: 'entityType',
type: 'options',
default: 'person',
options: [
{
name: 'Person',
value: 'person',
},
{
name: 'Company',
value: 'company',
},
],
description: 'Entity Type could be a person or company',
},
{
displayName: 'Entity Name or ID',
name: '_id',
type: 'string',
default: '',
description: 'Could be a person or company\'s name or ID',
},
],
},
],
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
resource: [
'invoice',
],
operation: [
'create',
],
},
},
options: [
{
displayName: 'Invoice Name',
name: 'name',
type: 'string',
default: '',
description: 'Min-Max Character: 1-500',
},
{
displayName: 'Currency',
name: 'currency',
type: 'options',
default: 'USD',
options: [
{
name: 'USD',
value: 'USD',
},
{
name: 'EUR',
value: 'EUR',
},
],
},
{
displayName: 'Discount',
name: 'discount',
type: 'number',
default: '',
description: 'Should be a number for discount percentage',
},
{
displayName: 'Template Name or ID',
name: 'templateId',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getInvoiceTemplateId',
},
},
],
},
// Options for GET Request
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
resource: [
'invoice',
],
operation: [
'get',
],
},
},
options: [
{
displayName: 'Invoice ID',
name: '_id',
type: 'string',
default: '',
description: 'Should be a number for discount percentage',
},
{
displayName: 'Invoice Name',
name: 'name',
type: 'string',
default: '',
description: 'Min-Max Character: 1-500',
},
{
displayName: 'Currency',
name: 'currency',
type: 'options',
default: 'USD',
options: [
{
name: 'USD',
value: 'USD',
},
{
name: 'EUR',
value: 'EUR',
},
],
},
{
displayName: 'Status',
name: 'status',
type: 'options',
default: 'draft',
options: [
{
name: 'Draft',
value: 'draft',
},
{
name: 'Pending',
value: 'pending',
},
{
name: 'Paid',
value: 'paid',
},
{
name: 'Cancelled',
value: 'cancelled',
},
],
},
{
displayName: 'Discount',
name: 'discount',
type: 'number',
default: '',
description: 'Should be a number for discount percentage',
},
],
},
// Options for Update Operation
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
resource: [
'invoice',
],
operation: [
'update',
],
},
},
options: [
{
displayName: 'Invoice Name',
name: 'name',
type: 'string',
default: '',
description: 'Min-Max Character: 1-500',
},
{
displayName: 'Currency',
name: 'currency',
type: 'options',
default: 'USD',
options: [
{
name: 'USD',
value: 'USD',
},
{
name: 'EUR',
value: 'EUR',
},
],
},
{
displayName: 'Status',
name: 'status',
type: 'options',
default: 'draft',
options: [
{
name: 'Draft',
value: 'draft',
},
{
name: 'Pending',
value: 'pending',
},
{
name: 'Paid',
value: 'paid',
},
{
name: 'Cancelled',
value: 'cancelled',
},
],
},
{
displayName: 'Discount',
name: 'discount',
type: 'number',
default: '',
description: 'Should be a number for discount percentage',
},
],
},
];

View file

@ -0,0 +1,289 @@
import {
INodeProperties,
} from 'n8n-workflow';
export const projectOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
required: true,
displayOptions: {
show: {
resource: [
'project',
],
},
},
options: [
{
name: 'Copy',
value: 'copy',
description: 'Copy a project',
action: 'Copy a project',
},
{
name: 'Create',
value: 'create',
description: 'Create a new project',
action: 'Create a project',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a project',
action: 'Delete a project',
},
{
name: 'Get',
value: 'get',
description: 'Get projects',
action: 'Get a project',
},
{
name: 'Chykalophia',
value: 'getCklph',
description: 'Get projects by contributor\'s email for CKLPH',
action: 'Get a project',
},
{
name: 'Move',
value: 'move',
description: 'Move a project',
action: 'Move a project',
},
{
name: 'Update',
value: 'update',
description: 'Update a project',
action: 'Update a project',
},
],
default: 'getCklph',
},
];
export const projectDescription: INodeProperties[] = [
{
displayName: 'Project ID',
name: '_id',
type: 'string',
default: '',
displayOptions: {
show: {
resource: [
'project',
],
operation: [
'update',
'move',
'copy',
'delete',
],
},
},
description: 'ID of Project',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
resource: [
'project',
],
operation: [
'update',
'create',
],
},
},
options: [
{
displayName: 'Project Name',
name: 'name',
type: 'string',
default: '',
description: 'Name of Project',
},
{
displayName: 'Template Name or ID',
name: 'templateId',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getProjectTemplateId',
},
},
],
},
{
displayName: 'Custom Fields',
name: 'customFields',
type: 'fixedCollection',
placeholder: 'Add Custom Field',
typeOptions: {
multipleValues: true,
},
displayOptions: {
show: {
resource: [
'project',
],
operation: [
'create',
'update',
],
},
},
description: 'Key value pairs containing the name and value of the custom field. Only dates in the format YYYY-MM-DD are accepted as input for custom date fields.',
default: [],
options: [
{
displayName: 'Custom Field',
name: 'customField',
values: [
{
displayName: 'Custom Field Name or ID',
name: '_id',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getProjectCustomField',
},
},
{
displayName: 'Value Name or ID',
name: 'value',
type: 'string',
default: '',
description: 'Custom Field\'s values',
},
],
},
],
},
{
displayName: 'Contributors',
name: 'contributorsUi',
type: 'fixedCollection',
default: [],
placeholder: 'Add Person',
typeOptions: {
multipleValues: true,
},
displayOptions: {
show: {
resource: [
'project',
],
operation: [
'update',
'create',
],
},
},
options: [
{
displayName: 'Contributors',
name: 'contributors',
values: [
{
displayName: 'Contributors: Name or ID',
name: 'value',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getUsers',
},
},
],
},
],
description: 'Name or ID of the user to whom the task has been assigned. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/nodes/expressions.html#expressions">expression</a>.',
},
{
displayName: 'Index',
name: 'index',
type: 'number',
default: '',
displayOptions: {
show: {
resource: [
'project',
],
operation: [
'move',
'copy',
],
},
},
description: 'Should be a number representing project ID after which project should be moved',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
resource: [
'project',
],
operation: [
'get',
],
},
},
options: [
{
displayName: 'Contributor\'s Email\, Name or ID',
name: 'contributor',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getEmails',
},
},
{
displayName: 'Project Name or ID',
name: '_id',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getProjectId',
},
},
],
},
{
displayName: 'Contributor\'s Email\, Name or ID',
name: 'contributor',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getEmails',
},
displayOptions: {
show: {
resource: [
'project',
],
operation: [
'getCklph',
],
},
},
},
];

View file

@ -0,0 +1,358 @@
import {
INodeProperties,
} from 'n8n-workflow';
export const taskOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
required: true,
displayOptions: {
show: {
resource: [
'task',
],
},
},
options: [
{
name: 'Copy',
value: 'copy',
description: 'Copy a task',
action: 'Copy a task',
},
{
name: 'Create',
value: 'create',
description: 'Create a new task',
action: 'Create a task',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a task',
action: 'Delete a task',
},
{
name: 'Get',
value: 'get',
description: 'Get tasks',
action: 'Get a task',
},
{
name: 'Move',
value: 'move',
description: 'Move a task',
action: 'Move a task',
},
{
name: 'Update',
value: 'update',
description: 'Update a task',
action: 'Update a task',
},
],
default: 'create',
},
];
export const taskDescription: INodeProperties[] = [
{
displayName: 'Task ID',
name: '_id',
type: 'string',
default: '',
displayOptions: {
show: {
resource: [
'task',
],
operation: [
'update',
'move',
'copy',
'delete',
],
},
},
description: 'ID of task',
},
// Options for creating and updating task.
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
resource: [
'task',
],
operation: [
'create',
'update',
],
},
},
options: [
{
displayName: 'Project Name or ID',
name: 'projectId',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getProjectId',
},
},
{
displayName: 'Task Board Name or ID',
name: 'taskBoardId',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getTaskBoardId',
},
},
{
displayName: 'Task Group Name or ID',
name: 'taskGroupId',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getTaskGroupId',
},
},
{
displayName: 'Template Name or ID',
name: 'templateId',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getTaskTemplateId',
},
},
{
displayName: 'Creator Name or ID',
name: 'createdBy',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getUsers',
},
},
{
displayName: 'Title',
name: 'title',
type: 'string',
default: '',
description: 'Title of the task',
},
{
displayName: 'Description',
name: 'descriptionHTML',
type: 'string',
default: '',
description: 'Request Description',
},
{
displayName: 'Custom Fields',
name: 'customFields',
type: 'fixedCollection',
placeholder: 'Add Custom Field',
typeOptions: {
multipleValues: true,
},
description: 'Key value pairs containing the name and value of the custom field. Only dates in the format YYYY-MM-DD are accepted as input for custom date fields.',
default: [],
options: [
{
displayName: 'Custom Field',
name: 'customField',
values: [
{
displayName: 'Custom Field Name or ID',
name: '_id',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getCustomFieldTitle',
},
},
{
displayName: 'Value Name or ID',
name: 'value',
type: 'string',
default: '',
description: 'Custom Field\'s values',
},
],
},
],
},
],
},
{
displayName: 'Assigned To: Name or ID',
name: 'assignees',
type: 'fixedCollection',
default: [],
placeholder: 'Add Person',
typeOptions: {
multipleValues: true,
},
displayOptions: {
show: {
resource: [
'task',
],
operation: [
'update',
'create',
],
},
},
options: [
{
displayName: 'Assignee',
name: 'assignee',
values: [
{
displayName: 'Assigned To: Name or ID',
name: 'value',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getUsers',
},
},
],
},
],
description: 'Name or ID of the user to whom the task has been assigned. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/nodes/expressions.html#expressions">expression</a>.',
},
// move & copy task operation
{
displayName: 'Task Group Name or ID',
name: 'taskGroupId',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getTaskGroupId',
},
displayOptions: {
show: {
resource: [
'task',
],
operation: [
'move',
'copy',
],
},
},
},
{
displayName: 'Position',
name: 'position',
type: 'number',
default: '',
displayOptions: {
show: {
resource: [
'task',
],
operation: [
'move',
'copy',
],
},
},
description: 'Should be a number representing task ID after which task should be moved',
},
// Options for GET request
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
resource: [
'task',
],
operation: [
'get',
],
},
},
options: [
{
displayName: 'Task ID',
name: '_id',
type: 'string',
default: '',
description: 'ID of task',
},
{
displayName: 'Project Name or ID',
name: 'projectId',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getProjectId',
},
},
{
displayName: 'Task Board Name or ID',
name: 'taskBoardId',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getTaskBoardId',
},
},
{
displayName: 'Task Group Name or ID',
name: 'taskGroupId',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getTaskGroupId',
},
},
{
displayName: 'Creator Name or ID',
name: 'createdBy',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
default: '',
typeOptions: {
loadOptionsMethod: 'getUsers',
},
},
{
displayName: 'Title',
name: 'title',
type: 'string',
default: '',
},
],
},
];

View file

@ -0,0 +1,15 @@
import { taskDescription, taskOperations } from './TaskDescription';
import { commentDescription, commentOperations } from './CommentDescription';
import { invoiceDescription, invoiceOperations } from './InvoiceDescription';
import { projectDescription, projectOperations } from './ProjectDescription';
export {
taskOperations,
taskDescription,
commentOperations,
commentDescription,
invoiceOperations,
invoiceDescription,
projectOperations,
projectDescription,
};

BIN
nodes/Plutio/plutio.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB