Add Wufoo-Trigger node (#597)

* Generic functions, credentials, interface, logo, triggernode

* TSLint tabs rule, request error handling, webhook done

On hold until Wufoo responds with sandbox account

* Removed test logging, fixed various errors, cleaned up

* Sorted imports, adjusted data display,  removed anys, tslint import sort rule

* RAAAAAW data

*  Fix logo and improve formatting

*  Improvements

*  Minor improvements to WuFoo-Trigger

Co-authored-by: Rupenieks <ru@myos,co>
Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Rupenieks
2020-10-01 09:07:55 +02:00
committed by GitHub
parent 70dc99da41
commit 9b5731450f
7 changed files with 350 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
import {
OptionsWithUri,
} from 'request';
import {
IExecuteFunctions,
IExecuteSingleFunctions,
IHookFunctions,
ILoadOptionsFunctions,
} from 'n8n-core';
import {
IDataObject,
} from 'n8n-workflow';
export async function wufooApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('wufooApi');
if (credentials === undefined) {
throw new Error('No credentials got returned!');
}
let options: OptionsWithUri = {
auth: {
username: credentials!.apiKey as string,
password: '',
},
method,
form: body,
body,
qs,
uri: `https://${credentials!.subdomain}.wufoo.com/api/v3/${resource}`,
json: true
};
options = Object.assign({}, options, option);
if (Object.keys(options.body).length === 0 || method === 'PUT') {
delete options.body;
}
try {
return await this.helpers.request!(options);
} catch (error) {
throw new Error(error.message);
}
}