n8n-nodes-pragma-bitrix24 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +51 -0
- package/README.md +340 -0
- package/dist/credentials/Bitrix24Api.credentials.js +55 -0
- package/dist/nodes/Bitrix24/Bitrix24.node.js +1410 -0
- package/dist/nodes/Bitrix24/Company.js +17 -0
- package/dist/nodes/Bitrix24/Contact.js +31 -0
- package/dist/nodes/Bitrix24/Deal.js +17 -0
- package/dist/nodes/Bitrix24/Helpers.js +300 -0
- package/dist/nodes/Bitrix24/Lead.js +17 -0
- package/dist/nodes/Bitrix24/SmartProcess.js +1 -0
- package/dist/nodes/Bitrix24/bitrix24.svg +7 -0
- package/dist/nodes/Bitrix24/types.js +58 -0
- package/dist/nodes/Bitrix24AI/Bitrix24AI.node.js +205 -0
- package/dist/nodes/Bitrix24App/Bitrix24App.node.js +179 -0
- package/dist/nodes/Bitrix24Auxiliary/Bitrix24Auxiliary.node.js +566 -0
- package/dist/nodes/Bitrix24Booking/Bitrix24Booking.node.js +871 -0
- package/dist/nodes/Bitrix24Calendar/Bitrix24Calendar.node.js +471 -0
- package/dist/nodes/Bitrix24ChatBot/Bitrix24ChatBot.node.js +522 -0
- package/dist/nodes/Bitrix24Commerce/Bitrix24Commerce.node.js +431 -0
- package/dist/nodes/Bitrix24Department/Bitrix24Department.node.js +317 -0
- package/dist/nodes/Bitrix24Disk/Bitrix24Disk.node.js +334 -0
- package/dist/nodes/Bitrix24Document/Bitrix24Document.node.js +280 -0
- package/dist/nodes/Bitrix24Entity/Bitrix24Entity.node.js +263 -0
- package/dist/nodes/Bitrix24Group/Bitrix24Group.node.js +327 -0
- package/dist/nodes/Bitrix24Lists/Bitrix24Lists.node.js +406 -0
- package/dist/nodes/Bitrix24Log/Bitrix24Log.node.js +309 -0
- package/dist/nodes/Bitrix24Mail/Bitrix24Mail.node.js +109 -0
- package/dist/nodes/Bitrix24MessageService/Bitrix24MessageService.node.js +218 -0
- package/dist/nodes/Bitrix24OpenChannels/Bitrix24OpenChannels.node.js +379 -0
- package/dist/nodes/Bitrix24PaySystem/Bitrix24PaySystem.node.js +241 -0
- package/dist/nodes/Bitrix24Pipeline/Bitrix24Pipeline.node.js +553 -0
- package/dist/nodes/Bitrix24Pipeline/bitrix24.svg +7 -0
- package/dist/nodes/Bitrix24Sale/Bitrix24Sale.node.js +391 -0
- package/dist/nodes/Bitrix24Scrum/Bitrix24Scrum.node.js +555 -0
- package/dist/nodes/Bitrix24Scrum/bitrix24.svg +7 -0
- package/dist/nodes/Bitrix24Sign/Bitrix24Sign.node.js +132 -0
- package/dist/nodes/Bitrix24Social/Bitrix24Social.node.js +224 -0
- package/dist/nodes/Bitrix24Task/Bitrix24Task.node.js +444 -0
- package/dist/nodes/Bitrix24Telephony/Bitrix24Telephony.node.js +511 -0
- package/dist/nodes/Bitrix24Timeman/Bitrix24Timeman.node.js +196 -0
- package/dist/nodes/Bitrix24Tool/Bitrix24Tool.node.js +1035 -0
- package/dist/nodes/Bitrix24Tool/bitrix24.svg +7 -0
- package/dist/nodes/Bitrix24Trigger/Bitrix24Trigger.node.js +184 -0
- package/dist/nodes/Bitrix24User/Bitrix24User.node.js +351 -0
- package/dist/nodes/Bitrix24UserField/Bitrix24UserField.node.js +386 -0
- package/dist/nodes/Bitrix24UserField/bitrix24.svg +7 -0
- package/dist/nodes/shared/bitrix24.svg +7 -0
- package/dist/nodes/shared/localization.js +189 -0
- package/dist/nodes/shared/types.js +22 -0
- package/index.js +10 -0
- package/package.json +108 -0
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bitrix24 Pipeline — Нода воронок и стадий
|
|
4
|
+
*
|
|
5
|
+
* Bitrix24 PRAGMA.by nodes for n8n
|
|
6
|
+
* Профессиональная интеграция с Битрикс24.
|
|
7
|
+
*
|
|
8
|
+
* @author PRAGMA & Азбука Решений
|
|
9
|
+
* @copyright 2026 PRAGMA (https://pragma.by/) & Азбука Решений (https://abc-solution.ru/)
|
|
10
|
+
*
|
|
11
|
+
* Контакты:
|
|
12
|
+
* 🇧🇾 PRAGMA: +375 (44) 702-70-90 | https://pragma.by/
|
|
13
|
+
* 🇷🇺 Азбука Решений: +7 (939) 555-19-60 | https://abc-solution.ru/
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.Bitrix24Pipeline = void 0;
|
|
17
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
18
|
+
const Helpers_1 = require("../Bitrix24/Helpers");
|
|
19
|
+
class Bitrix24Pipeline {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.description = {
|
|
22
|
+
displayName: 'Bitrix24 Воронки',
|
|
23
|
+
name: 'pragmaBitrix24Pipeline',
|
|
24
|
+
icon: 'file:bitrix24.svg',
|
|
25
|
+
group: ['transform'],
|
|
26
|
+
version: 1,
|
|
27
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
28
|
+
description: 'Управление CRM-воронками и стадиями сделок',
|
|
29
|
+
defaults: {
|
|
30
|
+
name: 'Bitrix24 Воронки',
|
|
31
|
+
},
|
|
32
|
+
inputs: ['main'],
|
|
33
|
+
outputs: ['main'],
|
|
34
|
+
credentials: [
|
|
35
|
+
{
|
|
36
|
+
name: 'bitrix24Api',
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
properties: [
|
|
41
|
+
{
|
|
42
|
+
displayName: 'Resource',
|
|
43
|
+
name: 'resource',
|
|
44
|
+
type: 'options',
|
|
45
|
+
noDataExpression: true,
|
|
46
|
+
options: [
|
|
47
|
+
{ name: 'Funnel (Category)', value: 'category' },
|
|
48
|
+
{ name: 'Funnel Status', value: 'status' },
|
|
49
|
+
],
|
|
50
|
+
default: 'category',
|
|
51
|
+
required: true,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
displayName: 'Operation',
|
|
55
|
+
name: 'operation',
|
|
56
|
+
type: 'options',
|
|
57
|
+
noDataExpression: true,
|
|
58
|
+
options: [
|
|
59
|
+
{ name: 'Create', value: 'create', description: 'Create an item', action: 'Create an item' },
|
|
60
|
+
{ name: 'Update', value: 'update', description: 'Update an item', action: 'Update an item' },
|
|
61
|
+
{ name: 'Get', value: 'get', description: 'Get an item', action: 'Get an item' },
|
|
62
|
+
{ name: 'Get All', value: 'getAll', description: 'Get all items', action: 'Get all items' },
|
|
63
|
+
{ name: 'Delete', value: 'delete', description: 'Delete an item', action: 'Delete an item' },
|
|
64
|
+
],
|
|
65
|
+
default: 'create',
|
|
66
|
+
},
|
|
67
|
+
// Funnel (Category) Fields
|
|
68
|
+
{
|
|
69
|
+
displayName: 'ID',
|
|
70
|
+
name: 'id',
|
|
71
|
+
type: 'string',
|
|
72
|
+
default: '',
|
|
73
|
+
required: true,
|
|
74
|
+
displayOptions: {
|
|
75
|
+
show: {
|
|
76
|
+
resource: ['category'],
|
|
77
|
+
operation: ['update', 'get', 'delete'],
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
description: 'ID of the funnel',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
displayName: 'Name',
|
|
84
|
+
name: 'name',
|
|
85
|
+
type: 'string',
|
|
86
|
+
default: '',
|
|
87
|
+
required: true,
|
|
88
|
+
displayOptions: {
|
|
89
|
+
show: {
|
|
90
|
+
resource: ['category'],
|
|
91
|
+
operation: ['create', 'update'],
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
description: 'Name of the funnel',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
displayName: 'Sort',
|
|
98
|
+
name: 'sort',
|
|
99
|
+
type: 'number',
|
|
100
|
+
default: 100,
|
|
101
|
+
displayOptions: {
|
|
102
|
+
show: {
|
|
103
|
+
resource: ['category'],
|
|
104
|
+
operation: ['create', 'update'],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
description: 'Sort order',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
displayName: 'Is Default',
|
|
111
|
+
name: 'isDefault',
|
|
112
|
+
type: 'boolean',
|
|
113
|
+
default: false,
|
|
114
|
+
displayOptions: {
|
|
115
|
+
show: {
|
|
116
|
+
resource: ['category'],
|
|
117
|
+
operation: ['create', 'update'],
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
description: 'Is default funnel',
|
|
121
|
+
},
|
|
122
|
+
// Status Fields
|
|
123
|
+
{
|
|
124
|
+
displayName: 'Category ID',
|
|
125
|
+
name: 'categoryId',
|
|
126
|
+
type: 'string',
|
|
127
|
+
default: '',
|
|
128
|
+
required: true,
|
|
129
|
+
displayOptions: {
|
|
130
|
+
show: {
|
|
131
|
+
resource: ['status'],
|
|
132
|
+
operation: ['create', 'update', 'delete', 'getAll'],
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
description: 'ID of the funnel (category)',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
displayName: 'Status Name',
|
|
139
|
+
name: 'statusName',
|
|
140
|
+
type: 'string',
|
|
141
|
+
default: '',
|
|
142
|
+
required: true,
|
|
143
|
+
displayOptions: {
|
|
144
|
+
show: {
|
|
145
|
+
resource: ['status'],
|
|
146
|
+
operation: ['create', 'update'],
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
description: 'Name of the status',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
displayName: 'Status Sort',
|
|
153
|
+
name: 'statusSort',
|
|
154
|
+
type: 'number',
|
|
155
|
+
default: 100,
|
|
156
|
+
displayOptions: {
|
|
157
|
+
show: {
|
|
158
|
+
resource: ['status'],
|
|
159
|
+
operation: ['create', 'update'],
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
description: 'Sort order',
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
displayName: 'Status Color',
|
|
166
|
+
name: 'statusColor',
|
|
167
|
+
type: 'string',
|
|
168
|
+
default: '#00FF00',
|
|
169
|
+
displayOptions: {
|
|
170
|
+
show: {
|
|
171
|
+
resource: ['status'],
|
|
172
|
+
operation: ['create', 'update'],
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
description: 'Color of the status (HEX)',
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
displayName: 'Status Semantic',
|
|
179
|
+
name: 'statusSemantic',
|
|
180
|
+
type: 'options',
|
|
181
|
+
options: [
|
|
182
|
+
{ name: 'Process', value: 'P' },
|
|
183
|
+
{ name: 'Success', value: 'S' },
|
|
184
|
+
{ name: 'Failure', value: 'F' },
|
|
185
|
+
],
|
|
186
|
+
default: 'P',
|
|
187
|
+
displayOptions: {
|
|
188
|
+
show: {
|
|
189
|
+
resource: ['status'],
|
|
190
|
+
operation: ['create', 'update'],
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
description: 'Semantics of the status',
|
|
194
|
+
},
|
|
195
|
+
// Multiple Items Support
|
|
196
|
+
{
|
|
197
|
+
displayName: 'Multiple Items',
|
|
198
|
+
name: 'multipleItems',
|
|
199
|
+
type: 'boolean',
|
|
200
|
+
default: false,
|
|
201
|
+
displayOptions: {
|
|
202
|
+
show: {
|
|
203
|
+
operation: ['create', 'update'],
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
description: 'Create multiple items at once',
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
displayName: 'Items',
|
|
210
|
+
name: 'items',
|
|
211
|
+
type: 'fixedCollection',
|
|
212
|
+
typeOptions: {
|
|
213
|
+
multipleValues: true,
|
|
214
|
+
sortable: true,
|
|
215
|
+
},
|
|
216
|
+
displayOptions: {
|
|
217
|
+
show: {
|
|
218
|
+
operation: ['create', 'update'],
|
|
219
|
+
multipleItems: [true],
|
|
220
|
+
resource: ['category'],
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
description: 'List of funnels to create',
|
|
224
|
+
default: {},
|
|
225
|
+
options: [
|
|
226
|
+
{
|
|
227
|
+
name: 'categories',
|
|
228
|
+
displayName: 'Categories',
|
|
229
|
+
values: [
|
|
230
|
+
{
|
|
231
|
+
displayName: 'Name',
|
|
232
|
+
name: 'name',
|
|
233
|
+
type: 'string',
|
|
234
|
+
default: '',
|
|
235
|
+
description: 'Name',
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
displayName: 'Sort',
|
|
239
|
+
name: 'sort',
|
|
240
|
+
type: 'number',
|
|
241
|
+
default: 100,
|
|
242
|
+
description: 'Sort',
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
displayName: 'Is Default',
|
|
246
|
+
name: 'isDefault',
|
|
247
|
+
type: 'boolean',
|
|
248
|
+
default: false,
|
|
249
|
+
description: 'Is Default',
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
displayName: 'Items',
|
|
257
|
+
name: 'statusItems',
|
|
258
|
+
type: 'fixedCollection',
|
|
259
|
+
typeOptions: {
|
|
260
|
+
multipleValues: true,
|
|
261
|
+
sortable: true,
|
|
262
|
+
},
|
|
263
|
+
displayOptions: {
|
|
264
|
+
show: {
|
|
265
|
+
operation: ['create', 'update'],
|
|
266
|
+
multipleItems: [true],
|
|
267
|
+
resource: ['status'],
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
description: 'List of statuses to create',
|
|
271
|
+
default: {},
|
|
272
|
+
options: [
|
|
273
|
+
{
|
|
274
|
+
name: 'statuses',
|
|
275
|
+
displayName: 'Statuses',
|
|
276
|
+
values: [
|
|
277
|
+
{
|
|
278
|
+
displayName: 'Name',
|
|
279
|
+
name: 'name',
|
|
280
|
+
type: 'string',
|
|
281
|
+
default: '',
|
|
282
|
+
description: 'Name',
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
displayName: 'Sort',
|
|
286
|
+
name: 'sort',
|
|
287
|
+
type: 'number',
|
|
288
|
+
default: 100,
|
|
289
|
+
description: 'Sort',
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
displayName: 'Color',
|
|
293
|
+
name: 'color',
|
|
294
|
+
type: 'string',
|
|
295
|
+
default: '#00FF00',
|
|
296
|
+
description: 'Color',
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
displayName: 'Semantic',
|
|
300
|
+
name: 'semantic',
|
|
301
|
+
type: 'options',
|
|
302
|
+
options: [
|
|
303
|
+
{ name: 'Process', value: 'P' },
|
|
304
|
+
{ name: 'Success', value: 'S' },
|
|
305
|
+
{ name: 'Failure', value: 'F' },
|
|
306
|
+
],
|
|
307
|
+
default: 'P',
|
|
308
|
+
description: 'Semantic',
|
|
309
|
+
},
|
|
310
|
+
],
|
|
311
|
+
},
|
|
312
|
+
],
|
|
313
|
+
},
|
|
314
|
+
],
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
async execute() {
|
|
318
|
+
const items = this.getInputData();
|
|
319
|
+
const returnData = [];
|
|
320
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
321
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
322
|
+
try {
|
|
323
|
+
for (let i = 0; i < items.length; i++) {
|
|
324
|
+
try {
|
|
325
|
+
if (resource === 'category') {
|
|
326
|
+
if (operation === 'create' || operation === 'update') {
|
|
327
|
+
const multipleItems = this.getNodeParameter('multipleItems', i);
|
|
328
|
+
const method = operation === 'create' ? 'add' : 'update';
|
|
329
|
+
const endpoint = `crm.category.${method}`;
|
|
330
|
+
if (multipleItems) {
|
|
331
|
+
const itemsData = this.getNodeParameter('items.categories', i, []);
|
|
332
|
+
for (const item of itemsData) {
|
|
333
|
+
const params = {
|
|
334
|
+
entityTypeId: 2,
|
|
335
|
+
fields: {
|
|
336
|
+
name: item.name,
|
|
337
|
+
sort: item.sort || 100,
|
|
338
|
+
isDefault: item.isDefault ? 'Y' : 'N',
|
|
339
|
+
},
|
|
340
|
+
};
|
|
341
|
+
const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', endpoint, params);
|
|
342
|
+
if (response && response.result) {
|
|
343
|
+
returnData.push({
|
|
344
|
+
json: {
|
|
345
|
+
success: true,
|
|
346
|
+
id: response.result,
|
|
347
|
+
...params.fields,
|
|
348
|
+
},
|
|
349
|
+
pairedItem: { item: i },
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
const name = this.getNodeParameter('name', i);
|
|
356
|
+
const sort = this.getNodeParameter('sort', i);
|
|
357
|
+
const isDefault = this.getNodeParameter('isDefault', i);
|
|
358
|
+
const params = {
|
|
359
|
+
entityTypeId: 2,
|
|
360
|
+
fields: {
|
|
361
|
+
name: name,
|
|
362
|
+
sort: sort,
|
|
363
|
+
isDefault: isDefault ? 'Y' : 'N',
|
|
364
|
+
},
|
|
365
|
+
};
|
|
366
|
+
if (operation === 'update') {
|
|
367
|
+
params.id = this.getNodeParameter('id', i);
|
|
368
|
+
}
|
|
369
|
+
const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', endpoint, params);
|
|
370
|
+
if (response && response.result) {
|
|
371
|
+
returnData.push({
|
|
372
|
+
json: {
|
|
373
|
+
success: true,
|
|
374
|
+
id: response.result,
|
|
375
|
+
...params.fields,
|
|
376
|
+
},
|
|
377
|
+
pairedItem: { item: i },
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
if (operation === 'get') {
|
|
383
|
+
const categoryId = this.getNodeParameter('id', i);
|
|
384
|
+
const endpoint = `crm.category.get`;
|
|
385
|
+
const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', endpoint, {
|
|
386
|
+
entityTypeId: 2,
|
|
387
|
+
id: categoryId
|
|
388
|
+
});
|
|
389
|
+
if (response && response.result) {
|
|
390
|
+
returnData.push({
|
|
391
|
+
json: response.result,
|
|
392
|
+
pairedItem: { item: i },
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
if (operation === 'getAll') {
|
|
397
|
+
const endpoint = `crm.category.list`;
|
|
398
|
+
const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', endpoint, {
|
|
399
|
+
entityTypeId: 2
|
|
400
|
+
});
|
|
401
|
+
if (response && response.result) {
|
|
402
|
+
const categories = Array.isArray(response.result) ? response.result : [response.result];
|
|
403
|
+
for (const category of categories) {
|
|
404
|
+
returnData.push({
|
|
405
|
+
json: {
|
|
406
|
+
...category,
|
|
407
|
+
id: category.ID,
|
|
408
|
+
},
|
|
409
|
+
pairedItem: { item: i },
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
if (operation === 'delete') {
|
|
415
|
+
const categoryId = this.getNodeParameter('id', i);
|
|
416
|
+
const endpoint = `crm.category.delete`;
|
|
417
|
+
await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', endpoint, {
|
|
418
|
+
entityTypeId: 2,
|
|
419
|
+
id: categoryId
|
|
420
|
+
});
|
|
421
|
+
returnData.push({
|
|
422
|
+
json: { success: true, id: categoryId },
|
|
423
|
+
pairedItem: { item: i },
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
if (resource === 'status') {
|
|
428
|
+
if (operation === 'create' || operation === 'update') {
|
|
429
|
+
const multipleItems = this.getNodeParameter('multipleItems', i);
|
|
430
|
+
const categoryId = this.getNodeParameter('categoryId', i);
|
|
431
|
+
const method = operation === 'create' ? 'add' : 'update';
|
|
432
|
+
const endpoint = `crm.status.${method}`;
|
|
433
|
+
if (multipleItems) {
|
|
434
|
+
const itemsData = this.getNodeParameter('statusItems.statuses', i, []);
|
|
435
|
+
for (const item of itemsData) {
|
|
436
|
+
const params = {
|
|
437
|
+
fields: {
|
|
438
|
+
NAME: item.name,
|
|
439
|
+
SORT: item.sort || 100,
|
|
440
|
+
COLOR: item.color || '#00FF00',
|
|
441
|
+
SEMANTIC_INFO: { CODE: item.semantic || 'P' },
|
|
442
|
+
CATEGORY_ID: categoryId,
|
|
443
|
+
ENTITY_ID: `DEAL_STAGE_${categoryId}`,
|
|
444
|
+
STATUS_ID: `${categoryId}_${item.sort || 100}`,
|
|
445
|
+
},
|
|
446
|
+
};
|
|
447
|
+
if (operation === 'update' && item.id) {
|
|
448
|
+
params.id = item.id;
|
|
449
|
+
}
|
|
450
|
+
const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', endpoint, params);
|
|
451
|
+
if (response && response.result) {
|
|
452
|
+
returnData.push({
|
|
453
|
+
json: {
|
|
454
|
+
success: true,
|
|
455
|
+
id: response.result,
|
|
456
|
+
...params.fields,
|
|
457
|
+
},
|
|
458
|
+
pairedItem: { item: i },
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
const statusName = this.getNodeParameter('statusName', i);
|
|
465
|
+
const statusSort = this.getNodeParameter('statusSort', i);
|
|
466
|
+
const statusColor = this.getNodeParameter('statusColor', i);
|
|
467
|
+
const statusSemantic = this.getNodeParameter('statusSemantic', i);
|
|
468
|
+
const params = {
|
|
469
|
+
fields: {
|
|
470
|
+
NAME: statusName,
|
|
471
|
+
SORT: statusSort,
|
|
472
|
+
COLOR: statusColor,
|
|
473
|
+
SEMANTIC_INFO: { CODE: statusSemantic },
|
|
474
|
+
CATEGORY_ID: categoryId,
|
|
475
|
+
ENTITY_ID: `DEAL_STAGE_${categoryId}`,
|
|
476
|
+
STATUS_ID: `${categoryId}_${statusSort}`,
|
|
477
|
+
},
|
|
478
|
+
};
|
|
479
|
+
if (operation === 'update') {
|
|
480
|
+
const statusId = this.getNodeParameter('id', i);
|
|
481
|
+
params.id = statusId;
|
|
482
|
+
}
|
|
483
|
+
const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', endpoint, params);
|
|
484
|
+
if (response && response.result) {
|
|
485
|
+
returnData.push({
|
|
486
|
+
json: {
|
|
487
|
+
success: true,
|
|
488
|
+
id: response.result,
|
|
489
|
+
...params.fields,
|
|
490
|
+
},
|
|
491
|
+
pairedItem: { item: i },
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
if (operation === 'get') {
|
|
497
|
+
const statusId = this.getNodeParameter('id', i);
|
|
498
|
+
const endpoint = `crm.status.get`;
|
|
499
|
+
const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', endpoint, { id: statusId });
|
|
500
|
+
returnData.push({
|
|
501
|
+
json: response.data,
|
|
502
|
+
pairedItem: { item: i },
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
if (operation === 'getAll') {
|
|
506
|
+
const categoryId = this.getNodeParameter('categoryId', i);
|
|
507
|
+
const entityId = categoryId === '0' ? 'DEAL_STAGE' : `DEAL_STAGE_${categoryId}`;
|
|
508
|
+
const endpoint = `crm.status.list`;
|
|
509
|
+
const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', endpoint, {
|
|
510
|
+
filter: {
|
|
511
|
+
ENTITY_ID: entityId
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
if (response && response.result) {
|
|
515
|
+
const results = response.result;
|
|
516
|
+
for (const item of results) {
|
|
517
|
+
returnData.push({
|
|
518
|
+
json: item,
|
|
519
|
+
pairedItem: { item: i },
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (operation === 'delete') {
|
|
525
|
+
const statusId = this.getNodeParameter('id', i);
|
|
526
|
+
const endpoint = `crm.status.delete`;
|
|
527
|
+
await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', endpoint, { id: statusId });
|
|
528
|
+
returnData.push({
|
|
529
|
+
json: { success: true, id: statusId },
|
|
530
|
+
pairedItem: { item: i },
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
catch (error) {
|
|
536
|
+
if (this.continueOnFail()) {
|
|
537
|
+
returnData.push({
|
|
538
|
+
json: { error: error.message },
|
|
539
|
+
pairedItem: { item: i },
|
|
540
|
+
});
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
throw error;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
return [returnData];
|
|
547
|
+
}
|
|
548
|
+
catch (error) {
|
|
549
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
exports.Bitrix24Pipeline = Bitrix24Pipeline;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
4
|
+
<path d="M16,0 C24.8365,0 32,7.1635 32,16 C32,24.8365 24.8365,32 16,32 C7.1635,32 0,24.8365 0,16 C0,7.1635 7.1635,0 16,0" fill="#2FC7F7"/>
|
|
5
|
+
<path d="M13.3333,8 L18.6667,8 C21.6122,8 24,10.3878 24,13.3333 L24,18.6667 C24,21.6122 21.6122,24 18.6667,24 L13.3333,24 C10.3878,24 8,21.6122 8,18.6667 L8,13.3333 C8,10.3878 10.3878,8 13.3333,8" fill="#FFFFFF"/>
|
|
6
|
+
</g>
|
|
7
|
+
</svg>
|