UNPKG

n8n-nodes-instantly-dev

Version:

n8n community node for Instantly API v2

115 lines 5.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OperationRouter = void 0; const AccountOperations_1 = require("./AccountOperations"); const CampaignOperations_1 = require("./CampaignOperations"); const LeadOperations_1 = require("./LeadOperations"); const AnalyticsOperations_1 = require("./AnalyticsOperations"); /** * Main operation router that delegates to specific resource handlers */ class OperationRouter { /** * Route operation to appropriate handler based on resource and operation type */ static async execute(context, itemIndex, resource, operation) { switch (resource) { case 'account': return await this.handleAccountOperation(context, itemIndex, operation); case 'campaign': return await this.handleCampaignOperation(context, itemIndex, operation); case 'lead': return await this.handleLeadOperation(context, itemIndex, operation); case 'analytics': return await this.handleAnalyticsOperation(context, itemIndex, operation); default: throw new Error(`Unknown resource: ${resource}`); } } /** * Handle account operations */ static async handleAccountOperation(context, itemIndex, operation) { switch (operation) { case 'getMany': return await AccountOperations_1.AccountOperations.getMany(context, itemIndex); case 'get': return await AccountOperations_1.AccountOperations.get(context, itemIndex); case 'pause': return await AccountOperations_1.AccountOperations.pause(context, itemIndex); case 'resume': return await AccountOperations_1.AccountOperations.resume(context, itemIndex); case 'update': return await AccountOperations_1.AccountOperations.update(context, itemIndex); case 'create': return await AccountOperations_1.AccountOperations.create(context, itemIndex); case 'deleteAccount': return await AccountOperations_1.AccountOperations.deleteAccount(context, itemIndex); case 'enableWarmup': return await AccountOperations_1.AccountOperations.enableWarmup(context, itemIndex); case 'disableWarmup': return await AccountOperations_1.AccountOperations.disableWarmup(context, itemIndex); default: throw new Error(`Unknown account operation: ${operation}`); } } /** * Handle campaign operations */ static async handleCampaignOperation(context, itemIndex, operation) { switch (operation) { case 'create': return await CampaignOperations_1.CampaignOperations.create(context, itemIndex); case 'get': return await CampaignOperations_1.CampaignOperations.get(context, itemIndex); case 'getMany': return await CampaignOperations_1.CampaignOperations.getMany(context, itemIndex); case 'update': return await CampaignOperations_1.CampaignOperations.update(context, itemIndex); case 'delete': return await CampaignOperations_1.CampaignOperations.delete(context, itemIndex); case 'launch': return await CampaignOperations_1.CampaignOperations.launch(context, itemIndex); case 'pause': return await CampaignOperations_1.CampaignOperations.pause(context, itemIndex); default: throw new Error(`Unknown campaign operation: ${operation}`); } } /** * Handle lead operations */ static async handleLeadOperation(context, itemIndex, operation) { switch (operation) { case 'addToCampaign': return await LeadOperations_1.LeadOperations.addToCampaign(context, itemIndex); case 'create': return await LeadOperations_1.LeadOperations.create(context, itemIndex); case 'get': return await LeadOperations_1.LeadOperations.get(context, itemIndex); case 'getMany': return await LeadOperations_1.LeadOperations.getMany(context, itemIndex); case 'update': return await LeadOperations_1.LeadOperations.update(context, itemIndex); case 'delete': return await LeadOperations_1.LeadOperations.delete(context, itemIndex); case 'updateInterestStatus': return await LeadOperations_1.LeadOperations.updateInterestStatus(context, itemIndex); default: throw new Error(`Unknown lead operation: ${operation}`); } } /** * Handle analytics operations */ static async handleAnalyticsOperation(context, itemIndex, operation) { switch (operation) { case 'getCampaignAnalytics': return await AnalyticsOperations_1.AnalyticsOperations.getCampaignAnalytics(context, itemIndex); default: throw new Error(`Unknown analytics operation: ${operation}`); } } } exports.OperationRouter = OperationRouter; //# sourceMappingURL=OperationRouter.js.map