UNPKG

n8n-nodes-rd-station-crm

Version:

n8n community node for RD Station CRM: API v1 (private token) and API v2 (OAuth2) — contacts, deals, organizations, tasks, notes, pipelines, stages, products, custom fields, sources, campaigns, loss reasons, users, teams and a real webhook trigger.

102 lines 4.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RdStationCrm = void 0; const n8n_workflow_1 = require("n8n-workflow"); const actions_1 = require("./actions"); const loadOptions_1 = require("./methods/loadOptions"); const loadOptionsV2_1 = require("./methods/loadOptionsV2"); class RdStationCrm { constructor() { this.description = { displayName: 'RD Station CRM', name: 'rdStationCrm', icon: { light: 'file:rdStationCrm.svg', dark: 'file:rdStationCrm.dark.svg' }, group: ['transform'], version: 1, subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', description: 'Read and write data in RD Station CRM. Create, get, update and list contacts (leads/people), deals (sales opportunities), organizations (companies), tasks, notes, and manage pipelines, stages, products, custom fields, sources, campaigns, loss reasons, users, teams and webhooks. Supports API v1 (private token) and API v2 (OAuth2). Usable as an AI Agent tool.', defaults: { name: 'RD Station CRM', }, inputs: [n8n_workflow_1.NodeConnectionTypes.Main], outputs: [n8n_workflow_1.NodeConnectionTypes.Main], usableAsTool: true, credentials: [ { name: 'rdStationCrmApi', required: true, displayOptions: { show: { authentication: ['accessToken'] } }, }, { name: 'rdStationCrmOAuth2Api', required: true, displayOptions: { show: { authentication: ['oauth2'] } }, }, ], properties: [ { displayName: 'Authentication', name: 'authentication', type: 'options', noDataExpression: true, options: [ { name: 'Access Token (API V1)', value: 'accessToken' }, { name: 'OAuth2 (API V2)', value: 'oauth2' }, ], default: 'accessToken', description: 'API v1 uses a private token; API v2 uses OAuth2', }, { displayName: 'Resource', name: 'resource', type: 'options', noDataExpression: true, displayOptions: { show: { authentication: ['accessToken'] } }, options: actions_1.resourceOptions, default: 'contact', }, { displayName: 'Resource', name: 'resource', type: 'options', noDataExpression: true, displayOptions: { show: { authentication: ['oauth2'] } }, options: actions_1.resourceOptionsV2, default: 'contactV2', }, ...actions_1.resourceProperties, ...actions_1.resourcePropertiesV2, ], }; this.methods = { loadOptions: { ...loadOptions_1.loadOptions, ...loadOptionsV2_1.loadOptionsV2 }, }; } async execute() { const items = this.getInputData(); const returnData = []; for (let i = 0; i < items.length; i++) { try { const resource = this.getNodeParameter('resource', i); const operation = this.getNodeParameter('operation', i); const responseData = await actions_1.executeResource.call(this, resource, operation, i); const asArray = Array.isArray(responseData) ? responseData : [responseData]; const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(asArray), { itemData: { item: i } }); returnData.push(...executionData); } catch (error) { if (this.continueOnFail()) { returnData.push({ json: { error: error.message }, pairedItem: { item: i }, }); continue; } throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i }); } } return [returnData]; } } exports.RdStationCrm = RdStationCrm; //# sourceMappingURL=RdStationCrm.node.js.map