Fixed deprecated API calls & Added OAuth2 support

This commit is contained in:
Rupenieks
2020-06-16 14:16:03 +02:00
parent 346ae8efc9
commit 04f1f26248
4 changed files with 117 additions and 11 deletions

View File

@@ -35,7 +35,25 @@ export class EventbriteTrigger implements INodeType {
{
name: 'eventbriteApi',
required: true,
}
displayOptions: {
show: {
authentication: [
'accessToken',
],
},
},
},
{
name: 'eventbriteOAuth2Api',
required: true,
displayOptions: {
show: {
authentication: [
'oAuth2',
],
},
},
},
],
webhooks: [
{
@@ -46,6 +64,23 @@ export class EventbriteTrigger implements INodeType {
},
],
properties: [
{
displayName: 'Authentication',
name: 'authentication',
type: 'options',
options: [
{
name: 'Access Token',
value: 'accessToken',
},
{
name: 'OAuth2',
value: 'oAuth2',
},
],
default: 'accessToken',
description: 'The resource to operate on.',
},
{
displayName: 'Organization',
name: 'organization',
@@ -192,10 +227,12 @@ export class EventbriteTrigger implements INodeType {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {
const webhookData = this.getWorkflowStaticData('node');
const organisation = this.getNodeParameter('organization') as string;
if (webhookData.webhookId === undefined) {
return false;
}
const endpoint = `/webhooks/${webhookData.webhookId}/`;
const endpoint = `/organizations/${organisation}/webhooks/`;
try {
await eventbriteApiRequest.call(this, 'GET', endpoint);
} catch (e) {
@@ -206,9 +243,10 @@ export class EventbriteTrigger implements INodeType {
async create(this: IHookFunctions): Promise<boolean> {
const webhookUrl = this.getNodeWebhookUrl('default');
const webhookData = this.getWorkflowStaticData('node');
const organisation = this.getNodeParameter('organization') as string;
const event = this.getNodeParameter('event') as string;
const actions = this.getNodeParameter('actions') as string[];
const endpoint = `/webhooks/`;
const endpoint = `/organizations/${organisation}/webhooks/`;
const body: IDataObject = {
endpoint_url: webhookUrl,
actions: actions.join(','),