Compare commits
No commits in common. "f3b5f6c953d7032c2c0428ccf9d43721cd6df875" and "dad641b8bcb07919239d1840d4d6a345f3457ef3" have entirely different histories.
f3b5f6c953
...
dad641b8bc
|
@ -1,12 +1,43 @@
|
||||||
import {
|
import {
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
|
ICredentialDataDecryptedObject,
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
IExecuteFunctions,
|
||||||
|
ICredentialTestRequest,
|
||||||
|
NodeApiError,
|
||||||
|
IDataObject,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export class PlutioApi implements ICredentialType {
|
export class PlutioApi implements ICredentialType {
|
||||||
name = 'plutioApi';
|
name = 'plutioApi';
|
||||||
displayName = 'Plutio API';
|
displayName = 'Plutio API';
|
||||||
|
extends = ['oAuth2Api'];
|
||||||
properties: INodeProperties[] = [
|
properties: INodeProperties[] = [
|
||||||
|
// {
|
||||||
|
// displayName: 'Grant Type',
|
||||||
|
// name: 'grantType',
|
||||||
|
// type: 'hidden',
|
||||||
|
// default: 'client_credentials',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// displayName: 'Scope',
|
||||||
|
// name: 'scope',
|
||||||
|
// type: 'hidden',
|
||||||
|
// default: '*',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// displayName: 'Authentication',
|
||||||
|
// name: 'authentication',
|
||||||
|
// type: 'hidden',
|
||||||
|
// default: 'header',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// displayName: 'Access Token URL',
|
||||||
|
// name: 'accessTokenUrl',
|
||||||
|
// type: 'hidden',
|
||||||
|
// default: 'https://api.plutio.com/v1.10/oauth/token',
|
||||||
|
// },
|
||||||
{
|
{
|
||||||
displayName: 'Client ID',
|
displayName: 'Client ID',
|
||||||
name: 'clientId',
|
name: 'clientId',
|
||||||
|
@ -29,4 +60,57 @@ export class PlutioApi implements ICredentialType {
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// async preAuthentication(this: IExecuteFunctions, credentials: ICredentialDataDecryptedObject) {
|
||||||
|
// const endpoint = 'api.plutio.com/v1.10';
|
||||||
|
// const returnData: IDataObject[] = [];
|
||||||
|
// let access_token;
|
||||||
|
// try {
|
||||||
|
// access_token = await this.helpers.httpRequest({
|
||||||
|
// method: 'POST',
|
||||||
|
// url: `https://${endpoint}/oauth/token`,
|
||||||
|
// headers: {
|
||||||
|
// 'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
// 'business': `${credentials.business}`,
|
||||||
|
// },
|
||||||
|
// body: {
|
||||||
|
// 'client_id': `${credentials.clientId}`,
|
||||||
|
// 'client_secret': `${credentials.clientSecret}`,
|
||||||
|
// 'grant_type': 'client_credentials',
|
||||||
|
// },
|
||||||
|
// json: true,
|
||||||
|
// }) as {access_token: IDataObject};
|
||||||
|
// if (Array.isArray(access_token)) {
|
||||||
|
// returnData.push.apply(returnData, access_token as IDataObject[]);
|
||||||
|
// } else {
|
||||||
|
// if (access_token === undefined) {
|
||||||
|
// access_token = {
|
||||||
|
// success: true,
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
// returnData.push(access_token as IDataObject);
|
||||||
|
// }
|
||||||
|
// if (returnData[0].accessToken) {
|
||||||
|
// return {accessToken: returnData[0].accessToken};
|
||||||
|
// }
|
||||||
|
// } catch (error) {
|
||||||
|
// throw new NodeApiError(this.getNode(), error);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// authenticate: IAuthenticateGeneric = {
|
||||||
|
// type: 'generic',
|
||||||
|
// properties: {
|
||||||
|
// headers: {
|
||||||
|
// 'Content-Type': 'application/json',
|
||||||
|
// 'Business': '={{$credentials.business}}',
|
||||||
|
// 'Authorization': '=Bearer {{$credentials.accessToken}}',
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// };
|
||||||
|
// test: ICredentialTestRequest = {
|
||||||
|
// request: {
|
||||||
|
// baseURL: 'https://api.plutio.com/v1.10',
|
||||||
|
// url: '/templates',
|
||||||
|
// },
|
||||||
|
// };
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,11 @@ async function plutioApiRequestToken(this: IExecuteFunctions | ILoadOptionsFunct
|
||||||
const clientId = `${credentials.clientId}`;
|
const clientId = `${credentials.clientId}`;
|
||||||
const clientSecret = `${credentials.clientSecret}`;
|
const clientSecret = `${credentials.clientSecret}`;
|
||||||
const business = `${credentials.business}`;
|
const business = `${credentials.business}`;
|
||||||
|
<<<<<<< HEAD
|
||||||
const endpoint = 'api.plutio.com/v1.10';
|
const endpoint = 'api.plutio.com/v1.10';
|
||||||
|
=======
|
||||||
|
const endpoint = 'api.plutio.com/v1.9';
|
||||||
|
>>>>>>> master
|
||||||
const returnData: IDataObject[] = [];
|
const returnData: IDataObject[] = [];
|
||||||
|
|
||||||
let responseData;
|
let responseData;
|
||||||
|
@ -59,7 +62,11 @@ async function plutioApiRequestToken(this: IExecuteFunctions | ILoadOptionsFunct
|
||||||
|
|
||||||
// Rest API function for plutio node.
|
// 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
|
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
|
||||||
|
<<<<<<< HEAD
|
||||||
const endpoint = 'api.plutio.com/v1.10';
|
const endpoint = 'api.plutio.com/v1.10';
|
||||||
|
=======
|
||||||
|
const endpoint = 'api.plutio.com/v1.9';
|
||||||
|
>>>>>>> master
|
||||||
const credentials = await this.getCredentials('plutioApi');
|
const credentials = await this.getCredentials('plutioApi');
|
||||||
const plutioApiToken = await plutioApiRequestToken.call(this);
|
const plutioApiToken = await plutioApiRequestToken.call(this);
|
||||||
const business = `${credentials.business}`;
|
const business = `${credentials.business}`;
|
||||||
|
|
|
@ -826,6 +826,26 @@ export class Plutio implements INodeType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ('project' === resource) {
|
if ('project' === resource) {
|
||||||
|
if ('getCklph' === operation) {
|
||||||
|
const contributor = this.getNodeParameter('contributor', i) as IDataObject;
|
||||||
|
|
||||||
|
if (contributor) {
|
||||||
|
let contributorId;
|
||||||
|
const users = await plutioApiRequest.call(this, 'GET', '/people');
|
||||||
|
for (const user of users) {
|
||||||
|
if (user.contactEmails[0].address === contributor || contributor === user._id) {
|
||||||
|
contributorId = user._id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qs.contributors = contributorId as string;
|
||||||
|
}
|
||||||
|
const project = await plutioApiRequest.call(this, 'GET', '/projects', {}, qs);
|
||||||
|
if (project.length === 1) {
|
||||||
|
responseData = project;
|
||||||
|
} else {
|
||||||
|
responseData = {'name': 'default'};
|
||||||
|
}
|
||||||
|
}
|
||||||
if ('get' === operation) {
|
if ('get' === operation) {
|
||||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||||
|
|
||||||
|
@ -977,7 +997,7 @@ export class Plutio implements INodeType {
|
||||||
|
|
||||||
body.contributors = contributor as [string];
|
body.contributors = contributor as [string];
|
||||||
}
|
}
|
||||||
responseData = await plutioApiRequest.call(this, 'PUT', '/projects', body);
|
responseData = await plutioApiRequest.call(this, 'PUT', '/projects', body);;
|
||||||
}
|
}
|
||||||
if ('move' === operation) {
|
if ('move' === operation) {
|
||||||
const _id = this.getNodeParameter('_id', 0) as string;
|
const _id = this.getNodeParameter('_id', 0) as string;
|
||||||
|
|
|
@ -41,6 +41,12 @@ export const projectOperations: INodeProperties[] = [
|
||||||
description: 'Get projects',
|
description: 'Get projects',
|
||||||
action: 'Get a project',
|
action: 'Get a project',
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// name: 'Chykalophia',
|
||||||
|
// value: 'getCklph',
|
||||||
|
// description: 'Get projects by contributor\'s email for CKLPH',
|
||||||
|
// action: 'Get a project',
|
||||||
|
// },
|
||||||
{
|
{
|
||||||
name: 'Move',
|
name: 'Move',
|
||||||
value: 'move',
|
value: 'move',
|
||||||
|
@ -54,7 +60,7 @@ export const projectOperations: INodeProperties[] = [
|
||||||
action: 'Update a project',
|
action: 'Update a project',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: 'get',
|
default: 'getCklph',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -108,7 +114,7 @@ export const projectDescription: INodeProperties[] = [
|
||||||
displayName: 'Template Name or ID',
|
displayName: 'Template Name or ID',
|
||||||
name: 'templateId',
|
name: 'templateId',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/nodes/expressions.html#expressions">expression</a>',
|
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||||
default: '',
|
default: '',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
loadOptionsMethod: 'getProjectTemplateId',
|
loadOptionsMethod: 'getProjectTemplateId',
|
||||||
|
@ -146,7 +152,7 @@ export const projectDescription: INodeProperties[] = [
|
||||||
displayName: 'Custom Field Name or ID',
|
displayName: 'Custom Field Name or ID',
|
||||||
name: '_id',
|
name: '_id',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/nodes/expressions.html#expressions">expression</a>',
|
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||||
default: '',
|
default: '',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
loadOptionsMethod: 'getProjectCustomField',
|
loadOptionsMethod: 'getProjectCustomField',
|
||||||
|
@ -192,7 +198,7 @@ export const projectDescription: INodeProperties[] = [
|
||||||
displayName: 'Contributors: Name or ID',
|
displayName: 'Contributors: Name or ID',
|
||||||
name: 'value',
|
name: 'value',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/nodes/expressions.html#expressions">expression</a>',
|
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||||
default: '',
|
default: '',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
loadOptionsMethod: 'getUsers',
|
loadOptionsMethod: 'getUsers',
|
||||||
|
@ -242,7 +248,7 @@ export const projectDescription: INodeProperties[] = [
|
||||||
displayName: 'Contributor\'s Email\, Name or ID',
|
displayName: 'Contributor\'s Email\, Name or ID',
|
||||||
name: 'contributor',
|
name: 'contributor',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/nodes/expressions.html#expressions">expression</a>',
|
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||||
default: '',
|
default: '',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
loadOptionsMethod: 'getEmails',
|
loadOptionsMethod: 'getEmails',
|
||||||
|
@ -252,7 +258,7 @@ export const projectDescription: INodeProperties[] = [
|
||||||
displayName: 'Project Name or ID',
|
displayName: 'Project Name or ID',
|
||||||
name: '_id',
|
name: '_id',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/nodes/expressions.html#expressions">expression</a>',
|
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||||
default: '',
|
default: '',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
loadOptionsMethod: 'getProjectId',
|
loadOptionsMethod: 'getProjectId',
|
||||||
|
@ -260,4 +266,24 @@ export const projectDescription: INodeProperties[] = [
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
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',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue