Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wufooTrigger Node): fix form names not being listed correctly #4151

Merged
merged 1 commit into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion packages/nodes-base/credentials/WufooApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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',
},
};
}
10 changes: 3 additions & 7 deletions packages/nodes-base/nodes/Wufoo/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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);
}
}
6 changes: 3 additions & 3 deletions packages/nodes-base/nodes/Wufoo/WufooTrigger.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {

import { wufooApiRequest } from './GenericFunctions';

import { IField, IFormQuery, IWebhook } from './Interface';
import { IField, IWebhook } from './Interface';

import { randomBytes } from 'crypto';

Expand Down Expand Up @@ -70,9 +70,9 @@ export class WufooTrigger implements INodeType {
loadOptions: {
async getForms(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
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;
Expand Down