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.

94 lines 3.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.noteV2Description = void 0; exports.executeNoteV2 = executeNoteV2; const v2_1 = require("../../transport/v2"); // --------------------------------------------------------------------------- // v2 (OAuth2) resource — mirrors ContactV2 template. // Notes are deal-scoped: they live under /deals/{dealId}/notes and support // only create + list in the v2 API. // --------------------------------------------------------------------------- const showOnly = { resource: ['noteV2'] }; exports.noteV2Description = [ { displayName: 'Operation', name: 'operation', type: 'options', noDataExpression: true, displayOptions: { show: showOnly }, options: [ { name: 'Create', value: 'create', action: 'Create a note', description: 'Create a new text note attached to a deal in RD Station CRM (API v2) and return the created record' }, { name: 'Get Many', value: 'getMany', action: 'Get many notes', description: 'Retrieve a paginated list of notes attached to a deal in RD Station CRM (API v2)' }, ], default: 'create', }, { displayName: 'Deal ID', name: 'dealId', type: 'string', required: true, default: '', displayOptions: { show: { ...showOnly, operation: ['create', 'getMany'] } }, description: 'Unique identifier of the deal whose notes to read or add to, taken from a create or get deals operation', }, { displayName: 'Description', name: 'description', type: 'string', required: true, default: '', typeOptions: { rows: 4 }, displayOptions: { show: { ...showOnly, operation: ['create'] } }, description: 'Text content of the note to add to the deal', }, { displayName: 'User Name or ID', name: 'user_id', type: 'options', required: true, default: '', description: 'User to record as the author of the note. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>', typeOptions: { loadOptionsMethod: 'getUsersV2' }, displayOptions: { show: { ...showOnly, operation: ['create'] } }, }, { displayName: 'Return All', name: 'returnAll', type: 'boolean', default: false, description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { ...showOnly, operation: ['getMany'] } }, }, { displayName: 'Limit', name: 'limit', type: 'number', default: 50, typeOptions: { minValue: 1 }, description: 'Max number of results to return', displayOptions: { show: { ...showOnly, operation: ['getMany'], returnAll: [false] } }, }, ]; async function executeNoteV2(operation, i) { if (operation === 'create') { const dealId = this.getNodeParameter('dealId', i); const description = this.getNodeParameter('description', i); const userId = this.getNodeParameter('user_id', i); const body = { description, user_id: userId }; const response = await v2_1.rdCrmV2Request.call(this, 'POST', `/deals/${dealId}/notes`, body); return response.data ?? response; } if (operation === 'getMany') { const dealId = this.getNodeParameter('dealId', i); const returnAll = this.getNodeParameter('returnAll', i); const qs = {}; if (returnAll) { return v2_1.rdCrmV2RequestAllItems.call(this, `/deals/${dealId}/notes`, qs); } qs['page[size]'] = this.getNodeParameter('limit', i); const response = await v2_1.rdCrmV2Request.call(this, 'GET', `/deals/${dealId}/notes`, {}, qs); return response.data ?? response; } return {}; } //# sourceMappingURL=NoteV2.js.map