diff --git a/packages/nodes-base/credentials/EventbriteApi.credentials.ts b/packages/nodes-base/credentials/EventbriteApi.credentials.ts
index 9fa48753fb..e54be8580c 100644
--- a/packages/nodes-base/credentials/EventbriteApi.credentials.ts
+++ b/packages/nodes-base/credentials/EventbriteApi.credentials.ts
@@ -8,7 +8,7 @@ export class EventbriteApi implements ICredentialType {
displayName = 'Eventbrite API';
properties = [
{
- displayName: 'API Key',
+ displayName: 'Private Key',
name: 'apiKey',
type: 'string' as NodePropertyTypes,
default: '',
diff --git a/packages/nodes-base/nodes/Eventbrite/EventbriteTrigger.node.ts b/packages/nodes-base/nodes/Eventbrite/EventbriteTrigger.node.ts
index 8299ae866d..0c9158b6c3 100644
--- a/packages/nodes-base/nodes/Eventbrite/EventbriteTrigger.node.ts
+++ b/packages/nodes-base/nodes/Eventbrite/EventbriteTrigger.node.ts
@@ -38,7 +38,7 @@ export class EventbriteTrigger implements INodeType {
displayOptions: {
show: {
authentication: [
- 'accessToken',
+ 'privateKey',
],
},
},
@@ -70,15 +70,15 @@ export class EventbriteTrigger implements INodeType {
type: 'options',
options: [
{
- name: 'Access Token',
- value: 'accessToken',
+ name: 'Private Key',
+ value: 'privateKey',
},
{
name: 'OAuth2',
value: 'oAuth2',
},
],
- default: 'accessToken',
+ default: 'privateKey',
description: 'The resource to operate on.',
},
{
@@ -184,7 +184,6 @@ export class EventbriteTrigger implements INodeType {
description: 'By default does the webhook-data only contain the URL to receive
the object data manually. If this option gets activated it
will resolve the data automatically.',
},
],
-
};
methods = {
@@ -227,18 +226,31 @@ export class EventbriteTrigger implements INodeType {
default: {
async checkExists(this: IHookFunctions): Promise {
const webhookData = this.getWorkflowStaticData('node');
+ const webhookUrl = this.getNodeWebhookUrl('default');
const organisation = this.getNodeParameter('organization') as string;
+ const actions = this.getNodeParameter('actions') as string[];
- if (webhookData.webhookId === undefined) {
- return false;
- }
const endpoint = `/organizations/${organisation}/webhooks/`;
- try {
- await eventbriteApiRequest.call(this, 'GET', endpoint);
- } catch (e) {
- return false;
+
+ const { webhooks } = await eventbriteApiRequest.call(this, 'GET', endpoint);
+
+ const check = (currentActions: string[], webhookActions: string[]) => {
+ for (const currentAction of currentActions) {
+ if (!webhookActions.includes(currentAction)) {
+ return false;
+ }
+ }
+ return true;
+ };
+
+ for (const webhook of webhooks) {
+ if (webhook.endpoint_url === webhookUrl && check(actions, webhook.actions)) {
+ webhookData.webhookId = webhook.id;
+ return true;
+ }
}
- return true;
+
+ return false;
},
async create(this: IHookFunctions): Promise {
const webhookUrl = this.getNodeWebhookUrl('default');
diff --git a/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts b/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts
index 5bbb517c5d..2392a0ae20 100644
--- a/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts
+++ b/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts
@@ -1,4 +1,7 @@
-import { OptionsWithUri } from 'request';
+import {
+ OptionsWithUri,
+} from 'request';
+
import {
IExecuteFunctions,
IExecuteSingleFunctions,
@@ -6,7 +9,10 @@ import {
ILoadOptionsFunctions,
IWebhookFunctions,
} from 'n8n-core';
-import { IDataObject } from 'n8n-workflow';
+
+import {
+ IDataObject,
+} from 'n8n-workflow';
export async function eventbriteApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any
let options: OptionsWithUri = {
@@ -25,7 +31,7 @@ export async function eventbriteApiRequest(this: IHookFunctions | IExecuteFuncti
const authenticationMethod = this.getNodeParameter('authentication', 0);
try {
- if (authenticationMethod === 'accessToken') {
+ if (authenticationMethod === 'privateKey') {
const credentials = this.getCredentials('eventbriteApi');
if (credentials === undefined) {
throw new Error('No credentials got returned!');