From e209077160ca9126f75f10a4cb7846c18adbedaf Mon Sep 17 00:00:00 2001 From: Erin Date: Thu, 2 Jul 2020 16:41:59 -0400 Subject: [PATCH] :sparkles: ConvertKit Trigger and Regular Node --- .../credentials/ConvertKitApi.credentials.ts | 21 ++ .../nodes/ConvertKit/ConvertKit.node.ts | 289 ++++++++++++++++++ .../ConvertKit/ConvertKitTrigger.node.ts | 163 ++++++++++ .../nodes/ConvertKit/FieldDescription.ts | 83 +++++ .../nodes/ConvertKit/FormDescription.ts | 174 +++++++++++ .../nodes/ConvertKit/GenericFunctions.ts | 44 +++ .../nodes/ConvertKit/SequenceDescription.ts | 174 +++++++++++ .../nodes/ConvertKit/TagDescription.ts | 204 +++++++++++++ .../nodes/ConvertKit/convertKit.png | Bin 0 -> 4958 bytes packages/nodes-base/package.json | 3 + 10 files changed, 1155 insertions(+) create mode 100644 packages/nodes-base/credentials/ConvertKitApi.credentials.ts create mode 100644 packages/nodes-base/nodes/ConvertKit/ConvertKit.node.ts create mode 100644 packages/nodes-base/nodes/ConvertKit/ConvertKitTrigger.node.ts create mode 100644 packages/nodes-base/nodes/ConvertKit/FieldDescription.ts create mode 100644 packages/nodes-base/nodes/ConvertKit/FormDescription.ts create mode 100644 packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts create mode 100644 packages/nodes-base/nodes/ConvertKit/SequenceDescription.ts create mode 100644 packages/nodes-base/nodes/ConvertKit/TagDescription.ts create mode 100644 packages/nodes-base/nodes/ConvertKit/convertKit.png diff --git a/packages/nodes-base/credentials/ConvertKitApi.credentials.ts b/packages/nodes-base/credentials/ConvertKitApi.credentials.ts new file mode 100644 index 0000000000..1685c11a24 --- /dev/null +++ b/packages/nodes-base/credentials/ConvertKitApi.credentials.ts @@ -0,0 +1,21 @@ +import { + ICredentialType, + NodePropertyTypes, +} from 'n8n-workflow'; + + +export class ConvertKitApi implements ICredentialType { + name = 'convertKitApi'; + displayName = 'ConvertKit Api'; + properties = [ + { + displayName: 'API Secret', + name: 'apiSecret', + type: 'string' as NodePropertyTypes, + default: '', + typeOptions: { + password: true, + }, + }, + ]; +} diff --git a/packages/nodes-base/nodes/ConvertKit/ConvertKit.node.ts b/packages/nodes-base/nodes/ConvertKit/ConvertKit.node.ts new file mode 100644 index 0000000000..71f58a4172 --- /dev/null +++ b/packages/nodes-base/nodes/ConvertKit/ConvertKit.node.ts @@ -0,0 +1,289 @@ +import { + IExecuteFunctions, +} from 'n8n-core'; + +import { + IDataObject, + INodeExecutionData, + INodeTypeDescription, + INodeType, +} from 'n8n-workflow'; + +import { + convertKitApiRequest, +} from './GenericFunctions'; + +import { + fieldOperations, + fieldFields, +} from './FieldDescription'; + +import { + formOperations, + formFields, +} from './FormDescription'; + +import { + sequenceOperations, + sequenceFields, +} from './SequenceDescription'; + +import { + tagOperations, + tagFields, +} from './TagDescription'; + +export class ConvertKit implements INodeType { + description: INodeTypeDescription = { + displayName: 'ConvertKit', + name: 'convertKit', + icon: 'file:convertKit.png', + group: ['input'], + version: 1, + subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', + description: 'Consume ConvertKit API.', + defaults: { + name: 'ConvertKit', + color: '#fb6970', + }, + inputs: ['main'], + outputs: ['main'], + credentials: [ + { + name: 'convertKitApi', + required: true, + } + ], + properties: [ + { + displayName: 'Resource', + name: 'resource', + type: 'options', + options: [ + { + name: 'Field', + value: 'field', + }, + { + name: 'Form', + value: 'form', + }, + { + name: 'Sequence', + value: 'sequence', + }, + { + name: 'Tag', + value: 'tag', + }, + ], + default: 'field', + description: 'The resource to operate on.' + }, + //-------------------- + // Field Description + //-------------------- + ...fieldOperations, + ...fieldFields, + //-------------------- + // FormDescription + //-------------------- + ...formOperations, + ...formFields, + //-------------------- + // Sequence Description + //-------------------- + ...sequenceOperations, + ...sequenceFields, + //-------------------- + // Tag Description + //-------------------- + ...tagOperations, + ...tagFields, + ], + }; + + async execute(this: IExecuteFunctions): Promise { + const items = this.getInputData(); + const returnData: IDataObject[] = []; + + let method = ''; + let endpoint = ''; + const qs: IDataObject = {}; + let responseData; + + const resource = this.getNodeParameter('resource', 0) as string; + const operation = this.getNodeParameter('operation', 0) as string; + + const fullOperation = `${resource}/${operation}`; + + for (let i = 0; i < items.length; i++) { + //-------------------- + // Field Operations + //-------------------- + if(resource === 'field') { + //--------- + // Update + //--------- + if(operation === 'update') { + qs.label = this.getNodeParameter('label', i) as string; + + const id = this.getNodeParameter('id', i) as string; + + method = 'PUT'; + endpoint = `/custom_fields/${id}`; + //--------- + // Get All + //--------- + } else if(operation === 'getAll') { + method = 'GET'; + endpoint = '/custom_fields'; + //--------- + // Create + //--------- + } else if(operation === 'create') { + qs.label = this.getNodeParameter('label', i) as string; + + method = 'POST'; + endpoint = '/custom_fields'; + //--------- + // Delete + //--------- + } else if(operation === 'delete') { + const id = this.getNodeParameter('id', i) as string; + + method = 'DELETE'; + endpoint = `/custom_fields/${id}`; + } else { + throw new Error(`The operation "${operation}" is not known!`); + } + //-------------------------------------------- + // Form, Sequence, and Tag Operations + //-------------------------------------------- + } else if(['form', 'sequence', 'tag'].includes(resource)) { + //----------------- + // Add Subscriber + //----------------- + if(operation === 'addSubscriber') { + qs.email= this.getNodeParameter('email', i) as string; + const id = this.getNodeParameter('id', i); + + const additionalParams = this.getNodeParameter('additionalFields', 0) as IDataObject; + + if(additionalParams.firstName) { + qs.first_name = additionalParams.firstName; + } + + if(additionalParams.fields !== undefined) { + const fields = {} as IDataObject; + const fieldsParams = additionalParams.fields as IDataObject; + const field = fieldsParams?.field as IDataObject[]; + + for(let j = 0; j < field.length; j++) { + const key = field[j].key as string; + const value = field[j].value as string; + + fields[key] = value; + } + + qs.fields = fields; + } + + if(resource === 'form') { + method = 'POST'; + endpoint = `/forms/${id}/subscribe`; + } else if(resource === 'sequence') { + method = 'POST'; + endpoint = `/sequences/${id}/subscribe`; + } else if(resource === 'tag') { + method = 'POST'; + endpoint = `/tags/${id}/subscribe`; + } + //----------------- + // Get All + //----------------- + } else if(operation === 'getAll') { + method = 'GET'; + if(resource === 'form') { + endpoint = '/forms'; + } else if(resource === 'tag') { + endpoint = '/tags'; + } else if(resource === 'sequence') { + endpoint = '/sequences'; + } + //-------------------- + // Get Subscriptions + //-------------------- + } else if(operation === 'getSubscriptions') { + const id = this.getNodeParameter('id', i); + const additionalParams = this.getNodeParameter('additionalFields', 0) as IDataObject; + if(additionalParams.subscriberState) { + qs.subscriber_state = additionalParams.subscriberState; + } + + method = 'GET'; + if(resource === 'form') { + endpoint = `/forms/${id}/subscriptions`; + } else if(resource === 'tag') { + endpoint = `/tags/${id}/subscriptions`; + } else if(resource === 'sequence') { + endpoint = `/sequences/${id}/subscriptions`; + } + //------------ + // Create Tag + //------------ + } else if(operation === 'create') { + const name = this.getNodeParameter('name', i); + qs.tag = { name, }; + + method = 'POST'; + endpoint = '/tags'; + //------------ + // Remove Tag + //------------ + } else if(operation === 'removeSubscriber') { + const id = this.getNodeParameter('id', i); + + qs.email = this.getNodeParameter('email', i); + + method = 'POST'; + endpoint = `/tags/${id}/unsubscribe`; + } else { + throw new Error(`The operation "${operation}" is not known!`); + } + } else { + throw new Error(`The resource "${resource}" is not known!`); + } + + responseData = await convertKitApiRequest.call(this, method, endpoint, {}, qs); + + if(fullOperation === 'field/getAll') { + responseData = responseData.custom_fields; + } else if(['form/addSubscriber', 'tag/addSubscriber', 'sequence/addSubscriber'].includes(fullOperation)) { + responseData = responseData.subscription; + } else if(fullOperation === 'form/getAll') { + responseData = responseData.forms; + } else if(['form/getSubscriptions', 'tag/getSubscriptions'].includes(fullOperation)) { + responseData = responseData.subscriptions; + } else if(fullOperation === 'tag/getAll') { + responseData = responseData.tags; + } else if(fullOperation === 'sequence/getAll') { + responseData = responseData.courses; + } + + if (Array.isArray(responseData)) { + returnData.push.apply(returnData, responseData as IDataObject[]); + } else if (responseData !== undefined) { + returnData.push(responseData as IDataObject); + } else { + if(method === 'GET') { + returnData.push( { } ); + } else { + returnData.push( { success: true } ); + } + } + } + + return [this.helpers.returnJsonArray(returnData)]; + } +} diff --git a/packages/nodes-base/nodes/ConvertKit/ConvertKitTrigger.node.ts b/packages/nodes-base/nodes/ConvertKit/ConvertKitTrigger.node.ts new file mode 100644 index 0000000000..5b1c6c2274 --- /dev/null +++ b/packages/nodes-base/nodes/ConvertKit/ConvertKitTrigger.node.ts @@ -0,0 +1,163 @@ +import { + IHookFunctions, + IWebhookFunctions, +} from 'n8n-core'; + +import { + IDataObject, + INodeTypeDescription, + INodeType, + IWebhookResponseData, +} from 'n8n-workflow'; + +import { + convertKitApiRequest, +} from './GenericFunctions'; + + +export class ConvertKitTrigger implements INodeType { + description: INodeTypeDescription = { + displayName: 'ConvertKit Trigger', + name: 'convertKitTrigger', + icon: 'file:convertKit.png', + subtitle: '={{$parameter["event"]}}', + group: ['trigger'], + version: 1, + description: 'Handle ConvertKit events via webhooks', + defaults: { + name: 'ConvertKit Trigger', + color: '#fb6970', + }, + inputs: [], + outputs: ['main'], + credentials: [ + { + name: 'convertKitApi', + required: true, + } + ], + webhooks: [ + { + name: 'default', + httpMethod: 'POST', + responseMode: 'onReceived', + path: 'webhook', + }, + ], + properties: [ + { + displayName: 'Event', + name: 'event', + type: 'options', + required: true, + default: 'subscriberActivated', + description: 'The events that can trigger the webhook and whether they are enabled.', + options: [ + { + name: 'Subscriber Activated', + value: 'subscriberActivated', + description: 'Whether the webhook is triggered when a subscriber is activated.', + }, + { + name: 'Link Clicked', + value: 'linkClicked', + description: 'Whether the webhook is triggered when a link is clicked.', + }, + ], + }, + { + displayName: 'Initiating Link', + name: 'link', + type: 'string', + required: true, + default: '', + description: 'The URL of the initiating link', + displayOptions: { + show: { + event: [ + 'linkClicked', + ], + }, + }, + }, + ], + }; + + // @ts-ignore (because of request) + webhookMethods = { + default: { + async checkExists(this: IHookFunctions): Promise { + const webhookData = this.getWorkflowStaticData('node'); + + if(webhookData.webhookId) { + return true; + } + return false; + }, + + async create(this: IHookFunctions): Promise { + let webhook; + const webhookUrl = this.getNodeWebhookUrl('default'); + const event = this.getNodeParameter('event', 0); + const endpoint = '/automations/hooks'; + + const qs: IDataObject = {}; + + try { + qs.target_url = webhookUrl; + + if(event === 'subscriberActivated') { + qs.event = { + name: 'subscriber.subscriber_activate', + }; + } else if(event === 'linkClicked') { + const link = this.getNodeParameter('link', 0) as string; + qs.event = { + name: 'subscriber.link_click', + initiator_value: link, + }; + } + webhook = await convertKitApiRequest.call(this, 'POST', endpoint, {}, qs); + } catch (error) { + throw error; + } + + if (webhook.rule.id === undefined) { + return false; + } + + const webhookData = this.getWorkflowStaticData('node'); + webhookData.webhookId = webhook.rule.id as string; + webhookData.events = event; + return true; + }, + + async delete(this: IHookFunctions): Promise { + const webhookData = this.getWorkflowStaticData('node'); + if (webhookData.webhookId !== undefined) { + const endpoint = `/automations/hooks/${webhookData.webhookId}`; + try { + await convertKitApiRequest.call(this, 'DELETE', endpoint, {}, {}); + } catch (error) { + return false; + } + delete webhookData.webhookId; + delete webhookData.events; + } + return true; + }, + }, + }; + + + async webhook(this: IWebhookFunctions): Promise { + const returnData: IDataObject[] = []; + returnData.push(this.getBodyData()); + + return { + workflowData: [ + this.helpers.returnJsonArray(returnData), + ], + }; + } +} diff --git a/packages/nodes-base/nodes/ConvertKit/FieldDescription.ts b/packages/nodes-base/nodes/ConvertKit/FieldDescription.ts new file mode 100644 index 0000000000..8966e60efa --- /dev/null +++ b/packages/nodes-base/nodes/ConvertKit/FieldDescription.ts @@ -0,0 +1,83 @@ +import { + INodeProperties +} from 'n8n-workflow'; + +export const fieldOperations = [ + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'field', + ], + }, + }, + options: [ + { + name: 'Create', + value: 'create', + description: 'Create a field.', + }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a field.', + }, + { + name: 'Get All', + value: 'getAll', + description: `List all of your account's custom fields.`, + }, + { + name: 'Update', + value: 'update', + description: 'Update a field.', + }, + ], + default: 'update', + description: 'The operation to perform.', + }, +] as INodeProperties[]; + +export const fieldFields = [ + { + displayName: 'Field ID', + name: 'id', + type: 'string', + required: true, + displayOptions: { + show: { + resource: [ + 'field', + ], + operation: [ + 'update', + 'delete', + ], + }, + }, + default: '', + description: 'The ID of your custom field.', + }, + { + displayName: 'Label', + name: 'label', + type: 'string', + required: true, + displayOptions: { + show: { + resource: [ + 'field', + ], + operation: [ + 'update', + 'create', + ], + }, + }, + default: '', + description: 'The label of the custom field.', + }, +] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/ConvertKit/FormDescription.ts b/packages/nodes-base/nodes/ConvertKit/FormDescription.ts new file mode 100644 index 0000000000..3e266d18a5 --- /dev/null +++ b/packages/nodes-base/nodes/ConvertKit/FormDescription.ts @@ -0,0 +1,174 @@ +import { + INodeProperties +} from 'n8n-workflow'; + +export const formOperations = [ + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'form', + ], + }, + }, + options: [ + { + name: 'Add Subscriber', + value: 'addSubscriber', + description: 'Add a subscriber.', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Get a list of all the forms for your account.', + }, + { + name: 'Get Subscriptions', + value: 'getSubscriptions', + description: 'List subscriptions to a form including subscriber data.', + }, + ], + default: 'addSubscriber', + description: 'The operations to perform.', + }, +] as INodeProperties[]; + +export const formFields = [ + { + displayName: 'Email Address', + name: 'email', + type: 'string', + required: true, + displayOptions: { + show: { + resource: [ + 'form', + ], + operation: [ + 'addSubscriber', + ], + }, + }, + default: '', + description: `The subscriber's email address.`, + }, + { + displayName: 'Form ID', + name: 'id', + type: 'string', + required: true, + displayOptions: { + show: { + resource: [ + 'form', + ], + operation: [ + 'addSubscriber', + 'getSubscriptions', + ], + }, + }, + default: '', + description: 'Form ID.', + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + resource: [ + 'form', + ], + operation: [ + 'addSubscriber', + ], + }, + }, + options: [ + { + displayName: 'First Name', + name: 'firstName', + type: 'string', + default: '', + description: `The subscriber's first name.`, + }, + { + displayName: 'Custom Fields', + name: 'fields', + placeholder: 'Add Custom Field', + description: 'Object of key/value pairs for custom fields (the custom field must exist before you can use it here).', + type: 'fixedCollection', + typeOptions: { + multipleValues: true, + }, + default: {}, + options: [ + { + name: 'field', + displayName: 'Custom Field', + values: [ + { + displayName: 'Field Key', + name: 'key', + type: 'string', + default: '', + placeholder: 'last_name', + description: `The field's key.`, + }, + { + displayName: 'Field Value', + name: 'value', + type: 'string', + default: '', + placeholder: 'Doe', + description: 'Value of the field.', + }, + ], + }, + ], + }, + ], + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + resource: [ + 'form', + ], + operation: [ + 'getSubscriptions', + ], + }, + }, + options: [ + { + displayName: 'Subscriber State', + name: 'subscriberState', + type: 'options', + options: [ + { + name: 'Active', + value: 'active', + }, + { + name: 'Cancelled', + value: 'cancelled', + }, + ], + default: 'active', + }, + ], + description: 'Receive only active subscribers or cancelled subscribers.', + }, +] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts b/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts new file mode 100644 index 0000000000..525aed043a --- /dev/null +++ b/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts @@ -0,0 +1,44 @@ +import { + OptionsWithUri +} from 'request'; + +import { + IExecuteFunctions, + ILoadOptionsFunctions, + IExecuteSingleFunctions, +} from 'n8n-core'; + +import { + IDataObject, + IHookFunctions +} from 'n8n-workflow'; + +export async function convertKitApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions, + method: string, endpoint: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any + const credentials = this.getCredentials('convertKitApi'); + if (credentials === undefined) { + throw new Error('No credentials got returned!'); + } + + let options: OptionsWithUri = { + headers: { + 'Content-Type': 'application/json', + }, + method, + qs, + body, + uri: uri ||`https://api.convertkit.com/v3${endpoint}`, + json: true, + }; + options = Object.assign({}, options, option); + if (Object.keys(options.body).length === 0) { + delete options.body; + } + try { + qs.api_secret = credentials.apiSecret; + + return await this.helpers.request!(options); + } catch (error) { + throw new Error(`ConvertKit error response: ${error.message}`); + } +} diff --git a/packages/nodes-base/nodes/ConvertKit/SequenceDescription.ts b/packages/nodes-base/nodes/ConvertKit/SequenceDescription.ts new file mode 100644 index 0000000000..1b82b741fa --- /dev/null +++ b/packages/nodes-base/nodes/ConvertKit/SequenceDescription.ts @@ -0,0 +1,174 @@ +import { + INodeProperties +} from 'n8n-workflow'; + +export const sequenceOperations = [ + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'sequence', + ], + }, + }, + options: [ + { + name: 'Add Subscriber', + value: 'addSubscriber', + description: 'Add a subscriber.', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Returns a list of sequences for the account.', + }, + { + name: 'Get Subscriptions', + value: 'getSubscriptions', + description: 'List subscriptions to a sequence including subscriber data.', + }, + ], + default: 'addSubscriber', + description: 'The operations to perform.', + }, +] as INodeProperties[]; + +export const sequenceFields = [ + { + displayName: 'Email Address', + name: 'email', + type: 'string', + required: true, + displayOptions: { + show: { + resource: [ + 'sequence', + ], + operation: [ + 'addSubscriber', + ], + }, + }, + default: '', + description: `The subscriber's email address.`, + }, + { + displayName: 'Sequence ID', + name: 'id', + type: 'string', + required: true, + displayOptions: { + show: { + resource: [ + 'sequence', + ], + operation: [ + 'addSubscriber', + 'getSubscriptions', + ], + }, + }, + default: '', + description: 'Sequence ID.', + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + resource: [ + 'sequence', + ], + operation: [ + 'addSubscriber', + ], + }, + }, + options: [ + { + displayName: 'First Name', + name: 'firstName', + type: 'string', + default: '', + description: `The subscriber's first name.`, + }, + { + displayName: 'Custom Fields', + name: 'fields', + placeholder: 'Add Custom Field', + description: 'Object of key/value pairs for custom fields (the custom field must exist before you can use it here).', + type: 'fixedCollection', + typeOptions: { + multipleValues: true, + }, + default: {}, + options: [ + { + name: 'field', + displayName: 'Custom Field', + values: [ + { + displayName: 'Field Key', + name: 'key', + type: 'string', + default: '', + placeholder: 'last_name', + description: `The field's key.`, + }, + { + displayName: 'Field Value', + name: 'value', + type: 'string', + default: '', + placeholder: 'Doe', + description: 'Value of the field.', + }, + ], + }, + ], + }, + ], + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + resource: [ + 'sequence', + ], + operation: [ + 'getSubscriptions', + ], + }, + }, + options: [ + { + displayName: 'Subscriber State', + name: 'subscriberState', + type: 'options', + options: [ + { + name: 'Active', + value: 'active', + }, + { + name: 'Cancelled', + value: 'cancelled', + }, + ], + default: 'active', + }, + ], + description: 'Receive only active subscribers or cancelled subscribers.', + }, +] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/ConvertKit/TagDescription.ts b/packages/nodes-base/nodes/ConvertKit/TagDescription.ts new file mode 100644 index 0000000000..a1a718ba3c --- /dev/null +++ b/packages/nodes-base/nodes/ConvertKit/TagDescription.ts @@ -0,0 +1,204 @@ +import { + INodeProperties +} from 'n8n-workflow'; + +export const tagOperations = [ + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'tag', + ], + }, + }, + options: [ + { + name: 'Create', + value: 'create', + description: 'Create a tag.', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Returns a list of tags for the account.', + }, + { + name: 'Get Subscriptions', + value: 'getSubscriptions', + description: 'List subscriptions to a tag including subscriber data.', + }, + { + name: 'Remove Subscriber', + value: 'removeSubscriber', + description: 'Remove a tag from a subscriber.', + }, + { + name: 'Add Subscriber', + value: 'addSubscriber', + description: 'Add a tag to a subscriber.', + }, + ], + default: 'create', + description: 'The operation to perform.', + }, +] as INodeProperties[]; + +export const tagFields = [ + { + displayName: 'Name', + name: 'name', + type: 'string', + required: true, + displayOptions: { + show: { + resource: [ + 'tag', + ], + operation: [ + 'create', + ], + }, + }, + default: '', + description: 'Tag name.', + }, + { + displayName: 'Email Address', + name: 'email', + type: 'string', + required: true, + displayOptions: { + show: { + resource: [ + 'tag', + ], + operation: [ + 'addSubscriber', + 'removeSubscriber', + ], + }, + }, + default: '', + description: 'Subscriber email address.', + }, + { + displayName: 'Tag ID', + name: 'id', + type: 'string', + required: true, + displayOptions: { + show: { + resource: [ + 'tag', + ], + operation: [ + 'addSubscriber', + 'removeSubscriber', + 'getSubscriptions', + ], + }, + }, + default: '', + description: 'Tag ID.', + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + resource: [ + 'tag', + ], + operation: [ + 'addSubscriber', + ], + }, + }, + options: [ + { + displayName: 'First Name', + name: 'firstName', + type: 'string', + default: '', + description: 'Subscriber first name.', + }, + { + displayName: 'Custom Fields', + name: 'fields', + placeholder: 'Add Custom Field', + description: 'Object of key/value pairs for custom fields (the custom field must exist before you can use it here).', + type: 'fixedCollection', + typeOptions: { + multipleValues: true, + }, + default: {}, + options: [ + { + name: 'field', + displayName: 'Custom Field', + values: [ + { + displayName: 'Field Key', + name: 'key', + type: 'string', + default: '', + placeholder: 'last_name', + description: `The field's key.`, + }, + { + displayName: 'Field Value', + name: 'value', + type: 'string', + default: '', + placeholder: 'Doe', + description: 'Value of the field.', + }, + ], + }, + ], + }, + ], + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + resource: [ + 'tag', + ], + operation: [ + 'getSubscriptions', + ], + }, + }, + options: [ + { + displayName: 'Subscriber State', + name: 'subscriberState', + type: 'options', + options: [ + { + name: 'Active', + value: 'active', + }, + { + name: 'Cancelled', + value: 'cancelled', + }, + ], + default: 'active', + }, + ], + description: 'Receive only active subscribers or cancelled subscribers.', + }, +] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/ConvertKit/convertKit.png b/packages/nodes-base/nodes/ConvertKit/convertKit.png new file mode 100644 index 0000000000000000000000000000000000000000..2dc9cf3ee52a2d64f636c43724bc9d1b81cb6372 GIT binary patch literal 4958 zcmY*-cRU+j_kZlIM(t61)d;GHStIt2ik-v^5g}%kYEiRhXwA|@soF}-8c|ynt?}5@ zXlWI#O~3kip5OEPe(&pb?mg$+_j$k1xqse7OLGGTT5ehZ0Ki~msAqk3s{b`=%Bvl8 zJ{x#-kYKG1bO6;Kc)wl+G#EpBEC4{q`qxMRc?FzT0DB|^8U!^n1-beA$->?J5gxK( zewZut6;l}K%JuUIf(wNCq0m@Rn1;|l2+)=PH!UY5@DC)&S3?MDW+|ZSALt>VBzsF1 zD5Oa%ARwR~={G-THr4)9N`}vq#-2qSLna%-+cxlJ^#NF8vCEI zt_GC*dm|?=3zYjW_f@I--z>-?5b1HH{Fh%-Ui}~B|H=JFM_ul(`2T9=-;@56y&6@M zR$cDD&!$Oh+9Pfc05BIB>D_^NQ;a(LqMY8d6}5~lG-jn!rE@X~6qkRYDt+-rpF#bxmOH#x2C0QC|z@R7vU4El3=e`j<`40P&2mF@nyEX0`-*sndttBcWXnG zC4i?mnZqP^X{`1#U{`%zudFxcyh3JOvX0$Vdovlx+W^p7gXScxa@N02PCs4H89FNc zR72y}0i(NkG5_fZP5X}f;!Wi^7EHpEF}&#vV3U1tYF6Y{GKxLan2whc;rVbxV4pQ?gm6nv3=(kGXEMxTtWm{1ySn?)HSB z=2(m5Vyy{#9ESaci#@vh0v|oSBESGQKUJ8t7#ZHqHMH_O$k%zeRp*$CnZrQ8GWcQ2 z+UBZPX(5YQBQB>QML2es>DuLe@vKIDUK%!X3#7@?H$Uhfmi;)Fx}K+GWM5$luYD>A z&W$>F(?=ARcqfRLvYy@H+^mx$mp6U!gswPmI&xP=GK;eqqH|w7zu}WN3E;QPkC(sS z@|<>b%tGd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