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.
Files changed (51) hide show
  1. package/LICENSE +51 -0
  2. package/README.md +340 -0
  3. package/dist/credentials/Bitrix24Api.credentials.js +55 -0
  4. package/dist/nodes/Bitrix24/Bitrix24.node.js +1410 -0
  5. package/dist/nodes/Bitrix24/Company.js +17 -0
  6. package/dist/nodes/Bitrix24/Contact.js +31 -0
  7. package/dist/nodes/Bitrix24/Deal.js +17 -0
  8. package/dist/nodes/Bitrix24/Helpers.js +300 -0
  9. package/dist/nodes/Bitrix24/Lead.js +17 -0
  10. package/dist/nodes/Bitrix24/SmartProcess.js +1 -0
  11. package/dist/nodes/Bitrix24/bitrix24.svg +7 -0
  12. package/dist/nodes/Bitrix24/types.js +58 -0
  13. package/dist/nodes/Bitrix24AI/Bitrix24AI.node.js +205 -0
  14. package/dist/nodes/Bitrix24App/Bitrix24App.node.js +179 -0
  15. package/dist/nodes/Bitrix24Auxiliary/Bitrix24Auxiliary.node.js +566 -0
  16. package/dist/nodes/Bitrix24Booking/Bitrix24Booking.node.js +871 -0
  17. package/dist/nodes/Bitrix24Calendar/Bitrix24Calendar.node.js +471 -0
  18. package/dist/nodes/Bitrix24ChatBot/Bitrix24ChatBot.node.js +522 -0
  19. package/dist/nodes/Bitrix24Commerce/Bitrix24Commerce.node.js +431 -0
  20. package/dist/nodes/Bitrix24Department/Bitrix24Department.node.js +317 -0
  21. package/dist/nodes/Bitrix24Disk/Bitrix24Disk.node.js +334 -0
  22. package/dist/nodes/Bitrix24Document/Bitrix24Document.node.js +280 -0
  23. package/dist/nodes/Bitrix24Entity/Bitrix24Entity.node.js +263 -0
  24. package/dist/nodes/Bitrix24Group/Bitrix24Group.node.js +327 -0
  25. package/dist/nodes/Bitrix24Lists/Bitrix24Lists.node.js +406 -0
  26. package/dist/nodes/Bitrix24Log/Bitrix24Log.node.js +309 -0
  27. package/dist/nodes/Bitrix24Mail/Bitrix24Mail.node.js +109 -0
  28. package/dist/nodes/Bitrix24MessageService/Bitrix24MessageService.node.js +218 -0
  29. package/dist/nodes/Bitrix24OpenChannels/Bitrix24OpenChannels.node.js +379 -0
  30. package/dist/nodes/Bitrix24PaySystem/Bitrix24PaySystem.node.js +241 -0
  31. package/dist/nodes/Bitrix24Pipeline/Bitrix24Pipeline.node.js +553 -0
  32. package/dist/nodes/Bitrix24Pipeline/bitrix24.svg +7 -0
  33. package/dist/nodes/Bitrix24Sale/Bitrix24Sale.node.js +391 -0
  34. package/dist/nodes/Bitrix24Scrum/Bitrix24Scrum.node.js +555 -0
  35. package/dist/nodes/Bitrix24Scrum/bitrix24.svg +7 -0
  36. package/dist/nodes/Bitrix24Sign/Bitrix24Sign.node.js +132 -0
  37. package/dist/nodes/Bitrix24Social/Bitrix24Social.node.js +224 -0
  38. package/dist/nodes/Bitrix24Task/Bitrix24Task.node.js +444 -0
  39. package/dist/nodes/Bitrix24Telephony/Bitrix24Telephony.node.js +511 -0
  40. package/dist/nodes/Bitrix24Timeman/Bitrix24Timeman.node.js +196 -0
  41. package/dist/nodes/Bitrix24Tool/Bitrix24Tool.node.js +1035 -0
  42. package/dist/nodes/Bitrix24Tool/bitrix24.svg +7 -0
  43. package/dist/nodes/Bitrix24Trigger/Bitrix24Trigger.node.js +184 -0
  44. package/dist/nodes/Bitrix24User/Bitrix24User.node.js +351 -0
  45. package/dist/nodes/Bitrix24UserField/Bitrix24UserField.node.js +386 -0
  46. package/dist/nodes/Bitrix24UserField/bitrix24.svg +7 -0
  47. package/dist/nodes/shared/bitrix24.svg +7 -0
  48. package/dist/nodes/shared/localization.js +189 -0
  49. package/dist/nodes/shared/types.js +22 -0
  50. package/index.js +10 -0
  51. package/package.json +108 -0
@@ -0,0 +1,309 @@
1
+ "use strict";
2
+ /**
3
+ * Bitrix24 Log — Нода ленты новостей
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.Bitrix24Log = void 0;
17
+ const Helpers_1 = require("../Bitrix24/Helpers");
18
+ class Bitrix24Log {
19
+ constructor() {
20
+ this.description = {
21
+ displayName: 'Bitrix24 Лента',
22
+ name: 'bitrix24Log',
23
+ icon: 'file:bitrix24.svg',
24
+ group: ['transform'],
25
+ version: 1,
26
+ subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
27
+ description: 'Управление лентой новостей: посты, комментарии, важные сообщения',
28
+ defaults: {
29
+ name: 'Bitrix24 Лента',
30
+ },
31
+ inputs: ['main'],
32
+ outputs: ['main'],
33
+ credentials: [
34
+ {
35
+ name: 'bitrix24Api',
36
+ required: true,
37
+ },
38
+ ],
39
+ properties: [
40
+ {
41
+ displayName: 'Resource',
42
+ name: 'resource',
43
+ type: 'options',
44
+ noDataExpression: true,
45
+ options: [
46
+ {
47
+ name: 'Post',
48
+ value: 'post',
49
+ description: 'Manage Feed posts',
50
+ },
51
+ {
52
+ name: 'Comment',
53
+ value: 'comment',
54
+ description: 'Manage comments',
55
+ },
56
+ ],
57
+ default: 'post',
58
+ required: true,
59
+ },
60
+ {
61
+ displayName: 'Operation',
62
+ name: 'operation',
63
+ type: 'options',
64
+ noDataExpression: true,
65
+ options: [
66
+ // Post
67
+ {
68
+ name: 'Create',
69
+ value: 'create',
70
+ action: 'Create a post',
71
+ displayOptions: { show: { resource: ['post'] } },
72
+ },
73
+ {
74
+ name: 'Update',
75
+ value: 'update',
76
+ action: 'Update a post',
77
+ displayOptions: { show: { resource: ['post'] } },
78
+ },
79
+ {
80
+ name: 'Delete',
81
+ value: 'delete',
82
+ action: 'Delete a post',
83
+ displayOptions: { show: { resource: ['post'] } },
84
+ },
85
+ {
86
+ name: 'Get',
87
+ value: 'get',
88
+ action: 'Get posts',
89
+ displayOptions: { show: { resource: ['post'] } },
90
+ },
91
+ {
92
+ name: 'Get Viewers',
93
+ value: 'getViewers', // log.blogpost.getusers.important
94
+ action: 'Get users who read important post',
95
+ displayOptions: { show: { resource: ['post'] } },
96
+ },
97
+ // Comment
98
+ {
99
+ name: 'Create',
100
+ value: 'create',
101
+ action: 'Add a comment',
102
+ displayOptions: { show: { resource: ['comment'] } },
103
+ },
104
+ {
105
+ name: 'Delete',
106
+ value: 'delete',
107
+ action: 'Delete a comment',
108
+ displayOptions: { show: { resource: ['comment'] } },
109
+ },
110
+ ],
111
+ default: 'create',
112
+ required: true,
113
+ },
114
+ // Fields
115
+ {
116
+ displayName: 'Post ID',
117
+ name: 'postId',
118
+ type: 'string',
119
+ default: '',
120
+ displayOptions: { show: { resource: ['post'], operation: ['update', 'delete', 'getViewers'] } },
121
+ required: true,
122
+ },
123
+ {
124
+ displayName: 'Title',
125
+ name: 'title',
126
+ type: 'string',
127
+ default: '',
128
+ displayOptions: { show: { resource: ['post'], operation: ['create', 'update'] } },
129
+ description: 'Post title',
130
+ required: true,
131
+ },
132
+ {
133
+ displayName: 'Message',
134
+ name: 'message',
135
+ type: 'string',
136
+ typeOptions: { rows: 4 },
137
+ default: '',
138
+ displayOptions: { show: { resource: ['post', 'comment'], operation: ['create', 'update'] } },
139
+ description: 'Post text. Supports BB-codes.',
140
+ required: true,
141
+ },
142
+ {
143
+ displayName: 'Important',
144
+ name: 'important',
145
+ type: 'boolean',
146
+ default: false,
147
+ displayOptions: { show: { resource: ['post'], operation: ['create', 'update'] } },
148
+ description: 'Whether the post is important (announcement)',
149
+ },
150
+ {
151
+ displayName: 'Recipient Type',
152
+ name: 'recipientType',
153
+ type: 'options',
154
+ options: [
155
+ { name: 'All Employees', value: 'UA' },
156
+ { name: 'Workgroup', value: 'SG' },
157
+ { name: 'User', value: 'U' },
158
+ { name: 'Department', value: 'DR' },
159
+ { name: 'Custom', value: 'custom' },
160
+ ],
161
+ default: 'UA',
162
+ displayOptions: { show: { resource: ['post'], operation: ['create'] } },
163
+ description: 'Who will see this post',
164
+ },
165
+ {
166
+ displayName: 'Recipient ID',
167
+ name: 'recipientId',
168
+ type: 'string',
169
+ default: '',
170
+ displayOptions: {
171
+ show: {
172
+ resource: ['post'],
173
+ operation: ['create'],
174
+ recipientType: ['SG', 'U', 'DR'],
175
+ }
176
+ },
177
+ description: 'ID of Group, User or Department',
178
+ },
179
+ {
180
+ displayName: 'Custom Destinations',
181
+ name: 'customDest',
182
+ type: 'string',
183
+ default: '',
184
+ displayOptions: {
185
+ show: {
186
+ resource: ['post'],
187
+ operation: ['create'],
188
+ recipientType: ['custom'],
189
+ }
190
+ },
191
+ description: 'Comma separated codes e.g. UA,SG1,U5',
192
+ },
193
+ {
194
+ displayName: 'Files (Base64)',
195
+ name: 'files',
196
+ type: 'json',
197
+ default: '',
198
+ displayOptions: { show: { resource: ['post'], operation: ['create', 'update'] } },
199
+ description: 'Array of file objects: [["name.txt", "base64String"]]',
200
+ },
201
+ // Comment Fields
202
+ {
203
+ displayName: 'Post ID (for Comment)',
204
+ name: 'commentPostId',
205
+ type: 'string',
206
+ default: '',
207
+ displayOptions: { show: { resource: ['comment'], operation: ['create'] } },
208
+ required: true,
209
+ },
210
+ {
211
+ displayName: 'Comment ID',
212
+ name: 'commentId',
213
+ type: 'string',
214
+ default: '',
215
+ displayOptions: { show: { resource: ['comment'], operation: ['delete'] } },
216
+ required: true,
217
+ },
218
+ ],
219
+ };
220
+ }
221
+ async execute() {
222
+ const items = this.getInputData();
223
+ const returnData = [];
224
+ const resource = this.getNodeParameter('resource', 0);
225
+ const operation = this.getNodeParameter('operation', 0);
226
+ for (let i = 0; i < items.length; i++) {
227
+ try {
228
+ let endpoint = '';
229
+ let body = {};
230
+ if (resource === 'post') {
231
+ if (operation === 'create') {
232
+ endpoint = 'log.blogpost.add';
233
+ body.TITLE = this.getNodeParameter('title', i);
234
+ body.DETAIL_TEXT = this.getNodeParameter('message', i);
235
+ if (this.getNodeParameter('important', i)) {
236
+ body.IMPORTANT = 'Y';
237
+ }
238
+ // Recipients
239
+ const recType = this.getNodeParameter('recipientType', i);
240
+ let dest = [];
241
+ if (recType === 'UA')
242
+ dest.push('UA');
243
+ else if (recType === 'custom') {
244
+ const custom = this.getNodeParameter('customDest', i);
245
+ dest = custom.split(',').map(s => s.trim());
246
+ }
247
+ else {
248
+ const id = this.getNodeParameter('recipientId', i);
249
+ dest.push(recType + id);
250
+ }
251
+ body.DEST = dest;
252
+ // Files
253
+ const files = this.getNodeParameter('files', i, []);
254
+ if (files && Array.isArray(files) && files.length > 0) {
255
+ body.FILES = files;
256
+ }
257
+ }
258
+ else if (operation === 'update') {
259
+ endpoint = 'log.blogpost.update';
260
+ body.POST_ID = this.getNodeParameter('postId', i);
261
+ body.TITLE = this.getNodeParameter('title', i);
262
+ body.DETAIL_TEXT = this.getNodeParameter('message', i);
263
+ }
264
+ else if (operation === 'delete') {
265
+ endpoint = 'log.blogpost.delete';
266
+ body.POST_ID = this.getNodeParameter('postId', i);
267
+ }
268
+ else if (operation === 'get') {
269
+ endpoint = 'log.blogpost.get';
270
+ }
271
+ else if (operation === 'getViewers') {
272
+ endpoint = 'log.blogpost.getusers.important';
273
+ body.POST_ID = this.getNodeParameter('postId', i);
274
+ }
275
+ }
276
+ else if (resource === 'comment') {
277
+ if (operation === 'create') {
278
+ endpoint = 'log.blogcomment.add';
279
+ body.POST_ID = this.getNodeParameter('commentPostId', i);
280
+ body.TEXT = this.getNodeParameter('message', i);
281
+ }
282
+ else if (operation === 'delete') {
283
+ endpoint = 'log.blogcomment.delete';
284
+ body.COMMENT_ID = this.getNodeParameter('commentId', i);
285
+ }
286
+ }
287
+ const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', endpoint, body);
288
+ let result = response.result;
289
+ if (Array.isArray(result)) {
290
+ for (const item of result) {
291
+ returnData.push({ json: item, pairedItem: { item: i } });
292
+ }
293
+ }
294
+ else {
295
+ returnData.push({ json: result, pairedItem: { item: i } });
296
+ }
297
+ }
298
+ catch (error) {
299
+ if (this.continueOnFail()) {
300
+ returnData.push({ json: { error: error.message }, pairedItem: { item: i } });
301
+ continue;
302
+ }
303
+ throw error;
304
+ }
305
+ }
306
+ return [returnData];
307
+ }
308
+ }
309
+ exports.Bitrix24Log = Bitrix24Log;
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ /**
3
+ * Bitrix24 Mail — Нода почтовых ящиков
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.Bitrix24Mail = void 0;
17
+ const Helpers_1 = require("../Bitrix24/Helpers");
18
+ class Bitrix24Mail {
19
+ constructor() {
20
+ this.description = {
21
+ displayName: 'Bitrix24 Почта',
22
+ name: 'bitrix24Mail',
23
+ icon: 'file:bitrix24.svg',
24
+ group: ['transform'],
25
+ version: 1,
26
+ subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
27
+ description: 'Управление почтовыми ящиками в Битрикс24',
28
+ defaults: {
29
+ name: 'Bitrix24 Почта',
30
+ },
31
+ inputs: ['main'],
32
+ outputs: ['main'],
33
+ credentials: [
34
+ {
35
+ name: 'bitrix24Api',
36
+ required: true,
37
+ },
38
+ ],
39
+ properties: [
40
+ {
41
+ displayName: 'Resource',
42
+ name: 'resource',
43
+ type: 'options',
44
+ noDataExpression: true,
45
+ options: [
46
+ {
47
+ name: 'Mailbox',
48
+ value: 'mailbox',
49
+ },
50
+ ],
51
+ default: 'mailbox',
52
+ required: true,
53
+ },
54
+ {
55
+ displayName: 'Operation',
56
+ name: 'operation',
57
+ type: 'options',
58
+ noDataExpression: true,
59
+ options: [
60
+ {
61
+ name: 'List',
62
+ value: 'list',
63
+ action: 'List mailboxes',
64
+ displayOptions: { show: { resource: ['mailbox'] } },
65
+ },
66
+ ],
67
+ default: 'list',
68
+ required: true,
69
+ },
70
+ ],
71
+ };
72
+ }
73
+ async execute() {
74
+ const items = this.getInputData();
75
+ const returnData = [];
76
+ const resource = this.getNodeParameter('resource', 0);
77
+ const operation = this.getNodeParameter('operation', 0);
78
+ for (let i = 0; i < items.length; i++) {
79
+ try {
80
+ let endpoint = '';
81
+ let body = {};
82
+ if (resource === 'mailbox') {
83
+ if (operation === 'list') {
84
+ endpoint = 'mailservice.mailbox.list';
85
+ }
86
+ }
87
+ const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', endpoint, body);
88
+ let result = response.result;
89
+ if (Array.isArray(result)) {
90
+ for (const item of result) {
91
+ returnData.push({ json: item, pairedItem: { item: i } });
92
+ }
93
+ }
94
+ else {
95
+ returnData.push({ json: result, pairedItem: { item: i } });
96
+ }
97
+ }
98
+ catch (error) {
99
+ if (this.continueOnFail()) {
100
+ returnData.push({ json: { error: error.message }, pairedItem: { item: i } });
101
+ continue;
102
+ }
103
+ throw error;
104
+ }
105
+ }
106
+ return [returnData];
107
+ }
108
+ }
109
+ exports.Bitrix24Mail = Bitrix24Mail;
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+ /**
3
+ * Bitrix24 MessageService — Нода SMS и мессенджеров
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.Bitrix24MessageService = void 0;
17
+ const Helpers_1 = require("../Bitrix24/Helpers");
18
+ class Bitrix24MessageService {
19
+ constructor() {
20
+ this.description = {
21
+ displayName: 'Bitrix24 SMS и Мессенджеры',
22
+ name: 'bitrix24MessageService',
23
+ icon: 'file:bitrix24.svg',
24
+ group: ['transform'],
25
+ version: 1,
26
+ subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
27
+ description: 'Управление SMS-провайдерами и отправка сообщений',
28
+ defaults: {
29
+ name: 'Bitrix24 SMS',
30
+ },
31
+ inputs: ['main'],
32
+ outputs: ['main'],
33
+ credentials: [
34
+ {
35
+ name: 'bitrix24Api',
36
+ required: true,
37
+ },
38
+ ],
39
+ properties: [
40
+ {
41
+ displayName: 'Resource',
42
+ name: 'resource',
43
+ type: 'options',
44
+ noDataExpression: true,
45
+ options: [
46
+ {
47
+ name: 'Sender (Provider)',
48
+ value: 'sender',
49
+ description: 'Register n8n as a message provider',
50
+ },
51
+ {
52
+ name: 'Message',
53
+ value: 'message',
54
+ description: 'Send messages via providers',
55
+ },
56
+ ],
57
+ default: 'message',
58
+ required: true,
59
+ },
60
+ {
61
+ displayName: 'Operation',
62
+ name: 'operation',
63
+ type: 'options',
64
+ noDataExpression: true,
65
+ options: [
66
+ // Sender
67
+ {
68
+ name: 'Register',
69
+ value: 'add',
70
+ action: 'Register new provider',
71
+ displayOptions: { show: { resource: ['sender'] } },
72
+ },
73
+ {
74
+ name: 'Delete',
75
+ value: 'delete',
76
+ action: 'Delete provider',
77
+ displayOptions: { show: { resource: ['sender'] } },
78
+ },
79
+ // Message
80
+ {
81
+ name: 'Send',
82
+ value: 'send',
83
+ action: 'Send message',
84
+ displayOptions: { show: { resource: ['message'] } },
85
+ },
86
+ ],
87
+ default: 'send',
88
+ required: true,
89
+ },
90
+ // Fields for Sender
91
+ {
92
+ displayName: 'Code',
93
+ name: 'code',
94
+ type: 'string',
95
+ default: 'n8nsms',
96
+ displayOptions: { show: { resource: ['sender'], operation: ['add', 'delete'] } }, // Code is ID
97
+ description: 'Unique code for the provider (a-z0-9)',
98
+ required: true,
99
+ },
100
+ {
101
+ displayName: 'Name',
102
+ name: 'name',
103
+ type: 'string',
104
+ default: 'n8n SMS Provider',
105
+ displayOptions: { show: { resource: ['sender'], operation: ['add'] } },
106
+ description: 'Visible name',
107
+ required: true,
108
+ },
109
+ {
110
+ displayName: 'Handler URL',
111
+ name: 'handlerUrl',
112
+ type: 'string',
113
+ default: '',
114
+ displayOptions: { show: { resource: ['sender'], operation: ['add'] } },
115
+ description: 'Webhook URL of n8n workflow to handle sending',
116
+ required: true,
117
+ },
118
+ {
119
+ displayName: 'Type',
120
+ name: 'type',
121
+ type: 'options',
122
+ options: [
123
+ { name: 'SMS', value: 'SMS' },
124
+ { name: 'Messenger', value: 'IM' },
125
+ ],
126
+ default: 'SMS',
127
+ displayOptions: { show: { resource: ['sender'], operation: ['add'] } },
128
+ required: true,
129
+ },
130
+ // Fields for Message Send
131
+ {
132
+ displayName: 'Sender ID',
133
+ name: 'senderId',
134
+ type: 'string',
135
+ default: 'sms',
136
+ displayOptions: { show: { resource: ['message'], operation: ['send'] } },
137
+ description: 'Provider ID (e.g. "sms", "bitrix24", or your custom code)',
138
+ required: true,
139
+ },
140
+ {
141
+ displayName: 'Recipient',
142
+ name: 'recipient',
143
+ type: 'string', // Usually phone number or user ID
144
+ default: '',
145
+ displayOptions: { show: { resource: ['message'], operation: ['send'] } },
146
+ description: 'Phone number or ID',
147
+ required: true,
148
+ },
149
+ {
150
+ displayName: 'Message',
151
+ name: 'message',
152
+ type: 'string',
153
+ default: '',
154
+ displayOptions: { show: { resource: ['message'], operation: ['send'] } },
155
+ required: true,
156
+ },
157
+ ],
158
+ };
159
+ }
160
+ async execute() {
161
+ const items = this.getInputData();
162
+ const returnData = [];
163
+ const resource = this.getNodeParameter('resource', 0);
164
+ const operation = this.getNodeParameter('operation', 0);
165
+ for (let i = 0; i < items.length; i++) {
166
+ try {
167
+ let endpoint = '';
168
+ let body = {};
169
+ if (resource === 'sender') {
170
+ if (operation === 'add') {
171
+ endpoint = 'messageservice.sender.add';
172
+ body.CODE = this.getNodeParameter('code', i);
173
+ body.NAME = this.getNodeParameter('name', i);
174
+ body.HANDLER = this.getNodeParameter('handlerUrl', i);
175
+ body.TYPE = this.getNodeParameter('type', i);
176
+ }
177
+ else if (operation === 'delete') {
178
+ endpoint = 'messageservice.sender.delete';
179
+ body.CODE = this.getNodeParameter('code', i);
180
+ }
181
+ }
182
+ else if (resource === 'message') {
183
+ if (operation === 'send') {
184
+ endpoint = 'messageservice.message.send';
185
+ body.SENDER_ID = this.getNodeParameter('senderId', i);
186
+ // Structure depends on detailed API, simplified here
187
+ // Usually: RECIPIENT_ID and MESSAGE_BODY
188
+ // But documentation says "FROM_USER_ID", "TO_USER_ID" for internal
189
+ // For SMS it's often a structured array.
190
+ // Assuming simple structure for now based on standard "send"
191
+ body.MESSAGE_FROM = '';
192
+ body.MESSAGE_TO = this.getNodeParameter('recipient', i);
193
+ body.MESSAGE_BODY = this.getNodeParameter('message', i);
194
+ }
195
+ }
196
+ const response = await Helpers_1.bitrixRequestWithRetry.call(this, 'POST', endpoint, body);
197
+ let result = response.result;
198
+ if (Array.isArray(result)) {
199
+ for (const item of result) {
200
+ returnData.push({ json: item, pairedItem: { item: i } });
201
+ }
202
+ }
203
+ else {
204
+ returnData.push({ json: result, pairedItem: { item: i } });
205
+ }
206
+ }
207
+ catch (error) {
208
+ if (this.continueOnFail()) {
209
+ returnData.push({ json: { error: error.message }, pairedItem: { item: i } });
210
+ continue;
211
+ }
212
+ throw error;
213
+ }
214
+ }
215
+ return [returnData];
216
+ }
217
+ }
218
+ exports.Bitrix24MessageService = Bitrix24MessageService;