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.

77 lines 3.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.loadOptions = void 0; const transport_1 = require("../transport"); function toOptions(items, labelKey = 'name') { return items .filter(Boolean) .map((item) => ({ name: (item[labelKey] ?? item.name ?? item.label ?? item.email ?? item.id), value: (item.id ?? item._id), })); } async function loadCustomFields(forEntity) { const fields = await transport_1.rdCrmApiRequestAllItems.call(this, 'custom_fields', 'GET', '/custom_fields', {}, { for: forEntity }); return toOptions(fields, 'label'); } exports.loadOptions = { async getOrganizations() { const items = await transport_1.rdCrmApiRequestAllItems.call(this, 'organizations', 'GET', '/organizations'); return toOptions(items); }, async getUsers() { const items = await transport_1.rdCrmApiRequestAllItems.call(this, 'users', 'GET', '/users'); return toOptions(items); }, async getTeams() { const items = await transport_1.rdCrmApiRequestAllItems.call(this, 'teams', 'GET', '/teams'); return toOptions(items); }, async getPipelines() { const items = await transport_1.rdCrmApiRequestAllItems.call(this, 'deal_pipelines', 'GET', '/deal_pipelines'); return toOptions(items); }, async getStages() { let pipelineId = ''; try { pipelineId = this.getNodeParameter('pipelineId', ''); } catch { pipelineId = ''; } const qs = pipelineId ? { deal_pipeline_id: pipelineId, limit: 12 } : { limit: 12 }; const items = await transport_1.rdCrmApiRequestAllItems.call(this, 'deal_stages', 'GET', '/deal_stages', {}, qs); return toOptions(items); }, async getCampaigns() { const items = await transport_1.rdCrmApiRequestAllItems.call(this, 'campaigns', 'GET', '/campaigns'); return toOptions(items); }, async getSources() { const items = await transport_1.rdCrmApiRequestAllItems.call(this, 'deal_sources', 'GET', '/deal_sources'); return toOptions(items); }, async getLossReasons() { const items = await transport_1.rdCrmApiRequestAllItems.call(this, 'deal_lost_reasons', 'GET', '/deal_lost_reasons'); return toOptions(items); }, async getProducts() { const items = await transport_1.rdCrmApiRequestAllItems.call(this, 'products', 'GET', '/products'); return toOptions(items); }, async getContactCustomFields() { return loadCustomFields.call(this, 'contact'); }, async getDealCustomFields() { return loadCustomFields.call(this, 'deal'); }, async getOrganizationCustomFields() { return loadCustomFields.call(this, 'organization'); }, async getProductCustomFields() { return loadCustomFields.call(this, 'product'); }, }; // Silence unused import in strict builds where only some helpers are referenced. void transport_1.rdCrmApiRequest; //# sourceMappingURL=loadOptions.js.map