mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
fix(wufooTrigger Node): fix form names not being listed correctly (#4151)
This commit is contained in:
parent
764bd3522b
commit
616d62aa8e
|
@ -1,4 +1,9 @@
|
||||||
import { ICredentialType, INodeProperties } from 'n8n-workflow';
|
import {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
|
ICredentialType,
|
||||||
|
INodeProperties,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export class WufooApi implements ICredentialType {
|
export class WufooApi implements ICredentialType {
|
||||||
name = 'wufooApi';
|
name = 'wufooApi';
|
||||||
|
@ -18,4 +23,21 @@ export class WufooApi implements ICredentialType {
|
||||||
default: '',
|
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',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
ILoadOptionsFunctions,
|
ILoadOptionsFunctions,
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
|
||||||
import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow';
|
import { IDataObject, JsonObject, NodeApiError } from 'n8n-workflow';
|
||||||
|
|
||||||
export async function wufooApiRequest(
|
export async function wufooApiRequest(
|
||||||
this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
||||||
|
@ -23,10 +23,6 @@ export async function wufooApiRequest(
|
||||||
const credentials = await this.getCredentials('wufooApi');
|
const credentials = await this.getCredentials('wufooApi');
|
||||||
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
auth: {
|
|
||||||
username: credentials!.apiKey as string,
|
|
||||||
password: '',
|
|
||||||
},
|
|
||||||
method,
|
method,
|
||||||
form: body,
|
form: body,
|
||||||
body,
|
body,
|
||||||
|
@ -41,8 +37,8 @@ export async function wufooApiRequest(
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.requestWithAuthentication.call(this, 'wufooApi', options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import {
|
||||||
|
|
||||||
import { wufooApiRequest } from './GenericFunctions';
|
import { wufooApiRequest } from './GenericFunctions';
|
||||||
|
|
||||||
import { IField, IFormQuery, IWebhook } from './Interface';
|
import { IField, IWebhook } from './Interface';
|
||||||
|
|
||||||
import { randomBytes } from 'crypto';
|
import { randomBytes } from 'crypto';
|
||||||
|
|
||||||
|
@ -70,9 +70,9 @@ export class WufooTrigger implements INodeType {
|
||||||
loadOptions: {
|
loadOptions: {
|
||||||
async getForms(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
async getForms(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
const returnData: INodePropertyOptions[] = [];
|
const returnData: INodePropertyOptions[] = [];
|
||||||
const body: IFormQuery = { includeTodayCount: true };
|
|
||||||
// https://wufoo.github.io/docs/#all-forms
|
// 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) {
|
for (const form of formObject.Forms) {
|
||||||
const name = form.Name;
|
const name = form.Name;
|
||||||
const value = form.Hash;
|
const value = form.Hash;
|
||||||
|
|
Loading…
Reference in a new issue