first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"node": "n8n-nodes-base.convertKit",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": ["Marketing", "Sales"],
|
||||
"resources": {
|
||||
"credentialDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/credentials/convertkit/"
|
||||
}
|
||||
],
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.convertkit/"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,494 @@
|
||||
import {
|
||||
type IExecuteFunctions,
|
||||
type ILoadOptionsFunctions,
|
||||
type IDataObject,
|
||||
type INodeExecutionData,
|
||||
type INodePropertyOptions,
|
||||
type INodeType,
|
||||
type INodeTypeDescription,
|
||||
NodeConnectionTypes,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { customFieldFields, customFieldOperations } from './CustomFieldDescription';
|
||||
import { formFields, formOperations } from './FormDescription';
|
||||
import { convertKitApiRequest } from './GenericFunctions';
|
||||
import { sequenceFields, sequenceOperations } from './SequenceDescription';
|
||||
import { tagFields, tagOperations } from './TagDescription';
|
||||
import { tagSubscriberFields, tagSubscriberOperations } from './TagSubscriberDescription';
|
||||
|
||||
export class ConvertKit implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'ConvertKit',
|
||||
name: 'convertKit',
|
||||
icon: 'file:convertKit.svg',
|
||||
group: ['input'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
description: 'Consume ConvertKit API',
|
||||
defaults: {
|
||||
name: 'ConvertKit',
|
||||
},
|
||||
usableAsTool: true,
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
credentials: [
|
||||
{
|
||||
name: 'convertKitApi',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
options: [
|
||||
{
|
||||
name: 'Custom Field',
|
||||
value: 'customField',
|
||||
},
|
||||
{
|
||||
name: 'Form',
|
||||
value: 'form',
|
||||
},
|
||||
{
|
||||
name: 'Sequence',
|
||||
value: 'sequence',
|
||||
},
|
||||
{
|
||||
name: 'Tag',
|
||||
value: 'tag',
|
||||
},
|
||||
{
|
||||
name: 'Tag Subscriber',
|
||||
value: 'tagSubscriber',
|
||||
},
|
||||
],
|
||||
default: 'form',
|
||||
},
|
||||
//--------------------
|
||||
// Field Description
|
||||
//--------------------
|
||||
...customFieldOperations,
|
||||
...customFieldFields,
|
||||
//--------------------
|
||||
// FormDescription
|
||||
//--------------------
|
||||
...formOperations,
|
||||
...formFields,
|
||||
//--------------------
|
||||
// Sequence Description
|
||||
//--------------------
|
||||
...sequenceOperations,
|
||||
...sequenceFields,
|
||||
//--------------------
|
||||
// Tag Description
|
||||
//--------------------
|
||||
...tagOperations,
|
||||
...tagFields,
|
||||
//--------------------
|
||||
// Tag Subscriber Description
|
||||
//--------------------
|
||||
...tagSubscriberOperations,
|
||||
...tagSubscriberFields,
|
||||
],
|
||||
};
|
||||
|
||||
methods = {
|
||||
loadOptions: {
|
||||
// Get all the tags to display them to user so that they can
|
||||
// select them easily
|
||||
async getTags(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { tags } = await convertKitApiRequest.call(this, 'GET', '/tags');
|
||||
for (const tag of tags) {
|
||||
const tagName = tag.name;
|
||||
const tagId = tag.id;
|
||||
returnData.push({
|
||||
name: tagName,
|
||||
value: tagId,
|
||||
});
|
||||
}
|
||||
|
||||
return returnData;
|
||||
},
|
||||
// Get all the forms to display them to user so that they can
|
||||
// select them easily
|
||||
async getForms(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { forms } = await convertKitApiRequest.call(this, 'GET', '/forms');
|
||||
for (const form of forms) {
|
||||
const formName = form.name;
|
||||
const formId = form.id;
|
||||
returnData.push({
|
||||
name: formName,
|
||||
value: formId,
|
||||
});
|
||||
}
|
||||
|
||||
return returnData;
|
||||
},
|
||||
|
||||
// Get all the sequences to display them to user so that they can
|
||||
// select them easily
|
||||
async getSequences(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { courses } = await convertKitApiRequest.call(this, 'GET', '/sequences');
|
||||
for (const course of courses) {
|
||||
const courseName = course.name;
|
||||
const courseId = course.id;
|
||||
returnData.push({
|
||||
name: courseName,
|
||||
value: courseId,
|
||||
});
|
||||
}
|
||||
|
||||
return returnData;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
|
||||
const qs: IDataObject = {};
|
||||
let responseData;
|
||||
|
||||
const resource = this.getNodeParameter('resource', 0);
|
||||
const operation = this.getNodeParameter('operation', 0);
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
try {
|
||||
if (resource === 'customField') {
|
||||
if (operation === 'create') {
|
||||
const label = this.getNodeParameter('label', i) as string;
|
||||
|
||||
responseData = await convertKitApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
'/custom_fields',
|
||||
{ label },
|
||||
qs,
|
||||
);
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
const id = this.getNodeParameter('id', i) as string;
|
||||
|
||||
responseData = await convertKitApiRequest.call(this, 'DELETE', `/custom_fields/${id}`);
|
||||
}
|
||||
if (operation === 'get') {
|
||||
const id = this.getNodeParameter('id', i) as string;
|
||||
|
||||
responseData = await convertKitApiRequest.call(this, 'GET', `/custom_fields/${id}`);
|
||||
}
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
responseData = await convertKitApiRequest.call(this, 'GET', '/custom_fields');
|
||||
|
||||
responseData = responseData.custom_fields;
|
||||
|
||||
if (!returnAll) {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
|
||||
responseData = responseData.slice(0, limit);
|
||||
}
|
||||
}
|
||||
if (operation === 'update') {
|
||||
const id = this.getNodeParameter('id', i) as string;
|
||||
|
||||
const label = this.getNodeParameter('label', i) as string;
|
||||
|
||||
responseData = await convertKitApiRequest.call(this, 'PUT', `/custom_fields/${id}`, {
|
||||
label,
|
||||
});
|
||||
|
||||
responseData = { success: true };
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'form') {
|
||||
if (operation === 'addSubscriber') {
|
||||
const email = this.getNodeParameter('email', i) as string;
|
||||
|
||||
const formId = this.getNodeParameter('id', i) as string;
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
|
||||
const body: IDataObject = {
|
||||
email,
|
||||
};
|
||||
|
||||
if (additionalFields.firstName) {
|
||||
body.first_name = additionalFields.firstName as string;
|
||||
}
|
||||
|
||||
if (additionalFields.tags) {
|
||||
body.tags = additionalFields.tags as string[];
|
||||
}
|
||||
|
||||
if (additionalFields.fieldsUi) {
|
||||
const fieldValues = (additionalFields.fieldsUi as IDataObject)
|
||||
.fieldsValues as IDataObject[];
|
||||
if (fieldValues) {
|
||||
body.fields = {};
|
||||
for (const fieldValue of fieldValues) {
|
||||
//@ts-ignore
|
||||
body.fields[fieldValue.key] = fieldValue.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const { subscription } = await convertKitApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/forms/${formId}/subscribe`,
|
||||
body,
|
||||
);
|
||||
|
||||
responseData = subscription;
|
||||
}
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
responseData = await convertKitApiRequest.call(this, 'GET', '/forms');
|
||||
|
||||
responseData = responseData.forms;
|
||||
|
||||
if (!returnAll) {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
|
||||
responseData = responseData.slice(0, limit);
|
||||
}
|
||||
}
|
||||
if (operation === 'getSubscriptions') {
|
||||
const formId = this.getNodeParameter('id', i) as string;
|
||||
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
|
||||
if (additionalFields.subscriberState) {
|
||||
qs.subscriber_state = additionalFields.subscriberState as string;
|
||||
}
|
||||
|
||||
responseData = await convertKitApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/forms/${formId}/subscriptions`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
|
||||
responseData = responseData.subscriptions;
|
||||
|
||||
if (!returnAll) {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
|
||||
responseData = responseData.slice(0, limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'sequence') {
|
||||
if (operation === 'addSubscriber') {
|
||||
const email = this.getNodeParameter('email', i) as string;
|
||||
|
||||
const sequenceId = this.getNodeParameter('id', i) as string;
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
|
||||
const body: IDataObject = {
|
||||
email,
|
||||
};
|
||||
|
||||
if (additionalFields.firstName) {
|
||||
body.first_name = additionalFields.firstName as string;
|
||||
}
|
||||
|
||||
if (additionalFields.tags) {
|
||||
body.tags = additionalFields.tags as string[];
|
||||
}
|
||||
|
||||
if (additionalFields.fieldsUi) {
|
||||
const fieldValues = (additionalFields.fieldsUi as IDataObject)
|
||||
.fieldsValues as IDataObject[];
|
||||
if (fieldValues) {
|
||||
body.fields = {};
|
||||
for (const fieldValue of fieldValues) {
|
||||
//@ts-ignore
|
||||
body.fields[fieldValue.key] = fieldValue.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const { subscription } = await convertKitApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/sequences/${sequenceId}/subscribe`,
|
||||
body,
|
||||
);
|
||||
|
||||
responseData = subscription;
|
||||
}
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
responseData = await convertKitApiRequest.call(this, 'GET', '/sequences');
|
||||
|
||||
responseData = responseData.courses;
|
||||
|
||||
if (!returnAll) {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
|
||||
responseData = responseData.slice(0, limit);
|
||||
}
|
||||
}
|
||||
if (operation === 'getSubscriptions') {
|
||||
const sequenceId = this.getNodeParameter('id', i) as string;
|
||||
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
|
||||
if (additionalFields.subscriberState) {
|
||||
qs.subscriber_state = additionalFields.subscriberState as string;
|
||||
}
|
||||
|
||||
responseData = await convertKitApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/sequences/${sequenceId}/subscriptions`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
|
||||
responseData = responseData.subscriptions;
|
||||
|
||||
if (!returnAll) {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
|
||||
responseData = responseData.slice(0, limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'tag') {
|
||||
if (operation === 'create') {
|
||||
const names = (this.getNodeParameter('name', i) as string)
|
||||
.split(',')
|
||||
.map((e) => ({ name: e }));
|
||||
|
||||
const body: IDataObject = {
|
||||
tag: names,
|
||||
};
|
||||
|
||||
responseData = await convertKitApiRequest.call(this, 'POST', '/tags', body);
|
||||
}
|
||||
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
responseData = await convertKitApiRequest.call(this, 'GET', '/tags');
|
||||
|
||||
responseData = responseData.tags;
|
||||
|
||||
if (!returnAll) {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
|
||||
responseData = responseData.slice(0, limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'tagSubscriber') {
|
||||
if (operation === 'add') {
|
||||
const tagId = this.getNodeParameter('tagId', i) as string;
|
||||
|
||||
const email = this.getNodeParameter('email', i) as string;
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
|
||||
const body: IDataObject = {
|
||||
email,
|
||||
};
|
||||
|
||||
if (additionalFields.firstName) {
|
||||
body.first_name = additionalFields.firstName as string;
|
||||
}
|
||||
|
||||
if (additionalFields.fieldsUi) {
|
||||
const fieldValues = (additionalFields.fieldsUi as IDataObject)
|
||||
.fieldsValues as IDataObject[];
|
||||
if (fieldValues) {
|
||||
body.fields = {};
|
||||
for (const fieldValue of fieldValues) {
|
||||
//@ts-ignore
|
||||
body.fields[fieldValue.key] = fieldValue.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const { subscription } = await convertKitApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/tags/${tagId}/subscribe`,
|
||||
body,
|
||||
);
|
||||
|
||||
responseData = subscription;
|
||||
}
|
||||
|
||||
if (operation === 'getAll') {
|
||||
const tagId = this.getNodeParameter('tagId', i) as string;
|
||||
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
responseData = await convertKitApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/tags/${tagId}/subscriptions`,
|
||||
);
|
||||
|
||||
responseData = responseData.subscriptions;
|
||||
|
||||
if (!returnAll) {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
|
||||
responseData = responseData.slice(0, limit);
|
||||
}
|
||||
}
|
||||
|
||||
if (operation === 'delete') {
|
||||
const tagId = this.getNodeParameter('tagId', i) as string;
|
||||
|
||||
const email = this.getNodeParameter('email', i) as string;
|
||||
|
||||
responseData = await convertKitApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/tags/${tagId}>/unsubscribe`,
|
||||
{ email },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData as IDataObject[]),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ error: error.message, json: {} });
|
||||
continue;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return [returnData];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"node": "n8n-nodes-base.convertKitTrigger",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": ["Marketing", "Sales"],
|
||||
"resources": {
|
||||
"credentialDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/credentials/convertkit/"
|
||||
}
|
||||
],
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.convertkittrigger/"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,340 @@
|
||||
import { snakeCase } from 'change-case';
|
||||
import type {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWebhookResponseData,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeConnectionTypes } from 'n8n-workflow';
|
||||
|
||||
import { convertKitApiRequest } from './GenericFunctions';
|
||||
|
||||
export class ConvertKitTrigger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'ConvertKit Trigger',
|
||||
name: 'convertKitTrigger',
|
||||
icon: 'file:convertKit.svg',
|
||||
subtitle: '={{$parameter["event"]}}',
|
||||
group: ['trigger'],
|
||||
version: 1,
|
||||
description: 'Handle ConvertKit events via webhooks',
|
||||
defaults: {
|
||||
name: 'ConvertKit Trigger',
|
||||
},
|
||||
inputs: [],
|
||||
outputs: [NodeConnectionTypes.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: '',
|
||||
description: 'The events that can trigger the webhook and whether they are enabled',
|
||||
options: [
|
||||
{
|
||||
name: 'Form Subscribe',
|
||||
value: 'formSubscribe',
|
||||
},
|
||||
{
|
||||
name: 'Link Click',
|
||||
value: 'linkClick',
|
||||
},
|
||||
{
|
||||
name: 'Product Purchase',
|
||||
value: 'productPurchase',
|
||||
},
|
||||
{
|
||||
name: 'Purchase Created',
|
||||
value: 'purchaseCreate',
|
||||
},
|
||||
{
|
||||
name: 'Sequence Complete',
|
||||
value: 'courseComplete',
|
||||
},
|
||||
{
|
||||
name: 'Sequence Subscribe',
|
||||
value: 'courseSubscribe',
|
||||
},
|
||||
{
|
||||
name: 'Subscriber Activated',
|
||||
value: 'subscriberActivate',
|
||||
},
|
||||
{
|
||||
name: 'Subscriber Unsubscribe',
|
||||
value: 'subscriberUnsubscribe',
|
||||
},
|
||||
{
|
||||
name: 'Tag Add',
|
||||
value: 'tagAdd',
|
||||
},
|
||||
{
|
||||
name: 'Tag Remove',
|
||||
value: 'tagRemove',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Form Name or ID',
|
||||
name: 'formId',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getForms',
|
||||
},
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
event: ['formSubscribe'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Sequence Name or ID',
|
||||
name: 'courseId',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getSequences',
|
||||
},
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
event: ['courseSubscribe', 'courseComplete'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Initiating Link',
|
||||
name: 'link',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
description: 'The URL of the initiating link',
|
||||
displayOptions: {
|
||||
show: {
|
||||
event: ['linkClick'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Product ID',
|
||||
name: 'productId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
event: ['productPurchase'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Tag Name or ID',
|
||||
name: 'tagId',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTags',
|
||||
},
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
event: ['tagAdd', 'tagRemove'],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
methods = {
|
||||
loadOptions: {
|
||||
// Get all the tags to display them to user so that they can
|
||||
// select them easily
|
||||
async getTags(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
|
||||
const { tags } = await convertKitApiRequest.call(this, 'GET', '/tags');
|
||||
|
||||
for (const tag of tags) {
|
||||
const tagName = tag.name;
|
||||
|
||||
const tagId = tag.id;
|
||||
|
||||
returnData.push({
|
||||
name: tagName,
|
||||
value: tagId,
|
||||
});
|
||||
}
|
||||
|
||||
return returnData;
|
||||
},
|
||||
// Get all the forms to display them to user so that they can
|
||||
// select them easily
|
||||
async getForms(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
|
||||
const { forms } = await convertKitApiRequest.call(this, 'GET', '/forms');
|
||||
|
||||
for (const form of forms) {
|
||||
const formName = form.name;
|
||||
|
||||
const formId = form.id;
|
||||
|
||||
returnData.push({
|
||||
name: formName,
|
||||
value: formId,
|
||||
});
|
||||
}
|
||||
|
||||
return returnData;
|
||||
},
|
||||
|
||||
// Get all the sequences to display them to user so that they can
|
||||
// select them easily
|
||||
async getSequences(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
|
||||
const { courses } = await convertKitApiRequest.call(this, 'GET', '/sequences');
|
||||
|
||||
for (const course of courses) {
|
||||
const courseName = course.name;
|
||||
|
||||
const courseId = course.id;
|
||||
|
||||
returnData.push({
|
||||
name: courseName,
|
||||
value: courseId,
|
||||
});
|
||||
}
|
||||
|
||||
return returnData;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
|
||||
// THe API does not have an endpoint to list all webhooks
|
||||
|
||||
if (webhookData.webhookId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
async create(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
|
||||
let event = this.getNodeParameter('event', 0) as string;
|
||||
|
||||
const endpoint = '/automations/hooks';
|
||||
|
||||
if (event === 'purchaseCreate') {
|
||||
event = `purchase.${snakeCase(event)}`;
|
||||
} else {
|
||||
event = `subscriber.${snakeCase(event)}`;
|
||||
}
|
||||
|
||||
const body: IDataObject = {
|
||||
target_url: webhookUrl as string,
|
||||
event: {
|
||||
name: event,
|
||||
},
|
||||
};
|
||||
|
||||
if (event === 'subscriber.form_subscribe') {
|
||||
//@ts-ignore
|
||||
body.event.form_id = this.getNodeParameter('formId', 0);
|
||||
}
|
||||
|
||||
if (event === 'subscriber.course_subscribe' || event === 'subscriber.course_complete') {
|
||||
//@ts-ignore
|
||||
body.event.sequence_id = this.getNodeParameter('courseId', 0);
|
||||
}
|
||||
|
||||
if (event === 'subscriber.link_click') {
|
||||
//@ts-ignore
|
||||
body.event.initiator_value = this.getNodeParameter('link', 0);
|
||||
}
|
||||
|
||||
if (event === 'subscriber.product_purchase') {
|
||||
//@ts-ignore
|
||||
body.event.product_id = this.getNodeParameter('productId', 0);
|
||||
}
|
||||
|
||||
if (event === 'subscriber.tag_add' || event === 'subscriber.tag_remove') {
|
||||
//@ts-ignore
|
||||
body.event.tag_id = this.getNodeParameter('tagId', 0);
|
||||
}
|
||||
|
||||
const webhook = await convertKitApiRequest.call(this, 'POST', endpoint, body);
|
||||
|
||||
if (webhook.rule.id === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
|
||||
webhookData.webhookId = webhook.rule.id as string;
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
async delete(this: IHookFunctions): Promise<boolean> {
|
||||
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;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||
const returnData: IDataObject[] = [];
|
||||
returnData.push(this.getBodyData());
|
||||
|
||||
return {
|
||||
workflowData: [this.helpers.returnJsonArray(returnData)],
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const customFieldOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['customField'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a field',
|
||||
action: 'Create a custom field',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete a field',
|
||||
action: 'Delete a custom field',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many fields',
|
||||
action: 'Get many custom fields',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a field',
|
||||
action: 'Update a custom field',
|
||||
},
|
||||
],
|
||||
default: 'update',
|
||||
},
|
||||
];
|
||||
|
||||
export const customFieldFields: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Field ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['customField'],
|
||||
operation: ['update', 'delete'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The ID of your custom field',
|
||||
},
|
||||
{
|
||||
displayName: 'Label',
|
||||
name: 'label',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['customField'],
|
||||
operation: ['update', 'create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The label of the custom field',
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['customField'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['customField'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 500,
|
||||
},
|
||||
default: 100,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,194 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const formOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['form'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Add Subscriber',
|
||||
value: 'addSubscriber',
|
||||
description: 'Add a subscriber',
|
||||
action: 'Add a subscriber',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many forms',
|
||||
action: 'Get many forms',
|
||||
},
|
||||
{
|
||||
name: 'Get Subscriptions',
|
||||
value: 'getSubscriptions',
|
||||
description: 'List subscriptions to a form including subscriber data',
|
||||
action: 'Get all subscriptions',
|
||||
},
|
||||
],
|
||||
default: 'addSubscriber',
|
||||
description: 'The operations to perform',
|
||||
},
|
||||
];
|
||||
|
||||
export const formFields: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Form Name or ID',
|
||||
name: 'id',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getForms',
|
||||
},
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['form'],
|
||||
operation: ['addSubscriber', 'getSubscriptions'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
type: 'string',
|
||||
placeholder: 'name@email.com',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['form'],
|
||||
operation: ['addSubscriber'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: "The subscriber's email address",
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['form'],
|
||||
operation: ['addSubscriber'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Custom Fields',
|
||||
name: 'fieldsUi',
|
||||
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: 'fieldsValues',
|
||||
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: 'First Name',
|
||||
name: 'firstName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: "The subscriber's first name",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll', 'getSubscriptions'],
|
||||
resource: ['form'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll', 'getSubscriptions'],
|
||||
resource: ['form'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 500,
|
||||
},
|
||||
default: 100,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
{
|
||||
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',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,47 @@
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
IHttpRequestMethods,
|
||||
IHttpRequestOptions,
|
||||
ILoadOptionsFunctions,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function convertKitApiRequest(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
body: any = {},
|
||||
qs: IDataObject = {},
|
||||
url?: string,
|
||||
option: IDataObject = {},
|
||||
): Promise<any> {
|
||||
let options: IHttpRequestOptions = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method,
|
||||
qs,
|
||||
body,
|
||||
url: url || `https://api.convertkit.com/v3${endpoint}`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
options = Object.assign({}, options, option);
|
||||
|
||||
if (Object.keys(options.body as IDataObject).length === 0) {
|
||||
delete options.body;
|
||||
}
|
||||
|
||||
if (Object.keys(options.qs as IDataObject).length === 0) {
|
||||
delete options.qs;
|
||||
}
|
||||
|
||||
try {
|
||||
return await this.helpers.httpRequestWithAuthentication.call(this, 'convertKitApi', options);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const sequenceOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['sequence'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Add Subscriber',
|
||||
value: 'addSubscriber',
|
||||
description: 'Add a subscriber',
|
||||
action: 'Add a subscriber',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many sequences',
|
||||
action: 'Get many sequences',
|
||||
},
|
||||
{
|
||||
name: 'Get Subscriptions',
|
||||
value: 'getSubscriptions',
|
||||
description: 'Get all subscriptions to a sequence including subscriber data',
|
||||
action: 'Get all subscriptions to a sequence',
|
||||
},
|
||||
],
|
||||
default: 'addSubscriber',
|
||||
description: 'The operations to perform',
|
||||
},
|
||||
];
|
||||
|
||||
export const sequenceFields: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Sequence Name or ID',
|
||||
name: 'id',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getSequences',
|
||||
},
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['sequence'],
|
||||
operation: ['addSubscriber', 'getSubscriptions'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
type: 'string',
|
||||
placeholder: 'name@email.com',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['sequence'],
|
||||
operation: ['addSubscriber'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: "The subscriber's email address",
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll', 'getSubscriptions'],
|
||||
resource: ['sequence'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll', 'getSubscriptions'],
|
||||
resource: ['sequence'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 500,
|
||||
},
|
||||
default: 100,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['sequence'],
|
||||
operation: ['addSubscriber'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Custom Fields',
|
||||
name: 'fieldsUi',
|
||||
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: 'fieldsValues',
|
||||
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: 'First Name',
|
||||
name: 'firstName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: "The subscriber's first name",
|
||||
},
|
||||
{
|
||||
displayName: 'Tag Names or IDs',
|
||||
name: 'tags',
|
||||
type: 'multiOptions',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTags',
|
||||
},
|
||||
default: [],
|
||||
description:
|
||||
'Tags. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
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',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,78 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const tagOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['tag'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a tag',
|
||||
action: 'Create a tag',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many tags',
|
||||
action: 'Get many tags',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
export const tagFields: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['tag'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Tag name, multiple can be added separated by comma',
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['tag'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['tag'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 500,
|
||||
},
|
||||
default: 100,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,193 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const tagSubscriberOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['tagSubscriber'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Add',
|
||||
value: 'add',
|
||||
description: 'Add a tag to a subscriber',
|
||||
action: 'Add a tag to a subscriber',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'List subscriptions to a tag including subscriber data',
|
||||
action: 'Get many tag subscriptions',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete a tag from a subscriber',
|
||||
action: 'Delete a tag from a subscriber',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
export const tagSubscriberFields: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Tag Name or ID',
|
||||
name: 'tagId',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTags',
|
||||
},
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['tagSubscriber'],
|
||||
operation: ['add', 'getAll', 'delete'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
type: 'string',
|
||||
placeholder: 'name@email.com',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['tagSubscriber'],
|
||||
operation: ['add', 'delete'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Subscriber email address',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['tagSubscriber'],
|
||||
operation: ['add'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
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: 'First Name',
|
||||
name: 'firstName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Subscriber first name',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['tagSubscriber'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['tagSubscriber'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 500,
|
||||
},
|
||||
default: 100,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['tagSubscriber'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
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',
|
||||
},
|
||||
];
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"referrer": {
|
||||
"type": "null"
|
||||
},
|
||||
"state": {
|
||||
"type": "string"
|
||||
},
|
||||
"subscribable_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"subscribable_type": {
|
||||
"type": "string"
|
||||
},
|
||||
"subscriber": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"email_address": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"state": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"version": 1
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"referrer": {
|
||||
"type": "null"
|
||||
},
|
||||
"source": {
|
||||
"type": "null"
|
||||
},
|
||||
"state": {
|
||||
"type": "string"
|
||||
},
|
||||
"subscribable_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"subscribable_type": {
|
||||
"type": "string"
|
||||
},
|
||||
"subscriber": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"email_address": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"state": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"version": 2
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="172" height="160" fill="none"><path fill="#FB6970" d="M82.72 126.316c29.77 0 52.78-22.622 52.78-50.526 0-26.143-21.617-42.106-35.935-42.106-19.945 0-35.93 14.084-38.198 34.988-.418 3.856-3.476 7.09-7.355 7.061-6.423-.046-15.746-.1-21.658-.08-2.555.008-4.669-2.065-4.543-4.618.89-18.123 6.914-35.07 18.402-48.087C58.976 8.488 77.561 0 99.565 0c36.969 0 71.869 33.786 71.869 75.79 0 46.508-38.312 84.21-87.927 84.21-35.384 0-71.021-23.258-83.464-55.775a.7.7 0 0 1-.03-.377c.165-.962.494-1.841.818-2.707.471-1.258.931-2.488.864-3.906l-.215-4.529a5.52 5.52 0 0 1 3.18-5.263l1.798-.842a6.98 6.98 0 0 0 3.912-5.075 6.99 6.99 0 0 1 6.887-5.736c5.282 0 9.875 3.515 11.59 8.512 8.307 24.212 21.511 42.014 53.873 42.014"/></svg>
|
||||
|
After Width: | Height: | Size: 765 B |
Reference in New Issue
Block a user