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.
114 lines • 3.96 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.teamDescription = void 0;
exports.executeTeam = executeTeam;
const transport_1 = require("../../transport");
const showOnlyForTeams = {
resource: ['team'],
};
exports.teamDescription = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: { show: showOnlyForTeams },
options: [
{
name: 'Get',
value: 'get',
action: 'Get a team',
description: 'Retrieve a single team by its ID from RD Station CRM',
},
{
name: 'Get Many',
value: 'getMany',
action: 'Get many teams',
description: 'Retrieve a paginated list of teams (groups of users) from RD Station CRM',
},
],
default: 'get',
},
// ----- ID field (get) -----
{
displayName: 'Team ID',
name: 'teamId',
type: 'string',
required: true,
default: '',
displayOptions: { show: { ...showOnlyForTeams, operation: ['get'] } },
description: 'ID of the team to retrieve, obtained from a get many teams 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: { ...showOnlyForTeams, operation: ['getMany'] } },
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
default: 50,
typeOptions: { minValue: 1 },
description: 'Max number of results to return',
displayOptions: {
show: { ...showOnlyForTeams, operation: ['getMany'], returnAll: [false] },
},
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: { show: { ...showOnlyForTeams, operation: ['getMany'] } },
description: 'Additional options for how the teams are returned',
options: [
{
displayName: 'Sort By',
name: 'order',
type: 'options',
options: [
{ name: 'Created At', value: 'created_at' },
{ name: 'Name', value: 'name' },
],
default: 'name',
description: 'Field to sort the returned teams by. One of: created_at, name',
},
{
displayName: 'Sort Direction',
name: 'direction',
type: 'options',
options: [
{ name: 'Ascending', value: 'asc' },
{ name: 'Descending', value: 'desc' },
],
default: 'asc',
description: 'Sort order for the returned teams. One of: asc, desc',
},
],
},
];
async function executeTeam(operation, i) {
if (operation === 'get') {
const teamId = this.getNodeParameter('teamId', i);
return transport_1.rdCrmApiRequest.call(this, 'GET', `/teams/${teamId}`);
}
if (operation === 'getMany') {
const returnAll = this.getNodeParameter('returnAll', i);
const options = this.getNodeParameter('options', i, {});
const qs = { ...options };
if (returnAll) {
return transport_1.rdCrmApiRequestAllItems.call(this, 'teams', 'GET', '/teams', {}, qs);
}
qs.limit = this.getNodeParameter('limit', i);
const response = await transport_1.rdCrmApiRequest.call(this, 'GET', '/teams', {}, qs);
return response.teams ?? response;
}
return {};
}
//# sourceMappingURL=Team.js.map