mirror of
https://github.com/n8n-io/n8n-nodes-starter.git
synced 2025-12-16 17:33:01 -06:00
Implement n8n node for Autosend API with support for: - Mail resource: Send single and bulk emails with template or custom content - Contact resource: Create/update contacts (upsert) and get contacts by ID or email - API key authentication - Declarative routing following n8n best practices - Full TypeScript support with proper typing - Passing all linting checks
71 lines
1.7 KiB
TypeScript
71 lines
1.7 KiB
TypeScript
import type {
|
|
INodeType,
|
|
INodeTypeDescription,
|
|
INodeExecutionData,
|
|
IExecuteFunctions,
|
|
} from 'n8n-workflow';
|
|
import { mailFields, mailOperations } from './resources/mail';
|
|
import { contactFields, contactOperations } from './resources/contact';
|
|
|
|
export class Autosend implements INodeType {
|
|
description: INodeTypeDescription = {
|
|
displayName: 'Autosend',
|
|
name: 'autosend',
|
|
icon: 'file:autosend.svg',
|
|
group: ['transform'],
|
|
version: 1,
|
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
description: 'Interact with Autosend API to send emails and manage contacts',
|
|
defaults: {
|
|
name: 'Autosend',
|
|
},
|
|
inputs: ['main'],
|
|
outputs: ['main'],
|
|
credentials: [
|
|
{
|
|
name: 'autosendApi',
|
|
required: true,
|
|
},
|
|
],
|
|
requestDefaults: {
|
|
baseURL: 'https://api.autosend.com',
|
|
headers: {
|
|
Accept: 'application/json',
|
|
'Content-Type': 'application/json',
|
|
},
|
|
},
|
|
properties: [
|
|
{
|
|
displayName: 'Resource',
|
|
name: 'resource',
|
|
type: 'options',
|
|
noDataExpression: true,
|
|
options: [
|
|
{
|
|
name: 'Mail',
|
|
value: 'mail',
|
|
description: 'Send emails using Autosend',
|
|
},
|
|
{
|
|
name: 'Contact',
|
|
value: 'contact',
|
|
description: 'Manage contacts in Autosend',
|
|
},
|
|
],
|
|
default: 'mail',
|
|
},
|
|
...mailOperations,
|
|
...mailFields,
|
|
...contactOperations,
|
|
...contactFields,
|
|
],
|
|
usableAsTool: true,
|
|
};
|
|
|
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
// This method is required but the declarative routing handles everything
|
|
// This is only called if routing doesn't handle the request
|
|
const items = this.getInputData();
|
|
return [items];
|
|
}
|
|
}
|