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,566 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Bitrix24Auxiliary = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
class Bitrix24Auxiliary {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.description = {
|
|
8
|
+
displayName: 'Bitrix24 Auxiliary (Pragma)',
|
|
9
|
+
name: 'pragmaBitrix24Auxiliary',
|
|
10
|
+
icon: 'file:bitrix24.svg',
|
|
11
|
+
group: ['transform'],
|
|
12
|
+
version: 1,
|
|
13
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
14
|
+
description: 'Manage auxiliary entities in Bitrix24 (Funnels, Statuses)',
|
|
15
|
+
defaults: {
|
|
16
|
+
name: 'Bitrix24 Auxiliary',
|
|
17
|
+
},
|
|
18
|
+
inputs: ['main'],
|
|
19
|
+
outputs: ['main'],
|
|
20
|
+
credentials: [
|
|
21
|
+
{
|
|
22
|
+
name: 'bitrix24Api',
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
properties: [
|
|
27
|
+
{
|
|
28
|
+
displayName: 'Resource',
|
|
29
|
+
name: 'resource',
|
|
30
|
+
type: 'options',
|
|
31
|
+
noDataExpression: true,
|
|
32
|
+
options: [
|
|
33
|
+
{ name: 'Funnel (Category)', value: 'category' },
|
|
34
|
+
{ name: 'Funnel Status', value: 'status' },
|
|
35
|
+
],
|
|
36
|
+
default: 'category',
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
displayName: 'Operation',
|
|
41
|
+
name: 'operation',
|
|
42
|
+
type: 'options',
|
|
43
|
+
noDataExpression: true,
|
|
44
|
+
options: [
|
|
45
|
+
{ name: 'Create', value: 'create', description: 'Create an item', action: 'Create an item' },
|
|
46
|
+
{ name: 'Update', value: 'update', description: 'Update an item', action: 'Update an item' },
|
|
47
|
+
{ name: 'Get', value: 'get', description: 'Get an item', action: 'Get an item' },
|
|
48
|
+
{ name: 'Get All', value: 'getAll', description: 'Get all items', action: 'Get all items' },
|
|
49
|
+
{ name: 'Delete', value: 'delete', description: 'Delete an item', action: 'Delete an item' },
|
|
50
|
+
],
|
|
51
|
+
default: 'create',
|
|
52
|
+
},
|
|
53
|
+
// Funnel (Category) Fields
|
|
54
|
+
{
|
|
55
|
+
displayName: 'ID',
|
|
56
|
+
name: 'id',
|
|
57
|
+
type: 'string',
|
|
58
|
+
default: '',
|
|
59
|
+
required: true,
|
|
60
|
+
displayOptions: {
|
|
61
|
+
show: {
|
|
62
|
+
resource: ['category'],
|
|
63
|
+
operation: ['update', 'get', 'delete'],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
description: 'ID of the funnel',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
displayName: 'Name',
|
|
70
|
+
name: 'name',
|
|
71
|
+
type: 'string',
|
|
72
|
+
default: '',
|
|
73
|
+
required: true,
|
|
74
|
+
displayOptions: {
|
|
75
|
+
show: {
|
|
76
|
+
resource: ['category'],
|
|
77
|
+
operation: ['create', 'update'],
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
description: 'Name of the funnel',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
displayName: 'Sort',
|
|
84
|
+
name: 'sort',
|
|
85
|
+
type: 'number',
|
|
86
|
+
default: 100,
|
|
87
|
+
displayOptions: {
|
|
88
|
+
show: {
|
|
89
|
+
resource: ['category'],
|
|
90
|
+
operation: ['create', 'update'],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
description: 'Sort order',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
displayName: 'Is Default',
|
|
97
|
+
name: 'isDefault',
|
|
98
|
+
type: 'boolean',
|
|
99
|
+
default: false,
|
|
100
|
+
displayOptions: {
|
|
101
|
+
show: {
|
|
102
|
+
resource: ['category'],
|
|
103
|
+
operation: ['create', 'update'],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
description: 'Is default funnel',
|
|
107
|
+
},
|
|
108
|
+
// Status Fields
|
|
109
|
+
{
|
|
110
|
+
displayName: 'Category ID',
|
|
111
|
+
name: 'categoryId',
|
|
112
|
+
type: 'string',
|
|
113
|
+
default: '',
|
|
114
|
+
required: true,
|
|
115
|
+
displayOptions: {
|
|
116
|
+
show: {
|
|
117
|
+
resource: ['status'],
|
|
118
|
+
operation: ['create', 'update', 'delete', 'getAll'],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
description: 'ID of the funnel (category)',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
displayName: 'Status Name',
|
|
125
|
+
name: 'statusName',
|
|
126
|
+
type: 'string',
|
|
127
|
+
default: '',
|
|
128
|
+
required: true,
|
|
129
|
+
displayOptions: {
|
|
130
|
+
show: {
|
|
131
|
+
resource: ['status'],
|
|
132
|
+
operation: ['create', 'update'],
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
description: 'Name of the status',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
displayName: 'Status Sort',
|
|
139
|
+
name: 'statusSort',
|
|
140
|
+
type: 'number',
|
|
141
|
+
default: 100,
|
|
142
|
+
displayOptions: {
|
|
143
|
+
show: {
|
|
144
|
+
resource: ['status'],
|
|
145
|
+
operation: ['create', 'update'],
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
description: 'Sort order',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
displayName: 'Status Color',
|
|
152
|
+
name: 'statusColor',
|
|
153
|
+
type: 'string',
|
|
154
|
+
default: '#00FF00',
|
|
155
|
+
displayOptions: {
|
|
156
|
+
show: {
|
|
157
|
+
resource: ['status'],
|
|
158
|
+
operation: ['create', 'update'],
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
description: 'Color of the status (HEX)',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
displayName: 'Status Semantic',
|
|
165
|
+
name: 'statusSemantic',
|
|
166
|
+
type: 'options',
|
|
167
|
+
options: [
|
|
168
|
+
{ name: 'Process', value: 'P' },
|
|
169
|
+
{ name: 'Success', value: 'S' },
|
|
170
|
+
{ name: 'Failure', value: 'F' },
|
|
171
|
+
],
|
|
172
|
+
default: 'P',
|
|
173
|
+
displayOptions: {
|
|
174
|
+
show: {
|
|
175
|
+
resource: ['status'],
|
|
176
|
+
operation: ['create', 'update'],
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
description: 'Semantics of the status',
|
|
180
|
+
},
|
|
181
|
+
// Multiple Items Support
|
|
182
|
+
{
|
|
183
|
+
displayName: 'Multiple Items',
|
|
184
|
+
name: 'multipleItems',
|
|
185
|
+
type: 'boolean',
|
|
186
|
+
default: false,
|
|
187
|
+
displayOptions: {
|
|
188
|
+
show: {
|
|
189
|
+
operation: ['create', 'update'],
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
description: 'Create multiple items at once',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
displayName: 'Items',
|
|
196
|
+
name: 'items',
|
|
197
|
+
type: 'fixedCollection',
|
|
198
|
+
typeOptions: {
|
|
199
|
+
multipleValues: true,
|
|
200
|
+
sortable: true,
|
|
201
|
+
},
|
|
202
|
+
displayOptions: {
|
|
203
|
+
show: {
|
|
204
|
+
operation: ['create', 'update'],
|
|
205
|
+
multipleItems: [true],
|
|
206
|
+
resource: ['category'],
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
description: 'List of funnels to create',
|
|
210
|
+
default: {},
|
|
211
|
+
options: [
|
|
212
|
+
{
|
|
213
|
+
name: 'categories',
|
|
214
|
+
displayName: 'Categories',
|
|
215
|
+
values: [
|
|
216
|
+
{
|
|
217
|
+
displayName: 'Name',
|
|
218
|
+
name: 'name',
|
|
219
|
+
type: 'string',
|
|
220
|
+
default: '',
|
|
221
|
+
description: 'Name',
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
displayName: 'Sort',
|
|
225
|
+
name: 'sort',
|
|
226
|
+
type: 'number',
|
|
227
|
+
default: 100,
|
|
228
|
+
description: 'Sort',
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
displayName: 'Is Default',
|
|
232
|
+
name: 'isDefault',
|
|
233
|
+
type: 'boolean',
|
|
234
|
+
default: false,
|
|
235
|
+
description: 'Is Default',
|
|
236
|
+
},
|
|
237
|
+
],
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
displayName: 'Items',
|
|
243
|
+
name: 'statusItems',
|
|
244
|
+
type: 'fixedCollection',
|
|
245
|
+
typeOptions: {
|
|
246
|
+
multipleValues: true,
|
|
247
|
+
sortable: true,
|
|
248
|
+
},
|
|
249
|
+
displayOptions: {
|
|
250
|
+
show: {
|
|
251
|
+
operation: ['create', 'update'],
|
|
252
|
+
multipleItems: [true],
|
|
253
|
+
resource: ['status'],
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
description: 'List of statuses to create',
|
|
257
|
+
default: {},
|
|
258
|
+
options: [
|
|
259
|
+
{
|
|
260
|
+
name: 'statuses',
|
|
261
|
+
displayName: 'Statuses',
|
|
262
|
+
values: [
|
|
263
|
+
{
|
|
264
|
+
displayName: 'Name',
|
|
265
|
+
name: 'name',
|
|
266
|
+
type: 'string',
|
|
267
|
+
default: '',
|
|
268
|
+
description: 'Name',
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
displayName: 'Sort',
|
|
272
|
+
name: 'sort',
|
|
273
|
+
type: 'number',
|
|
274
|
+
default: 100,
|
|
275
|
+
description: 'Sort',
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
displayName: 'Color',
|
|
279
|
+
name: 'color',
|
|
280
|
+
type: 'string',
|
|
281
|
+
default: '#00FF00',
|
|
282
|
+
description: 'Color',
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
displayName: 'Semantic',
|
|
286
|
+
name: 'semantic',
|
|
287
|
+
type: 'options',
|
|
288
|
+
options: [
|
|
289
|
+
{ name: 'Process', value: 'P' },
|
|
290
|
+
{ name: 'Success', value: 'S' },
|
|
291
|
+
{ name: 'Failure', value: 'F' },
|
|
292
|
+
],
|
|
293
|
+
default: 'P',
|
|
294
|
+
description: 'Semantic',
|
|
295
|
+
},
|
|
296
|
+
],
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
},
|
|
300
|
+
],
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
async execute() {
|
|
304
|
+
const items = this.getInputData();
|
|
305
|
+
const returnData = [];
|
|
306
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
307
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
308
|
+
try {
|
|
309
|
+
const credentials = await this.getCredentials('bitrix24Api');
|
|
310
|
+
if (!credentials) {
|
|
311
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No credentials returned!');
|
|
312
|
+
}
|
|
313
|
+
const webhookUrl = credentials.webhookUrl;
|
|
314
|
+
for (let i = 0; i < items.length; i++) {
|
|
315
|
+
try {
|
|
316
|
+
if (resource === 'category') {
|
|
317
|
+
if (operation === 'create' || operation === 'update') {
|
|
318
|
+
const multipleItems = this.getNodeParameter('multipleItems', i);
|
|
319
|
+
const method = operation === 'create' ? 'add' : 'update';
|
|
320
|
+
const endpoint = `crm.category.${method}`;
|
|
321
|
+
if (multipleItems) {
|
|
322
|
+
const itemsData = this.getNodeParameter('items.categories', i, []);
|
|
323
|
+
for (const item of itemsData) {
|
|
324
|
+
const params = {
|
|
325
|
+
entityTypeId: 2,
|
|
326
|
+
fields: {
|
|
327
|
+
name: item.name,
|
|
328
|
+
sort: item.sort || 100,
|
|
329
|
+
isDefault: item.isDefault ? 'Y' : 'N',
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
const response = await this.helpers.httpRequest({
|
|
333
|
+
method: 'POST',
|
|
334
|
+
baseURL: webhookUrl,
|
|
335
|
+
url: endpoint,
|
|
336
|
+
body: params,
|
|
337
|
+
json: true,
|
|
338
|
+
});
|
|
339
|
+
if (response && response.result) {
|
|
340
|
+
returnData.push({
|
|
341
|
+
success: true,
|
|
342
|
+
id: response.result,
|
|
343
|
+
...params.fields,
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
const name = this.getNodeParameter('name', i);
|
|
350
|
+
const sort = this.getNodeParameter('sort', i);
|
|
351
|
+
const isDefault = this.getNodeParameter('isDefault', i);
|
|
352
|
+
const params = {
|
|
353
|
+
entityTypeId: 2,
|
|
354
|
+
fields: {
|
|
355
|
+
name: name,
|
|
356
|
+
sort: sort,
|
|
357
|
+
isDefault: isDefault ? 'Y' : 'N',
|
|
358
|
+
},
|
|
359
|
+
};
|
|
360
|
+
if (operation === 'update') {
|
|
361
|
+
params.id = this.getNodeParameter('id', i);
|
|
362
|
+
}
|
|
363
|
+
const response = await this.helpers.httpRequest({
|
|
364
|
+
method: 'POST',
|
|
365
|
+
baseURL: webhookUrl,
|
|
366
|
+
url: endpoint,
|
|
367
|
+
body: params,
|
|
368
|
+
json: true,
|
|
369
|
+
});
|
|
370
|
+
if (response && response.result) {
|
|
371
|
+
returnData.push({
|
|
372
|
+
success: true,
|
|
373
|
+
id: response.result,
|
|
374
|
+
...params.fields,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (operation === 'get') {
|
|
380
|
+
const categoryId = this.getNodeParameter('id', i);
|
|
381
|
+
const endpoint = `crm.category.get`;
|
|
382
|
+
const response = await this.helpers.httpRequest({
|
|
383
|
+
method: 'POST',
|
|
384
|
+
baseURL: webhookUrl,
|
|
385
|
+
url: endpoint,
|
|
386
|
+
body: {
|
|
387
|
+
entityTypeId: 2,
|
|
388
|
+
id: categoryId
|
|
389
|
+
},
|
|
390
|
+
json: true,
|
|
391
|
+
});
|
|
392
|
+
if (response && response.result) {
|
|
393
|
+
returnData.push(response.result);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
if (operation === 'getAll') {
|
|
397
|
+
const endpoint = `crm.category.list`;
|
|
398
|
+
const response = await this.helpers.httpRequest({
|
|
399
|
+
method: 'POST',
|
|
400
|
+
baseURL: webhookUrl,
|
|
401
|
+
url: endpoint,
|
|
402
|
+
body: {
|
|
403
|
+
entityTypeId: 2
|
|
404
|
+
},
|
|
405
|
+
json: true,
|
|
406
|
+
});
|
|
407
|
+
if (response && response.result) {
|
|
408
|
+
const categories = Array.isArray(response.result) ? response.result : [response.result];
|
|
409
|
+
returnData.push(...categories.map((category) => ({
|
|
410
|
+
...category,
|
|
411
|
+
id: category.ID,
|
|
412
|
+
})));
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (operation === 'delete') {
|
|
416
|
+
const categoryId = this.getNodeParameter('id', i);
|
|
417
|
+
const endpoint = `crm.category.delete`;
|
|
418
|
+
await this.helpers.httpRequest({
|
|
419
|
+
method: 'POST',
|
|
420
|
+
baseURL: webhookUrl,
|
|
421
|
+
url: endpoint,
|
|
422
|
+
body: {
|
|
423
|
+
entityTypeId: 2,
|
|
424
|
+
id: categoryId
|
|
425
|
+
},
|
|
426
|
+
json: true,
|
|
427
|
+
});
|
|
428
|
+
returnData.push({ success: true, id: categoryId });
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
if (resource === 'status') {
|
|
432
|
+
if (operation === 'create' || operation === 'update') {
|
|
433
|
+
const multipleItems = this.getNodeParameter('multipleItems', i);
|
|
434
|
+
const categoryId = this.getNodeParameter('categoryId', i);
|
|
435
|
+
const method = operation === 'create' ? 'add' : 'update';
|
|
436
|
+
const endpoint = `crm.status.${method}`;
|
|
437
|
+
if (multipleItems) {
|
|
438
|
+
const itemsData = this.getNodeParameter('statusItems.statuses', i, []);
|
|
439
|
+
for (const item of itemsData) {
|
|
440
|
+
const params = {
|
|
441
|
+
fields: {
|
|
442
|
+
NAME: item.name,
|
|
443
|
+
SORT: item.sort || 100,
|
|
444
|
+
COLOR: item.color || '#00FF00',
|
|
445
|
+
SEMANTIC_INFO: { CODE: item.semantic || 'P' },
|
|
446
|
+
CATEGORY_ID: categoryId,
|
|
447
|
+
ENTITY_ID: `DEAL_STAGE_${categoryId}`,
|
|
448
|
+
STATUS_ID: `${categoryId}_${item.sort || 100}`,
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
if (operation === 'update' && item.id) {
|
|
452
|
+
params.id = item.id;
|
|
453
|
+
}
|
|
454
|
+
const response = await this.helpers.httpRequest({
|
|
455
|
+
method: 'POST',
|
|
456
|
+
baseURL: webhookUrl,
|
|
457
|
+
url: endpoint,
|
|
458
|
+
body: params,
|
|
459
|
+
json: true,
|
|
460
|
+
});
|
|
461
|
+
if (response && response.result) {
|
|
462
|
+
returnData.push({
|
|
463
|
+
success: true,
|
|
464
|
+
id: response.result,
|
|
465
|
+
...params.fields,
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
const statusName = this.getNodeParameter('statusName', i);
|
|
472
|
+
const statusSort = this.getNodeParameter('statusSort', i);
|
|
473
|
+
const statusColor = this.getNodeParameter('statusColor', i);
|
|
474
|
+
const statusSemantic = this.getNodeParameter('statusSemantic', i);
|
|
475
|
+
const params = {
|
|
476
|
+
fields: {
|
|
477
|
+
NAME: statusName,
|
|
478
|
+
SORT: statusSort,
|
|
479
|
+
COLOR: statusColor,
|
|
480
|
+
SEMANTIC_INFO: { CODE: statusSemantic },
|
|
481
|
+
CATEGORY_ID: categoryId,
|
|
482
|
+
ENTITY_ID: `DEAL_STAGE_${categoryId}`,
|
|
483
|
+
STATUS_ID: `${categoryId}_${statusSort}`,
|
|
484
|
+
},
|
|
485
|
+
};
|
|
486
|
+
if (operation === 'update') {
|
|
487
|
+
const statusId = this.getNodeParameter('id', i);
|
|
488
|
+
params.id = statusId;
|
|
489
|
+
}
|
|
490
|
+
const response = await this.helpers.httpRequest({
|
|
491
|
+
method: 'POST',
|
|
492
|
+
baseURL: webhookUrl,
|
|
493
|
+
url: endpoint,
|
|
494
|
+
body: params,
|
|
495
|
+
json: true,
|
|
496
|
+
});
|
|
497
|
+
if (response && response.result) {
|
|
498
|
+
returnData.push({
|
|
499
|
+
success: true,
|
|
500
|
+
id: response.result,
|
|
501
|
+
...params.fields,
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
if (operation === 'get') {
|
|
507
|
+
const statusId = this.getNodeParameter('id', i);
|
|
508
|
+
const endpoint = `crm.status.get`;
|
|
509
|
+
const response = await this.helpers.httpRequest({
|
|
510
|
+
method: 'POST',
|
|
511
|
+
baseURL: webhookUrl,
|
|
512
|
+
url: endpoint,
|
|
513
|
+
body: { id: statusId },
|
|
514
|
+
json: true,
|
|
515
|
+
});
|
|
516
|
+
returnData.push(response.data);
|
|
517
|
+
}
|
|
518
|
+
if (operation === 'getAll') {
|
|
519
|
+
const categoryId = this.getNodeParameter('categoryId', i);
|
|
520
|
+
const entityId = categoryId === '0' ? 'DEAL_STAGE' : `DEAL_STAGE_${categoryId}`;
|
|
521
|
+
const endpoint = `crm.status.list`;
|
|
522
|
+
const response = await this.helpers.httpRequest({
|
|
523
|
+
method: 'POST',
|
|
524
|
+
baseURL: webhookUrl,
|
|
525
|
+
url: endpoint,
|
|
526
|
+
body: {
|
|
527
|
+
filter: {
|
|
528
|
+
ENTITY_ID: entityId
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
json: true,
|
|
532
|
+
});
|
|
533
|
+
if (response && response.result) {
|
|
534
|
+
returnData.push(...response.result);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
if (operation === 'delete') {
|
|
538
|
+
const statusId = this.getNodeParameter('id', i);
|
|
539
|
+
const endpoint = `crm.status.delete`;
|
|
540
|
+
await this.helpers.httpRequest({
|
|
541
|
+
method: 'POST',
|
|
542
|
+
baseURL: webhookUrl,
|
|
543
|
+
url: endpoint,
|
|
544
|
+
body: { id: statusId },
|
|
545
|
+
json: true,
|
|
546
|
+
});
|
|
547
|
+
returnData.push({ success: true, id: statusId });
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
catch (error) {
|
|
552
|
+
if (this.continueOnFail()) {
|
|
553
|
+
returnData.push({ error: error.message });
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
throw error;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return [this.helpers.returnJsonArray(returnData)];
|
|
560
|
+
}
|
|
561
|
+
catch (error) {
|
|
562
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
exports.Bitrix24Auxiliary = Bitrix24Auxiliary;
|