From 616d62aa8ef64952eb248b162176460a7ac65cc3 Mon Sep 17 00:00:00 2001 From: Jonathan Bennetts Date: Fri, 30 Sep 2022 12:18:14 +0100 Subject: [PATCH] fix(wufooTrigger Node): fix form names not being listed correctly (#4151) --- .../credentials/WufooApi.credentials.ts | 24 ++++++++++++++++++- .../nodes/Wufoo/GenericFunctions.ts | 10 +++----- .../nodes/Wufoo/WufooTrigger.node.ts | 6 ++--- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/packages/nodes-base/credentials/WufooApi.credentials.ts b/packages/nodes-base/credentials/WufooApi.credentials.ts index 6494853f48..56660f10dd 100644 --- a/packages/nodes-base/credentials/WufooApi.credentials.ts +++ b/packages/nodes-base/credentials/WufooApi.credentials.ts @@ -1,4 +1,9 @@ -import { ICredentialType, INodeProperties } from 'n8n-workflow'; +import { + IAuthenticateGeneric, + ICredentialTestRequest, + ICredentialType, + INodeProperties, +} from 'n8n-workflow'; export class WufooApi implements ICredentialType { name = 'wufooApi'; @@ -18,4 +23,21 @@ export class WufooApi implements ICredentialType { default: '', }, ]; + + authenticate: IAuthenticateGeneric = { + type: 'generic', + properties: { + auth: { + username: '={{$credentials.apiKey}}', + password: 'not-needed', + }, + }, + }; + + test: ICredentialTestRequest = { + request: { + baseURL: '=https://{{$credentials.subdomain}}.wufoo.com', + url: '/api/v3/forms.json', + }, + }; } diff --git a/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts b/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts index acb64f82e0..6912162bdf 100644 --- a/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts @@ -7,7 +7,7 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; +import { IDataObject, JsonObject, NodeApiError } from 'n8n-workflow'; export async function wufooApiRequest( this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, @@ -23,10 +23,6 @@ export async function wufooApiRequest( const credentials = await this.getCredentials('wufooApi'); let options: OptionsWithUri = { - auth: { - username: credentials!.apiKey as string, - password: '', - }, method, form: body, body, @@ -41,8 +37,8 @@ export async function wufooApiRequest( } try { - return await this.helpers.request!(options); + return await this.helpers.requestWithAuthentication.call(this, 'wufooApi', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Wufoo/WufooTrigger.node.ts b/packages/nodes-base/nodes/Wufoo/WufooTrigger.node.ts index 03efdfc10d..a5ae15acf7 100644 --- a/packages/nodes-base/nodes/Wufoo/WufooTrigger.node.ts +++ b/packages/nodes-base/nodes/Wufoo/WufooTrigger.node.ts @@ -11,7 +11,7 @@ import { import { wufooApiRequest } from './GenericFunctions'; -import { IField, IFormQuery, IWebhook } from './Interface'; +import { IField, IWebhook } from './Interface'; import { randomBytes } from 'crypto'; @@ -70,9 +70,9 @@ export class WufooTrigger implements INodeType { loadOptions: { async getForms(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const body: IFormQuery = { includeTodayCount: true }; + // https://wufoo.github.io/docs/#all-forms - const formObject = await wufooApiRequest.call(this, 'GET', 'forms.json', body); + const formObject = await wufooApiRequest.call(this, 'GET', 'forms.json'); for (const form of formObject.Forms) { const name = form.Name; const value = form.Hash;