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,871 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bitrix24 Booking — Нода бронирования ресурсов
|
|
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.Bitrix24Booking = void 0;
|
|
17
|
+
const Helpers_1 = require("../Bitrix24/Helpers");
|
|
18
|
+
class Bitrix24Booking {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.description = {
|
|
21
|
+
displayName: 'Bitrix24 Бронирование',
|
|
22
|
+
name: 'bitrix24Booking',
|
|
23
|
+
icon: 'file:bitrix24.svg',
|
|
24
|
+
group: ['transform'],
|
|
25
|
+
version: 1,
|
|
26
|
+
description: 'Управление бронированием ресурсов, слотами времени и записями',
|
|
27
|
+
defaults: {
|
|
28
|
+
name: 'Bitrix24 Бронирование',
|
|
29
|
+
},
|
|
30
|
+
inputs: ['main'],
|
|
31
|
+
outputs: ['main'],
|
|
32
|
+
credentials: [
|
|
33
|
+
{
|
|
34
|
+
name: 'bitrix24Api',
|
|
35
|
+
required: true,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
properties: [
|
|
39
|
+
// ----------------------------------
|
|
40
|
+
// Resource Selection
|
|
41
|
+
// ----------------------------------
|
|
42
|
+
{
|
|
43
|
+
displayName: 'Resource',
|
|
44
|
+
name: 'resource',
|
|
45
|
+
type: 'options',
|
|
46
|
+
noDataExpression: true,
|
|
47
|
+
options: [
|
|
48
|
+
{
|
|
49
|
+
name: 'Booking',
|
|
50
|
+
value: 'booking',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'Resource',
|
|
54
|
+
value: 'resource',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'Resource Type',
|
|
58
|
+
value: 'resourceType',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'Waitlist',
|
|
62
|
+
value: 'waitlist',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
default: 'booking',
|
|
66
|
+
},
|
|
67
|
+
// ----------------------------------
|
|
68
|
+
// Operations
|
|
69
|
+
// ----------------------------------
|
|
70
|
+
// Booking Operations
|
|
71
|
+
{
|
|
72
|
+
displayName: 'Operation',
|
|
73
|
+
name: 'operation',
|
|
74
|
+
type: 'options',
|
|
75
|
+
noDataExpression: true,
|
|
76
|
+
displayOptions: {
|
|
77
|
+
show: {
|
|
78
|
+
resource: ['booking'],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
options: [
|
|
82
|
+
{
|
|
83
|
+
name: 'Create',
|
|
84
|
+
value: 'create',
|
|
85
|
+
description: 'Create a new booking',
|
|
86
|
+
action: 'Create a booking',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'Delete',
|
|
90
|
+
value: 'delete',
|
|
91
|
+
description: 'Delete a booking',
|
|
92
|
+
action: 'Delete a booking',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'Get',
|
|
96
|
+
value: 'get',
|
|
97
|
+
description: 'Get a booking',
|
|
98
|
+
action: 'Get a booking',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'List',
|
|
102
|
+
value: 'list',
|
|
103
|
+
description: 'Retrieve all bookings',
|
|
104
|
+
action: 'List bookings',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'Update',
|
|
108
|
+
value: 'update',
|
|
109
|
+
description: 'Update a booking',
|
|
110
|
+
action: 'Update a booking',
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
default: 'list',
|
|
114
|
+
},
|
|
115
|
+
// Resource Operations
|
|
116
|
+
{
|
|
117
|
+
displayName: 'Operation',
|
|
118
|
+
name: 'operation',
|
|
119
|
+
type: 'options',
|
|
120
|
+
noDataExpression: true,
|
|
121
|
+
displayOptions: {
|
|
122
|
+
show: {
|
|
123
|
+
resource: ['resource'],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
options: [
|
|
127
|
+
{
|
|
128
|
+
name: 'Create',
|
|
129
|
+
value: 'create',
|
|
130
|
+
description: 'Create a new resource',
|
|
131
|
+
action: 'Create a resource',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: 'Delete',
|
|
135
|
+
value: 'delete',
|
|
136
|
+
description: 'Delete a resource',
|
|
137
|
+
action: 'Delete a resource',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: 'Get',
|
|
141
|
+
value: 'get',
|
|
142
|
+
description: 'Get a resource',
|
|
143
|
+
action: 'Get a resource',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: 'List',
|
|
147
|
+
value: 'list',
|
|
148
|
+
description: 'Retrieve all resources',
|
|
149
|
+
action: 'List resources',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: 'Manage Slots',
|
|
153
|
+
value: 'manageSlots',
|
|
154
|
+
description: 'Configure availability slots for a resource',
|
|
155
|
+
action: 'Manage resource slots',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: 'Update',
|
|
159
|
+
value: 'update',
|
|
160
|
+
description: 'Update a resource',
|
|
161
|
+
action: 'Update a resource',
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
default: 'list',
|
|
165
|
+
},
|
|
166
|
+
// Resource Type Operations
|
|
167
|
+
{
|
|
168
|
+
displayName: 'Operation',
|
|
169
|
+
name: 'operation',
|
|
170
|
+
type: 'options',
|
|
171
|
+
noDataExpression: true,
|
|
172
|
+
displayOptions: {
|
|
173
|
+
show: {
|
|
174
|
+
resource: ['resourceType'],
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
options: [
|
|
178
|
+
{
|
|
179
|
+
name: 'Create',
|
|
180
|
+
value: 'create',
|
|
181
|
+
description: 'Create a new resource type',
|
|
182
|
+
action: 'Create a resource type',
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: 'Delete',
|
|
186
|
+
value: 'delete',
|
|
187
|
+
description: 'Delete a resource type',
|
|
188
|
+
action: 'Delete a resource type',
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: 'Get',
|
|
192
|
+
value: 'get',
|
|
193
|
+
description: 'Get a resource type',
|
|
194
|
+
action: 'Get a resource type',
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
name: 'List',
|
|
198
|
+
value: 'list',
|
|
199
|
+
description: 'Retrieve all resource types',
|
|
200
|
+
action: 'List resource types',
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
name: 'Update',
|
|
204
|
+
value: 'update',
|
|
205
|
+
description: 'Update a resource type',
|
|
206
|
+
action: 'Update a resource type',
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
default: 'list',
|
|
210
|
+
},
|
|
211
|
+
// Waitlist Operations
|
|
212
|
+
{
|
|
213
|
+
displayName: 'Operation',
|
|
214
|
+
name: 'operation',
|
|
215
|
+
type: 'options',
|
|
216
|
+
noDataExpression: true,
|
|
217
|
+
displayOptions: {
|
|
218
|
+
show: {
|
|
219
|
+
resource: ['waitlist'],
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
options: [
|
|
223
|
+
{
|
|
224
|
+
name: 'Add',
|
|
225
|
+
value: 'add',
|
|
226
|
+
description: 'Add to waitlist',
|
|
227
|
+
action: 'Add to waitlist',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name: 'Delete',
|
|
231
|
+
value: 'delete',
|
|
232
|
+
description: 'Delete from waitlist',
|
|
233
|
+
action: 'Delete from waitlist',
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: 'Get',
|
|
237
|
+
value: 'get',
|
|
238
|
+
description: 'Get a waitlist item',
|
|
239
|
+
action: 'Get a waitlist item',
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: 'List',
|
|
243
|
+
value: 'list',
|
|
244
|
+
description: 'Retrieve waitlist',
|
|
245
|
+
action: 'List waitlist',
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: 'Update',
|
|
249
|
+
value: 'update',
|
|
250
|
+
description: 'Update a waitlist item',
|
|
251
|
+
action: 'Update a waitlist item',
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
default: 'list',
|
|
255
|
+
},
|
|
256
|
+
// ----------------------------------
|
|
257
|
+
// Shared Fields
|
|
258
|
+
// ----------------------------------
|
|
259
|
+
{
|
|
260
|
+
displayName: 'ID',
|
|
261
|
+
name: 'id',
|
|
262
|
+
type: 'string',
|
|
263
|
+
default: '',
|
|
264
|
+
required: true,
|
|
265
|
+
displayOptions: {
|
|
266
|
+
show: {
|
|
267
|
+
resource: ['booking', 'resource', 'resourceType', 'waitlist'],
|
|
268
|
+
operation: ['get', 'delete', 'update'],
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
description: 'ID of the entity',
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
displayName: 'Resource ID',
|
|
275
|
+
name: 'id',
|
|
276
|
+
type: 'string',
|
|
277
|
+
default: '',
|
|
278
|
+
required: true,
|
|
279
|
+
displayOptions: {
|
|
280
|
+
show: {
|
|
281
|
+
resource: ['resource'],
|
|
282
|
+
operation: ['manageSlots'],
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
description: 'ID of the resource to configure slots for',
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
displayName: 'Name',
|
|
289
|
+
name: 'name',
|
|
290
|
+
type: 'string',
|
|
291
|
+
default: '',
|
|
292
|
+
displayOptions: {
|
|
293
|
+
show: {
|
|
294
|
+
resource: ['booking', 'resource', 'resourceType'],
|
|
295
|
+
operation: ['create', 'update'],
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
description: 'Name of the entity',
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
displayName: 'Description',
|
|
302
|
+
name: 'description',
|
|
303
|
+
type: 'string',
|
|
304
|
+
default: '',
|
|
305
|
+
displayOptions: {
|
|
306
|
+
show: {
|
|
307
|
+
resource: ['booking', 'resource'],
|
|
308
|
+
operation: ['create', 'update'],
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
description: 'Description of the entity',
|
|
312
|
+
},
|
|
313
|
+
// ----------------------------------
|
|
314
|
+
// Booking Specific
|
|
315
|
+
// ----------------------------------
|
|
316
|
+
{
|
|
317
|
+
displayName: 'Resource IDs',
|
|
318
|
+
name: 'resourceIds',
|
|
319
|
+
type: 'string',
|
|
320
|
+
default: '',
|
|
321
|
+
displayOptions: {
|
|
322
|
+
show: {
|
|
323
|
+
resource: ['booking'],
|
|
324
|
+
operation: ['create', 'update'],
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
description: 'Comma separated list of Resource IDs to book (e.g. 5,10)',
|
|
328
|
+
required: true,
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
displayName: 'Start Time',
|
|
332
|
+
name: 'dateFrom',
|
|
333
|
+
type: 'dateTime',
|
|
334
|
+
default: '',
|
|
335
|
+
displayOptions: {
|
|
336
|
+
show: {
|
|
337
|
+
resource: ['booking', 'waitlist'],
|
|
338
|
+
operation: ['create', 'update', 'add'],
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
description: 'Start time of the booking/waitlist',
|
|
342
|
+
required: true,
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
displayName: 'End Time',
|
|
346
|
+
name: 'dateTo',
|
|
347
|
+
type: 'dateTime',
|
|
348
|
+
default: '',
|
|
349
|
+
displayOptions: {
|
|
350
|
+
show: {
|
|
351
|
+
resource: ['booking', 'waitlist'],
|
|
352
|
+
operation: ['create', 'update', 'add'],
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
description: 'End time of the booking/waitlist',
|
|
356
|
+
required: true,
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
displayName: 'Clients',
|
|
360
|
+
name: 'clients',
|
|
361
|
+
type: 'fixedCollection',
|
|
362
|
+
default: {},
|
|
363
|
+
typeOptions: {
|
|
364
|
+
multipleValues: true,
|
|
365
|
+
},
|
|
366
|
+
displayOptions: {
|
|
367
|
+
show: {
|
|
368
|
+
resource: ['booking', 'waitlist'],
|
|
369
|
+
operation: ['create', 'update', 'add'],
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
options: [
|
|
373
|
+
{
|
|
374
|
+
displayName: 'Client',
|
|
375
|
+
name: 'client',
|
|
376
|
+
values: [
|
|
377
|
+
{
|
|
378
|
+
displayName: 'Type',
|
|
379
|
+
name: 'type',
|
|
380
|
+
type: 'options',
|
|
381
|
+
options: [
|
|
382
|
+
{ name: 'Contact', value: 'contact' },
|
|
383
|
+
{ name: 'Company', value: 'company' },
|
|
384
|
+
{ name: 'Lead', value: 'lead' },
|
|
385
|
+
],
|
|
386
|
+
default: 'contact',
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
displayName: 'ID',
|
|
390
|
+
name: 'id',
|
|
391
|
+
type: 'string',
|
|
392
|
+
default: '',
|
|
393
|
+
description: 'ID of the CRM entity',
|
|
394
|
+
},
|
|
395
|
+
],
|
|
396
|
+
},
|
|
397
|
+
],
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
displayName: 'External Data',
|
|
401
|
+
name: 'externalData',
|
|
402
|
+
type: 'fixedCollection',
|
|
403
|
+
default: {},
|
|
404
|
+
typeOptions: {
|
|
405
|
+
multipleValues: true,
|
|
406
|
+
},
|
|
407
|
+
displayOptions: {
|
|
408
|
+
show: {
|
|
409
|
+
resource: ['booking'],
|
|
410
|
+
operation: ['create', 'update'],
|
|
411
|
+
},
|
|
412
|
+
},
|
|
413
|
+
options: [
|
|
414
|
+
{
|
|
415
|
+
displayName: 'Data',
|
|
416
|
+
name: 'data',
|
|
417
|
+
values: [
|
|
418
|
+
{
|
|
419
|
+
displayName: 'Module ID',
|
|
420
|
+
name: 'moduleId',
|
|
421
|
+
type: 'string',
|
|
422
|
+
default: 'crm',
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
displayName: 'Entity Type ID',
|
|
426
|
+
name: 'entityTypeId',
|
|
427
|
+
type: 'string',
|
|
428
|
+
default: 'DEAL',
|
|
429
|
+
description: 'E.g. DEAL, LEAD',
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
displayName: 'Value',
|
|
433
|
+
name: 'value',
|
|
434
|
+
type: 'string',
|
|
435
|
+
default: '',
|
|
436
|
+
description: 'ID of the entity',
|
|
437
|
+
},
|
|
438
|
+
],
|
|
439
|
+
},
|
|
440
|
+
],
|
|
441
|
+
},
|
|
442
|
+
// ----------------------------------
|
|
443
|
+
// Resource Specific
|
|
444
|
+
// ----------------------------------
|
|
445
|
+
{
|
|
446
|
+
displayName: 'Type ID',
|
|
447
|
+
name: 'typeId',
|
|
448
|
+
type: 'string',
|
|
449
|
+
default: '',
|
|
450
|
+
displayOptions: {
|
|
451
|
+
show: {
|
|
452
|
+
resource: ['resource'],
|
|
453
|
+
operation: ['create', 'update'],
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
description: 'ID of the resource type',
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
displayName: 'Is Main',
|
|
460
|
+
name: 'isMain',
|
|
461
|
+
type: 'boolean',
|
|
462
|
+
default: false,
|
|
463
|
+
displayOptions: {
|
|
464
|
+
show: {
|
|
465
|
+
resource: ['resource'],
|
|
466
|
+
operation: ['create', 'update'],
|
|
467
|
+
},
|
|
468
|
+
},
|
|
469
|
+
description: 'Whether this is the main resource',
|
|
470
|
+
},
|
|
471
|
+
// Notifications
|
|
472
|
+
{
|
|
473
|
+
displayName: 'Is Info Notification On',
|
|
474
|
+
name: 'isInfoNotificationOn',
|
|
475
|
+
type: 'boolean',
|
|
476
|
+
default: false,
|
|
477
|
+
displayOptions: {
|
|
478
|
+
show: {
|
|
479
|
+
resource: ['resource'],
|
|
480
|
+
operation: ['create', 'update'],
|
|
481
|
+
},
|
|
482
|
+
},
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
displayName: 'Template Type Info',
|
|
486
|
+
name: 'templateTypeInfo',
|
|
487
|
+
type: 'string',
|
|
488
|
+
default: '',
|
|
489
|
+
displayOptions: {
|
|
490
|
+
show: {
|
|
491
|
+
resource: ['resource'],
|
|
492
|
+
operation: ['create', 'update'],
|
|
493
|
+
},
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
displayName: 'Is Confirmation Notification On',
|
|
498
|
+
name: 'isConfirmationNotificationOn',
|
|
499
|
+
type: 'boolean',
|
|
500
|
+
default: false,
|
|
501
|
+
displayOptions: {
|
|
502
|
+
show: {
|
|
503
|
+
resource: ['resource'],
|
|
504
|
+
operation: ['create', 'update'],
|
|
505
|
+
},
|
|
506
|
+
},
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
displayName: 'Template Type Confirmation',
|
|
510
|
+
name: 'templateTypeConfirmation',
|
|
511
|
+
type: 'string',
|
|
512
|
+
default: '',
|
|
513
|
+
displayOptions: {
|
|
514
|
+
show: {
|
|
515
|
+
resource: ['resource'],
|
|
516
|
+
operation: ['create', 'update'],
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
displayName: 'Is Reminder Notification On',
|
|
522
|
+
name: 'isReminderNotificationOn',
|
|
523
|
+
type: 'boolean',
|
|
524
|
+
default: false,
|
|
525
|
+
displayOptions: {
|
|
526
|
+
show: {
|
|
527
|
+
resource: ['resource'],
|
|
528
|
+
operation: ['create', 'update'],
|
|
529
|
+
},
|
|
530
|
+
},
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
displayName: 'Template Type Reminder',
|
|
534
|
+
name: 'templateTypeReminder',
|
|
535
|
+
type: 'string',
|
|
536
|
+
default: '',
|
|
537
|
+
displayOptions: {
|
|
538
|
+
show: {
|
|
539
|
+
resource: ['resource'],
|
|
540
|
+
operation: ['create', 'update'],
|
|
541
|
+
},
|
|
542
|
+
},
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
displayName: 'Is Feedback Notification On',
|
|
546
|
+
name: 'isFeedbackNotificationOn',
|
|
547
|
+
type: 'boolean',
|
|
548
|
+
default: false,
|
|
549
|
+
displayOptions: {
|
|
550
|
+
show: {
|
|
551
|
+
resource: ['resource'],
|
|
552
|
+
operation: ['create', 'update'],
|
|
553
|
+
},
|
|
554
|
+
},
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
displayName: 'Template Type Feedback',
|
|
558
|
+
name: 'templateTypeFeedback',
|
|
559
|
+
type: 'string',
|
|
560
|
+
default: '',
|
|
561
|
+
displayOptions: {
|
|
562
|
+
show: {
|
|
563
|
+
resource: ['resource'],
|
|
564
|
+
operation: ['create', 'update'],
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
displayName: 'Is Delayed Notification On',
|
|
570
|
+
name: 'isDelayedNotificationOn',
|
|
571
|
+
type: 'boolean',
|
|
572
|
+
default: false,
|
|
573
|
+
displayOptions: {
|
|
574
|
+
show: {
|
|
575
|
+
resource: ['resource'],
|
|
576
|
+
operation: ['create', 'update'],
|
|
577
|
+
},
|
|
578
|
+
},
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
displayName: 'Template Type Delayed',
|
|
582
|
+
name: 'templateTypeDelayed',
|
|
583
|
+
type: 'string',
|
|
584
|
+
default: '',
|
|
585
|
+
displayOptions: {
|
|
586
|
+
show: {
|
|
587
|
+
resource: ['resource'],
|
|
588
|
+
operation: ['create', 'update'],
|
|
589
|
+
},
|
|
590
|
+
},
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
displayName: 'Slots (JSON)',
|
|
594
|
+
name: 'slots',
|
|
595
|
+
type: 'json',
|
|
596
|
+
default: '[]',
|
|
597
|
+
displayOptions: {
|
|
598
|
+
show: {
|
|
599
|
+
resource: ['resource'],
|
|
600
|
+
operation: ['manageSlots'],
|
|
601
|
+
},
|
|
602
|
+
},
|
|
603
|
+
description: 'Array of slot objects: [{ from: 480, to: 1020, weekDays: ["Mon", "Fri"], slotSize: 60, timezone: "UTC" }]. Times in minutes from midnight.',
|
|
604
|
+
},
|
|
605
|
+
],
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
async execute() {
|
|
609
|
+
const items = this.getInputData();
|
|
610
|
+
const returnData = [];
|
|
611
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
612
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
613
|
+
for (let i = 0; i < items.length; i++) {
|
|
614
|
+
try {
|
|
615
|
+
let responseData;
|
|
616
|
+
if (resource === 'booking') {
|
|
617
|
+
if (operation === 'get') {
|
|
618
|
+
const id = this.getNodeParameter('id', i);
|
|
619
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'GET', `booking.v1.booking.get?id=${id}`);
|
|
620
|
+
}
|
|
621
|
+
else if (operation === 'delete') {
|
|
622
|
+
const id = this.getNodeParameter('id', i);
|
|
623
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'booking.v1.booking.delete', { id });
|
|
624
|
+
}
|
|
625
|
+
else if (operation === 'create' || operation === 'update') {
|
|
626
|
+
const name = this.getNodeParameter('name', i);
|
|
627
|
+
const description = this.getNodeParameter('description', i);
|
|
628
|
+
const resourceIdsStr = this.getNodeParameter('resourceIds', i);
|
|
629
|
+
const dateFrom = this.getNodeParameter('dateFrom', i);
|
|
630
|
+
const dateTo = this.getNodeParameter('dateTo', i);
|
|
631
|
+
const fields = {};
|
|
632
|
+
if (name)
|
|
633
|
+
fields.name = name;
|
|
634
|
+
if (description)
|
|
635
|
+
fields.description = description;
|
|
636
|
+
if (resourceIdsStr) {
|
|
637
|
+
fields.resourceIds = resourceIdsStr.split(',').map(id => parseInt(id.trim())).filter(id => !isNaN(id));
|
|
638
|
+
}
|
|
639
|
+
if (dateFrom && dateTo) {
|
|
640
|
+
const fromTimestamp = Math.floor(new Date(dateFrom).getTime() / 1000);
|
|
641
|
+
const toTimestamp = Math.floor(new Date(dateTo).getTime() / 1000);
|
|
642
|
+
fields.datePeriod = {
|
|
643
|
+
from: { timestamp: fromTimestamp, timezone: 'UTC' },
|
|
644
|
+
to: { timestamp: toTimestamp, timezone: 'UTC' }
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
let bookingId;
|
|
648
|
+
if (operation === 'create') {
|
|
649
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'booking.v1.booking.add', { fields });
|
|
650
|
+
const resultObj = responseData.result;
|
|
651
|
+
if (resultObj && typeof resultObj === 'object' && resultObj.id) {
|
|
652
|
+
bookingId = resultObj.id;
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
bookingId = responseData.result;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
const id = this.getNodeParameter('id', i);
|
|
660
|
+
bookingId = id;
|
|
661
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'booking.v1.booking.update', { id, fields });
|
|
662
|
+
}
|
|
663
|
+
// Handle Clients (Separate Call)
|
|
664
|
+
const clientsData = this.getNodeParameter('clients', i);
|
|
665
|
+
if (clientsData && clientsData.client && bookingId) {
|
|
666
|
+
const clientsPayload = clientsData.client.map(c => ({
|
|
667
|
+
id: c.id,
|
|
668
|
+
type: {
|
|
669
|
+
module: 'crm',
|
|
670
|
+
code: c.type.toUpperCase()
|
|
671
|
+
}
|
|
672
|
+
}));
|
|
673
|
+
await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'booking.v1.booking.client.set', {
|
|
674
|
+
bookingId: bookingId,
|
|
675
|
+
clients: clientsPayload
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
// Handle External Data (Separate Call)
|
|
679
|
+
const externalDataInput = this.getNodeParameter('externalData', i);
|
|
680
|
+
if (externalDataInput && externalDataInput.data && bookingId) {
|
|
681
|
+
const externalPayload = externalDataInput.data.map(d => ({
|
|
682
|
+
moduleId: d.moduleId,
|
|
683
|
+
entityTypeId: d.entityTypeId,
|
|
684
|
+
value: d.value
|
|
685
|
+
}));
|
|
686
|
+
await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'booking.v1.booking.externalData.set', {
|
|
687
|
+
bookingId: bookingId,
|
|
688
|
+
externalData: externalPayload
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
else if (operation === 'list') {
|
|
693
|
+
// TODO: Add filters
|
|
694
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'GET', 'booking.v1.booking.list');
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
else if (resource === 'resource') {
|
|
698
|
+
if (operation === 'get') {
|
|
699
|
+
const id = this.getNodeParameter('id', i);
|
|
700
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'GET', `booking.v1.resource.get?id=${id}`);
|
|
701
|
+
}
|
|
702
|
+
else if (operation === 'delete') {
|
|
703
|
+
const id = this.getNodeParameter('id', i);
|
|
704
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'booking.v1.resource.delete', { id });
|
|
705
|
+
}
|
|
706
|
+
else if (operation === 'manageSlots') {
|
|
707
|
+
const id = this.getNodeParameter('id', i);
|
|
708
|
+
const slots = this.getNodeParameter('slots', i);
|
|
709
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'booking.v1.resource.slots.set', { resourceId: id, slots });
|
|
710
|
+
}
|
|
711
|
+
else if (operation === 'create' || operation === 'update') {
|
|
712
|
+
const name = this.getNodeParameter('name', i);
|
|
713
|
+
const typeId = this.getNodeParameter('typeId', i);
|
|
714
|
+
const description = this.getNodeParameter('description', i);
|
|
715
|
+
const fields = {};
|
|
716
|
+
if (name)
|
|
717
|
+
fields.name = name;
|
|
718
|
+
if (typeId)
|
|
719
|
+
fields.typeId = parseInt(typeId);
|
|
720
|
+
if (description)
|
|
721
|
+
fields.description = description;
|
|
722
|
+
const boolFields = [
|
|
723
|
+
'isMain', 'isInfoNotificationOn', 'isConfirmationNotificationOn',
|
|
724
|
+
'isReminderNotificationOn', 'isFeedbackNotificationOn', 'isDelayedNotificationOn'
|
|
725
|
+
];
|
|
726
|
+
for (const field of boolFields) {
|
|
727
|
+
try {
|
|
728
|
+
const val = this.getNodeParameter(field, i);
|
|
729
|
+
if (val !== undefined)
|
|
730
|
+
fields[field] = val ? 'Y' : 'N';
|
|
731
|
+
}
|
|
732
|
+
catch (e) { }
|
|
733
|
+
}
|
|
734
|
+
const textFields = [
|
|
735
|
+
'templateTypeInfo', 'templateTypeConfirmation', 'templateTypeReminder',
|
|
736
|
+
'templateTypeFeedback', 'templateTypeDelayed'
|
|
737
|
+
];
|
|
738
|
+
for (const field of textFields) {
|
|
739
|
+
try {
|
|
740
|
+
const val = this.getNodeParameter(field, i);
|
|
741
|
+
if (val)
|
|
742
|
+
fields[field] = val;
|
|
743
|
+
}
|
|
744
|
+
catch (e) { }
|
|
745
|
+
}
|
|
746
|
+
if (operation === 'create') {
|
|
747
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'booking.v1.resource.add', { fields });
|
|
748
|
+
}
|
|
749
|
+
else {
|
|
750
|
+
const id = this.getNodeParameter('id', i);
|
|
751
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'booking.v1.resource.update', { id, fields });
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
else if (operation === 'list') {
|
|
755
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'GET', 'booking.v1.resource.list');
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
else if (resource === 'resourceType') {
|
|
759
|
+
if (operation === 'get') {
|
|
760
|
+
const id = this.getNodeParameter('id', i);
|
|
761
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'GET', `booking.v1.resourcetype.get?id=${id}`);
|
|
762
|
+
}
|
|
763
|
+
else if (operation === 'delete') {
|
|
764
|
+
const id = this.getNodeParameter('id', i);
|
|
765
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'booking.v1.resourcetype.delete', { id });
|
|
766
|
+
}
|
|
767
|
+
else if (operation === 'create' || operation === 'update') {
|
|
768
|
+
const name = this.getNodeParameter('name', i);
|
|
769
|
+
const fields = {};
|
|
770
|
+
if (name)
|
|
771
|
+
fields.name = name;
|
|
772
|
+
if (operation === 'create') {
|
|
773
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'booking.v1.resourcetype.add', { fields });
|
|
774
|
+
}
|
|
775
|
+
else {
|
|
776
|
+
const id = this.getNodeParameter('id', i);
|
|
777
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'booking.v1.resourcetype.update', { id, fields });
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
else if (operation === 'list') {
|
|
781
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'GET', 'booking.v1.resourcetype.list');
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
else if (resource === 'waitlist') {
|
|
785
|
+
if (operation === 'get') {
|
|
786
|
+
const id = this.getNodeParameter('id', i);
|
|
787
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'GET', `booking.v1.waitlist.get?id=${id}`);
|
|
788
|
+
}
|
|
789
|
+
else if (operation === 'delete') {
|
|
790
|
+
const id = this.getNodeParameter('id', i);
|
|
791
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'booking.v1.waitlist.delete', { id });
|
|
792
|
+
}
|
|
793
|
+
else if (operation === 'add' || operation === 'update') {
|
|
794
|
+
const resourceIdsStr = this.getNodeParameter('resourceIds', i);
|
|
795
|
+
const dateFrom = this.getNodeParameter('dateFrom', i);
|
|
796
|
+
const dateTo = this.getNodeParameter('dateTo', i);
|
|
797
|
+
const fields = {};
|
|
798
|
+
if (resourceIdsStr) {
|
|
799
|
+
const ids = resourceIdsStr.split(',').map(id => parseInt(id.trim())).filter(id => !isNaN(id));
|
|
800
|
+
if (ids.length > 0)
|
|
801
|
+
fields.resourceId = ids[0];
|
|
802
|
+
}
|
|
803
|
+
if (dateFrom && dateTo) {
|
|
804
|
+
const fromTimestamp = Math.floor(new Date(dateFrom).getTime() / 1000);
|
|
805
|
+
const toTimestamp = Math.floor(new Date(dateTo).getTime() / 1000);
|
|
806
|
+
fields.datePeriod = {
|
|
807
|
+
from: { timestamp: fromTimestamp, timezone: 'UTC' },
|
|
808
|
+
to: { timestamp: toTimestamp, timezone: 'UTC' }
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
let waitlistId;
|
|
812
|
+
if (operation === 'add') {
|
|
813
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'booking.v1.waitlist.add', { fields });
|
|
814
|
+
const waitlistResult = responseData.result;
|
|
815
|
+
if (waitlistResult?.id)
|
|
816
|
+
waitlistId = waitlistResult.id;
|
|
817
|
+
else
|
|
818
|
+
waitlistId = responseData.result;
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
const id = this.getNodeParameter('id', i);
|
|
822
|
+
waitlistId = id;
|
|
823
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'booking.v1.waitlist.update', { id, fields });
|
|
824
|
+
}
|
|
825
|
+
// Handle Clients for Waitlist
|
|
826
|
+
const clientsData = this.getNodeParameter('clients', i);
|
|
827
|
+
if (clientsData && clientsData.client && waitlistId) {
|
|
828
|
+
const clientsPayload = clientsData.client.map(c => ({
|
|
829
|
+
id: c.id,
|
|
830
|
+
type: { module: 'crm', code: c.type.toUpperCase() }
|
|
831
|
+
}));
|
|
832
|
+
await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', 'booking.v1.waitlist.client.set', {
|
|
833
|
+
waitlistId: waitlistId,
|
|
834
|
+
clients: clientsPayload
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
else if (operation === 'list') {
|
|
839
|
+
responseData = await Helpers_1.bitrixRequestWithRetry.call(this, 'GET', 'booking.v1.waitlist.list');
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
if (responseData === undefined) {
|
|
843
|
+
// No op
|
|
844
|
+
}
|
|
845
|
+
else if (Array.isArray(responseData)) {
|
|
846
|
+
responseData.forEach((item) => returnData.push({ json: item }));
|
|
847
|
+
}
|
|
848
|
+
else if (responseData && responseData.result) {
|
|
849
|
+
if (Array.isArray(responseData.result)) {
|
|
850
|
+
responseData.result.forEach((item) => returnData.push({ json: item }));
|
|
851
|
+
}
|
|
852
|
+
else {
|
|
853
|
+
returnData.push({ json: responseData.result });
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
else {
|
|
857
|
+
returnData.push({ json: responseData });
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
catch (error) {
|
|
861
|
+
if (this.continueOnFail()) {
|
|
862
|
+
returnData.push({ json: { error: error.message } });
|
|
863
|
+
continue;
|
|
864
|
+
}
|
|
865
|
+
throw error;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
return [returnData];
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
exports.Bitrix24Booking = Bitrix24Booking;
|