mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 22:54:05 -08:00
9b5731450f
* 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>
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
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);
|
|
}
|
|
}
|