From 73c52102949274c4c67ae34c458a6afa9520c150 Mon Sep 17 00:00:00 2001 From: Jonathan Bennetts Date: Fri, 2 Sep 2022 15:51:05 +0100 Subject: [PATCH] fix(beeminder Node): fix request id not being sent when creating a new datapoint --- .../credentials/BeeminderApi.credentials.ts | 23 ++++++++++++++++++- .../nodes/Beeminder/Beeminder.node.ts | 3 +-- .../nodes/Beeminder/GenericFunctions.ts | 6 +---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/packages/nodes-base/credentials/BeeminderApi.credentials.ts b/packages/nodes-base/credentials/BeeminderApi.credentials.ts index 27367c5f4a..365813f246 100644 --- a/packages/nodes-base/credentials/BeeminderApi.credentials.ts +++ b/packages/nodes-base/credentials/BeeminderApi.credentials.ts @@ -1,4 +1,9 @@ -import { ICredentialType, INodeProperties } from 'n8n-workflow'; +import { + IAuthenticateGeneric, + ICredentialTestRequest, + ICredentialType, + INodeProperties, +} from 'n8n-workflow'; export class BeeminderApi implements ICredentialType { name = 'beeminderApi'; @@ -18,4 +23,20 @@ export class BeeminderApi implements ICredentialType { default: '', }, ]; + + authenticate: IAuthenticateGeneric = { + type: 'generic', + properties: { + body: { + auth_token: '={{$credentials.authToken}}', + }, + }, + }; + + test: ICredentialTestRequest = { + request: { + baseURL: 'https://www.beeminder.com/api/v1', + url: `=/users/{{$credentials.user}}.json`, + }, + }; } diff --git a/packages/nodes-base/nodes/Beeminder/Beeminder.node.ts b/packages/nodes-base/nodes/Beeminder/Beeminder.node.ts index d872d9846b..16c2aa0686 100644 --- a/packages/nodes-base/nodes/Beeminder/Beeminder.node.ts +++ b/packages/nodes-base/nodes/Beeminder/Beeminder.node.ts @@ -8,7 +8,6 @@ import { INodePropertyOptions, INodeType, INodeTypeDescription, - NodeOperationError, } from 'n8n-workflow'; import { @@ -197,7 +196,7 @@ export class Beeminder implements INodeType { }, { displayName: 'Request ID', - name: 'requestId', + name: 'requestid', type: 'string', default: '', placeholder: '', diff --git a/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts b/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts index 9ea2b43e6a..e88f0de9c2 100644 --- a/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts @@ -15,10 +15,6 @@ export async function beeminderApiRequest( query: IDataObject = {}, // tslint:disable-next-line:no-any ): Promise { - const credentials = (await this.getCredentials('beeminderApi')) as IDataObject; - - Object.assign(body, { auth_token: credentials.authToken }); - const options: OptionsWithUri = { method, body, @@ -36,7 +32,7 @@ export async function beeminderApiRequest( } try { - return await this.helpers.request!(options); + return await this.helpers.requestWithAuthentication.call(this, 'beeminderApi', options); } catch (error) { throw new NodeApiError(this.getNode(), error); }