Minor improvements to ConvertKit-Node

This commit is contained in:
Jan Oberhauser 2020-08-25 23:16:38 +02:00
parent 8da0f6af4a
commit 426f0ae784
3 changed files with 14 additions and 20 deletions

View file

@ -6,9 +6,9 @@ import {
import {
IDataObject,
INodeExecutionData,
INodePropertyOptions,
INodeTypeDescription,
INodeType,
INodePropertyOptions,
} from 'n8n-workflow';
import {
@ -16,28 +16,28 @@ import {
} from './GenericFunctions';
import {
customFieldOperations,
customFieldFields,
customFieldOperations,
} from './CustomFieldDescription';
import {
formOperations,
formFields,
formOperations,
} from './FormDescription';
import {
sequenceOperations,
sequenceFields,
sequenceOperations,
} from './SequenceDescription';
import {
tagOperations,
tagFields,
tagOperations,
} from './TagDescription';
import {
tagSubscriberOperations,
tagSubscriberFields,
tagSubscriberOperations,
} from './TagSubscriberDescription';
export class ConvertKit implements INodeType {
@ -88,7 +88,7 @@ export class ConvertKit implements INodeType {
value: 'tagSubscriber',
},
],
default: 'customField',
default: 'form',
description: 'The resource to operate on.'
},
//--------------------
@ -470,7 +470,7 @@ export class ConvertKit implements INodeType {
const email = this.getNodeParameter('email', i) as string;
responseData= await convertKitApiRequest.call(this, 'POST', `/tags/${tagId}>/unsubscribe`, { email });
responseData = await convertKitApiRequest.call(this, 'POST', `/tags/${tagId}>/unsubscribe`, { email });
}
}

View file

@ -5,11 +5,11 @@ import {
import {
IDataObject,
ILoadOptionsFunctions,
INodePropertyOptions,
INodeTypeDescription,
INodeType,
IWebhookResponseData,
ILoadOptionsFunctions,
INodePropertyOptions,
} from 'n8n-workflow';
import {
@ -266,7 +266,7 @@ export class ConvertKitTrigger implements INodeType {
// THe API does not have an endpoint to list all webhooks
if(webhookData.webhookId) {
if (webhookData.webhookId) {
return true;
}
@ -282,11 +282,8 @@ export class ConvertKitTrigger implements INodeType {
const endpoint = '/automations/hooks';
if (event === 'purchaseCreate') {
event = `purchase.${snakeCase(event)}`;
} else {
event = `subscriber.${snakeCase(event)}`;
}
@ -344,11 +341,8 @@ export class ConvertKitTrigger implements INodeType {
const endpoint = `/automations/hooks/${webhookData.webhookId}`;
try {
await convertKitApiRequest.call(this, 'DELETE', endpoint);
} catch (error) {
return false;
}

View file

@ -4,8 +4,8 @@ import {
import {
IExecuteFunctions,
ILoadOptionsFunctions,
IExecuteSingleFunctions,
ILoadOptionsFunctions,
} from 'n8n-core';
import {
@ -16,7 +16,7 @@ import {
export async function convertKitApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions,
method: string, endpoint: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('convertKitApi');
const credentials = this.getCredentials('convertKitApi');
if (credentials === undefined) {
throw new Error('No credentials got returned!');
@ -29,7 +29,7 @@ export async function convertKitApiRequest(this: IExecuteFunctions | IExecuteSin
method,
qs,
body,
uri: uri ||`https://api.convertkit.com/v3${endpoint}`,
uri: uri || `https://api.convertkit.com/v3${endpoint}`,
json: true,
};