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.

139 lines 5.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.userDescription = void 0; exports.executeUser = executeUser; const transport_1 = require("../../transport"); const showOnlyForUsers = { resource: ['user'], }; exports.userDescription = [ { displayName: 'Operation', name: 'operation', type: 'options', noDataExpression: true, displayOptions: { show: showOnlyForUsers }, options: [ { name: 'Get', value: 'get', action: 'Get a user', description: 'Retrieve a single CRM user by its ID from RD Station CRM', }, { name: 'Get Current', value: 'getCurrent', action: 'Get the current user', description: 'Retrieve the CRM user that owns the API token used for authentication', }, { name: 'Get Many', value: 'getMany', action: 'Get many users', description: 'Retrieve a paginated list of CRM users, optionally filtered by role, status, or team', }, ], default: 'get', }, // ----- ID field (get) ----- { displayName: 'User ID', name: 'userId', type: 'string', required: true, default: '', displayOptions: { show: { ...showOnlyForUsers, operation: ['get'] } }, description: 'ID of the CRM user to retrieve, obtained from a get many users operation', }, // ----- Get Many controls ----- { displayName: 'Return All', name: 'returnAll', type: 'boolean', default: false, description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { ...showOnlyForUsers, operation: ['getMany'] } }, }, { displayName: 'Limit', name: 'limit', type: 'number', default: 50, typeOptions: { minValue: 1 }, description: 'Max number of results to return', displayOptions: { show: { ...showOnlyForUsers, operation: ['getMany'], returnAll: [false] }, }, }, { displayName: 'Filters', name: 'filters', type: 'collection', placeholder: 'Add Filter', default: {}, displayOptions: { show: { ...showOnlyForUsers, operation: ['getMany'] } }, description: 'Optional filters to narrow the returned users', options: [ { displayName: 'Role', name: 'role', type: 'options', options: [ { name: 'Admin', value: 'admin' }, { name: 'Manager', value: 'manager' }, { name: 'User', value: 'user' }, ], default: 'user', description: 'Filter users by their access role. One of: admin, manager, user', }, { displayName: 'Status', name: 'status', type: 'options', options: [ { name: 'Active', value: 'active' }, { name: 'All', value: 'all' }, { name: 'Inactive', value: 'inactive' }, ], default: 'active', description: 'Filter users by their account status. One of: active, all, inactive', }, { displayName: 'Team Name or ID', name: 'teamId', type: 'options', description: 'Only return users belonging to this team. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>', typeOptions: { loadOptionsMethod: 'getTeams' }, default: '', }, ], }, ]; async function executeUser(operation, i) { if (operation === 'get') { const userId = this.getNodeParameter('userId', i); return transport_1.rdCrmApiRequest.call(this, 'GET', `/users/${userId}`); } if (operation === 'getCurrent') { return transport_1.rdCrmApiRequest.call(this, 'GET', '/users/me'); } if (operation === 'getMany') { const returnAll = this.getNodeParameter('returnAll', i); const filters = this.getNodeParameter('filters', i, {}); const qs = {}; if (filters.role) qs.role = filters.role; if (filters.teamId) qs.team_id = filters.teamId; if (filters.status && filters.status !== 'all') qs.status = filters.status; if (returnAll) { return transport_1.rdCrmApiRequestAllItems.call(this, 'users', 'GET', '/users', {}, qs); } qs.limit = this.getNodeParameter('limit', i); const response = await transport_1.rdCrmApiRequest.call(this, 'GET', '/users', {}, qs); return response.users ?? response; } return {}; } //# sourceMappingURL=User.js.map