@yuniruyuni/n8n-nodes-twitch 0.1.6 → 0.1.8

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 (56) hide show
  1. package/dist/credentials/TwitchOAuth2Api.credentials.js +3 -9
  2. package/dist/credentials/TwitchOAuth2Api.credentials.js.map +1 -1
  3. package/dist/nodes/Twitch/resources/Announcement.js +43 -81
  4. package/dist/nodes/Twitch/resources/Announcement.js.map +1 -1
  5. package/dist/nodes/Twitch/resources/Ban.js +36 -169
  6. package/dist/nodes/Twitch/resources/Ban.js.map +1 -1
  7. package/dist/nodes/Twitch/resources/BitsLeaderboard.js +54 -82
  8. package/dist/nodes/Twitch/resources/BitsLeaderboard.js.map +1 -1
  9. package/dist/nodes/Twitch/resources/Channel.js +13 -15
  10. package/dist/nodes/Twitch/resources/Channel.js.map +1 -1
  11. package/dist/nodes/Twitch/resources/ChatMessage.js +26 -49
  12. package/dist/nodes/Twitch/resources/ChatMessage.js.map +1 -1
  13. package/dist/nodes/Twitch/resources/Chatter.js +1 -49
  14. package/dist/nodes/Twitch/resources/Chatter.js.map +1 -1
  15. package/dist/nodes/Twitch/resources/Cheermote.js +1 -16
  16. package/dist/nodes/Twitch/resources/Cheermote.js.map +1 -1
  17. package/dist/nodes/Twitch/resources/Clip.js +91 -153
  18. package/dist/nodes/Twitch/resources/Clip.js.map +1 -1
  19. package/dist/nodes/Twitch/resources/CustomReward.js +309 -296
  20. package/dist/nodes/Twitch/resources/CustomReward.js.map +1 -1
  21. package/dist/nodes/Twitch/resources/Emote.js +1 -17
  22. package/dist/nodes/Twitch/resources/Emote.js.map +1 -1
  23. package/dist/nodes/Twitch/resources/Game.js +68 -92
  24. package/dist/nodes/Twitch/resources/Game.js.map +1 -1
  25. package/dist/nodes/Twitch/resources/Moderator.js +75 -108
  26. package/dist/nodes/Twitch/resources/Moderator.js.map +1 -1
  27. package/dist/nodes/Twitch/resources/Poll.js +174 -229
  28. package/dist/nodes/Twitch/resources/Poll.js.map +1 -1
  29. package/dist/nodes/Twitch/resources/Prediction.js +143 -201
  30. package/dist/nodes/Twitch/resources/Prediction.js.map +1 -1
  31. package/dist/nodes/Twitch/resources/Raid.js +48 -71
  32. package/dist/nodes/Twitch/resources/Raid.js.map +1 -1
  33. package/dist/nodes/Twitch/resources/Redemption.js +136 -139
  34. package/dist/nodes/Twitch/resources/Redemption.js.map +1 -1
  35. package/dist/nodes/Twitch/resources/Schedule.js +226 -213
  36. package/dist/nodes/Twitch/resources/Schedule.js.map +1 -1
  37. package/dist/nodes/Twitch/resources/Search.js +24 -34
  38. package/dist/nodes/Twitch/resources/Search.js.map +1 -1
  39. package/dist/nodes/Twitch/resources/Stream.js +13 -15
  40. package/dist/nodes/Twitch/resources/Stream.js.map +1 -1
  41. package/dist/nodes/Twitch/resources/Subscription.js +61 -75
  42. package/dist/nodes/Twitch/resources/Subscription.js.map +1 -1
  43. package/dist/nodes/Twitch/resources/Team.js +63 -72
  44. package/dist/nodes/Twitch/resources/Team.js.map +1 -1
  45. package/dist/nodes/Twitch/resources/User.js +13 -15
  46. package/dist/nodes/Twitch/resources/User.js.map +1 -1
  47. package/dist/nodes/Twitch/resources/Video.js +106 -129
  48. package/dist/nodes/Twitch/resources/Video.js.map +1 -1
  49. package/dist/nodes/Twitch/resources/Whisper.js +32 -28
  50. package/dist/nodes/Twitch/resources/Whisper.js.map +1 -1
  51. package/dist/nodes/Twitch/shared/updateDisplayOptions.d.ts +2 -0
  52. package/dist/nodes/Twitch/shared/updateDisplayOptions.js +12 -0
  53. package/dist/nodes/Twitch/shared/updateDisplayOptions.js.map +1 -0
  54. package/dist/package.json +1 -1
  55. package/dist/tsconfig.tsbuildinfo +1 -1
  56. package/package.json +1 -1
@@ -2,247 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.customRewardFields = exports.customRewardOperations = void 0;
4
4
  const userIdConverter_1 = require("../shared/userIdConverter");
5
- exports.customRewardOperations = [
6
- {
7
- displayName: 'Operation',
8
- name: 'operation',
9
- type: 'options',
10
- noDataExpression: true,
11
- displayOptions: {
12
- show: {
13
- resource: ['customReward'],
14
- },
15
- },
16
- options: [
17
- {
18
- name: 'Create',
19
- value: 'create',
20
- action: 'Create a custom reward',
21
- description: 'Create a custom channel points reward',
22
- routing: {
23
- request: {
24
- method: 'POST',
25
- url: '/channel_points/custom_rewards',
26
- },
27
- send: {
28
- preSend: [
29
- async function (requestOptions) {
30
- const broadcasterIdInput = this.getNodeParameter('broadcasterId', 0);
31
- const broadcasterId = await userIdConverter_1.resolveUserIdOrUsername.call(this, broadcasterIdInput);
32
- requestOptions.qs = { broadcaster_id: broadcasterId };
33
- const body = {
34
- title: this.getNodeParameter('title', 0),
35
- cost: this.getNodeParameter('cost', 0),
36
- };
37
- const additionalFields = this.getNodeParameter('additionalFields', 0, {});
38
- if (additionalFields.prompt) {
39
- body.prompt = additionalFields.prompt;
40
- }
41
- if (additionalFields.isEnabled !== undefined) {
42
- body.is_enabled = additionalFields.isEnabled;
43
- }
44
- if (additionalFields.backgroundColor) {
45
- body.background_color = additionalFields.backgroundColor;
46
- }
47
- if (additionalFields.isUserInputRequired !== undefined) {
48
- body.is_user_input_required = additionalFields.isUserInputRequired;
49
- }
50
- if (additionalFields.isMaxPerStreamEnabled !== undefined) {
51
- body.is_max_per_stream_enabled = additionalFields.isMaxPerStreamEnabled;
52
- }
53
- if (additionalFields.maxPerStream) {
54
- body.max_per_stream = additionalFields.maxPerStream;
55
- }
56
- if (additionalFields.isMaxPerUserPerStreamEnabled !== undefined) {
57
- body.is_max_per_user_per_stream_enabled = additionalFields.isMaxPerUserPerStreamEnabled;
58
- }
59
- if (additionalFields.maxPerUserPerStream) {
60
- body.max_per_user_per_stream = additionalFields.maxPerUserPerStream;
61
- }
62
- if (additionalFields.isGlobalCooldownEnabled !== undefined) {
63
- body.is_global_cooldown_enabled = additionalFields.isGlobalCooldownEnabled;
64
- }
65
- if (additionalFields.globalCooldownSeconds) {
66
- body.global_cooldown_seconds = additionalFields.globalCooldownSeconds;
67
- }
68
- if (additionalFields.shouldRedemptionsSkipRequestQueue !== undefined) {
69
- body.should_redemptions_skip_request_queue = additionalFields.shouldRedemptionsSkipRequestQueue;
70
- }
71
- requestOptions.body = body;
72
- return requestOptions;
73
- },
74
- ],
75
- },
76
- output: {
77
- postReceive: [
78
- {
79
- type: 'rootProperty',
80
- properties: {
81
- property: 'data',
82
- },
83
- },
84
- {
85
- type: 'setKeyValue',
86
- properties: {
87
- index: 0,
88
- },
89
- },
90
- ],
91
- },
92
- },
93
- },
94
- {
95
- name: 'Get',
96
- value: 'get',
97
- action: 'Get custom rewards',
98
- description: 'Get custom channel points rewards for a broadcaster',
99
- routing: {
100
- request: {
101
- method: 'GET',
102
- url: '/channel_points/custom_rewards',
103
- },
104
- send: {
105
- preSend: [
106
- async function (requestOptions) {
107
- const broadcasterIdInput = this.getNodeParameter('broadcasterId', 0);
108
- const broadcasterId = await userIdConverter_1.resolveUserIdOrUsername.call(this, broadcasterIdInput);
109
- const qs = { broadcaster_id: broadcasterId };
110
- const additionalFields = this.getNodeParameter('additionalFields', 0, {});
111
- if (additionalFields.id) {
112
- qs.id = additionalFields.id;
113
- }
114
- if (additionalFields.onlyManageableRewards !== undefined) {
115
- qs.only_manageable_rewards = additionalFields.onlyManageableRewards;
116
- }
117
- requestOptions.qs = qs;
118
- return requestOptions;
119
- },
120
- ],
121
- },
122
- output: {
123
- postReceive: [
124
- {
125
- type: 'rootProperty',
126
- properties: {
127
- property: 'data',
128
- },
129
- },
130
- ],
131
- },
132
- },
133
- },
134
- {
135
- name: 'Update',
136
- value: 'update',
137
- action: 'Update a custom reward',
138
- description: 'Update a custom channel points reward',
139
- routing: {
140
- request: {
141
- method: 'PATCH',
142
- url: '/channel_points/custom_rewards',
143
- },
144
- send: {
145
- preSend: [
146
- async function (requestOptions) {
147
- const broadcasterIdInput = this.getNodeParameter('broadcasterId', 0);
148
- const broadcasterId = await userIdConverter_1.resolveUserIdOrUsername.call(this, broadcasterIdInput);
149
- const id = this.getNodeParameter('rewardId', 0);
150
- requestOptions.qs = { broadcaster_id: broadcasterId, id };
151
- const body = {};
152
- const updateFields = this.getNodeParameter('updateFields', 0, {});
153
- if (updateFields.title) {
154
- body.title = updateFields.title;
155
- }
156
- if (updateFields.cost) {
157
- body.cost = updateFields.cost;
158
- }
159
- if (updateFields.prompt !== undefined) {
160
- body.prompt = updateFields.prompt;
161
- }
162
- if (updateFields.isEnabled !== undefined) {
163
- body.is_enabled = updateFields.isEnabled;
164
- }
165
- if (updateFields.backgroundColor) {
166
- body.background_color = updateFields.backgroundColor;
167
- }
168
- if (updateFields.isUserInputRequired !== undefined) {
169
- body.is_user_input_required = updateFields.isUserInputRequired;
170
- }
171
- if (updateFields.isMaxPerStreamEnabled !== undefined) {
172
- body.is_max_per_stream_enabled = updateFields.isMaxPerStreamEnabled;
173
- }
174
- if (updateFields.maxPerStream) {
175
- body.max_per_stream = updateFields.maxPerStream;
176
- }
177
- if (updateFields.isMaxPerUserPerStreamEnabled !== undefined) {
178
- body.is_max_per_user_per_stream_enabled = updateFields.isMaxPerUserPerStreamEnabled;
179
- }
180
- if (updateFields.maxPerUserPerStream) {
181
- body.max_per_user_per_stream = updateFields.maxPerUserPerStream;
182
- }
183
- if (updateFields.isGlobalCooldownEnabled !== undefined) {
184
- body.is_global_cooldown_enabled = updateFields.isGlobalCooldownEnabled;
185
- }
186
- if (updateFields.globalCooldownSeconds) {
187
- body.global_cooldown_seconds = updateFields.globalCooldownSeconds;
188
- }
189
- if (updateFields.isPaused !== undefined) {
190
- body.is_paused = updateFields.isPaused;
191
- }
192
- if (updateFields.shouldRedemptionsSkipRequestQueue !== undefined) {
193
- body.should_redemptions_skip_request_queue = updateFields.shouldRedemptionsSkipRequestQueue;
194
- }
195
- requestOptions.body = body;
196
- return requestOptions;
197
- },
198
- ],
199
- },
200
- output: {
201
- postReceive: [
202
- {
203
- type: 'rootProperty',
204
- properties: {
205
- property: 'data',
206
- },
207
- },
208
- {
209
- type: 'setKeyValue',
210
- properties: {
211
- index: 0,
212
- },
213
- },
214
- ],
215
- },
216
- },
217
- },
218
- {
219
- name: 'Delete',
220
- value: 'delete',
221
- action: 'Delete a custom reward',
222
- description: 'Delete a custom channel points reward',
223
- routing: {
224
- request: {
225
- method: 'DELETE',
226
- url: '/channel_points/custom_rewards',
227
- },
228
- send: {
229
- preSend: [
230
- async function (requestOptions) {
231
- const broadcasterIdInput = this.getNodeParameter('broadcasterId', 0);
232
- const broadcasterId = await userIdConverter_1.resolveUserIdOrUsername.call(this, broadcasterIdInput);
233
- const id = this.getNodeParameter('rewardId', 0);
234
- requestOptions.qs = { broadcaster_id: broadcasterId, id };
235
- return requestOptions;
236
- },
237
- ],
238
- },
239
- },
240
- },
241
- ],
242
- default: 'get',
243
- },
244
- ];
245
- exports.customRewardFields = [
5
+ const updateDisplayOptions_1 = require("../shared/updateDisplayOptions");
6
+ const createFields = [
246
7
  {
247
8
  displayName: 'Broadcaster ID or Username',
248
9
  name: 'broadcasterId',
@@ -251,22 +12,11 @@ exports.customRewardFields = [
251
12
  required: true,
252
13
  placeholder: 'e.g. 123456789 or username',
253
14
  description: 'The broadcaster user ID or username. If a username is provided, it will be automatically converted to user ID.',
254
- displayOptions: {
255
- show: {
256
- resource: ['customReward'],
257
- },
258
- },
259
15
  },
260
16
  {
261
17
  displayName: 'Title',
262
18
  name: 'title',
263
19
  type: 'string',
264
- displayOptions: {
265
- show: {
266
- resource: ['customReward'],
267
- operation: ['create'],
268
- },
269
- },
270
20
  default: '',
271
21
  required: true,
272
22
  placeholder: 'e.g. My Custom Reward',
@@ -276,12 +26,6 @@ exports.customRewardFields = [
276
26
  displayName: 'Cost',
277
27
  name: 'cost',
278
28
  type: 'number',
279
- displayOptions: {
280
- show: {
281
- resource: ['customReward'],
282
- operation: ['create'],
283
- },
284
- },
285
29
  default: 100,
286
30
  required: true,
287
31
  typeOptions: {
@@ -295,12 +39,6 @@ exports.customRewardFields = [
295
39
  type: 'collection',
296
40
  placeholder: 'Add Field',
297
41
  default: {},
298
- displayOptions: {
299
- show: {
300
- resource: ['customReward'],
301
- operation: ['create', 'get'],
302
- },
303
- },
304
42
  options: [
305
43
  {
306
44
  displayName: 'Background Color',
@@ -375,18 +113,6 @@ exports.customRewardFields = [
375
113
  },
376
114
  description: 'The maximum number of redemptions allowed per user per stream',
377
115
  },
378
- {
379
- displayName: 'Only Manageable Rewards',
380
- name: 'onlyManageableRewards',
381
- type: 'boolean',
382
- default: false,
383
- description: 'Whether to filter the results and only return custom rewards that the calling client_id can manage',
384
- displayOptions: {
385
- show: {
386
- '/operation': ['get'],
387
- },
388
- },
389
- },
390
116
  {
391
117
  displayName: 'Prompt',
392
118
  name: 'prompt',
@@ -395,6 +121,33 @@ exports.customRewardFields = [
395
121
  placeholder: 'e.g. Enter your message here',
396
122
  description: 'The prompt shown to the viewer when redeeming the reward (max 200 characters)',
397
123
  },
124
+ {
125
+ displayName: 'Should Redemptions Skip Request Queue',
126
+ name: 'shouldRedemptionsSkipRequestQueue',
127
+ type: 'boolean',
128
+ default: false,
129
+ description: 'Whether redemptions should be automatically fulfilled',
130
+ },
131
+ ],
132
+ },
133
+ ];
134
+ const getFields = [
135
+ {
136
+ displayName: 'Broadcaster ID or Username',
137
+ name: 'broadcasterId',
138
+ type: 'string',
139
+ default: '',
140
+ required: true,
141
+ placeholder: 'e.g. 123456789 or username',
142
+ description: 'The broadcaster user ID or username. If a username is provided, it will be automatically converted to user ID.',
143
+ },
144
+ {
145
+ displayName: 'Additional Fields',
146
+ name: 'additionalFields',
147
+ type: 'collection',
148
+ placeholder: 'Add Field',
149
+ default: {},
150
+ options: [
398
151
  {
399
152
  displayName: 'Reward ID',
400
153
  name: 'id',
@@ -402,31 +155,31 @@ exports.customRewardFields = [
402
155
  default: '',
403
156
  placeholder: 'e.g. 92af127c-7326-4483-a52b-b0da0be61c01',
404
157
  description: 'The ID of the custom reward to get (if not specified, returns all rewards)',
405
- displayOptions: {
406
- show: {
407
- '/operation': ['get'],
408
- },
409
- },
410
158
  },
411
159
  {
412
- displayName: 'Should Redemptions Skip Request Queue',
413
- name: 'shouldRedemptionsSkipRequestQueue',
160
+ displayName: 'Only Manageable Rewards',
161
+ name: 'onlyManageableRewards',
414
162
  type: 'boolean',
415
163
  default: false,
416
- description: 'Whether redemptions should be automatically fulfilled',
164
+ description: 'Whether to filter the results and only return custom rewards that the calling client_id can manage',
417
165
  },
418
166
  ],
419
167
  },
168
+ ];
169
+ const updateFields = [
170
+ {
171
+ displayName: 'Broadcaster ID or Username',
172
+ name: 'broadcasterId',
173
+ type: 'string',
174
+ default: '',
175
+ required: true,
176
+ placeholder: 'e.g. 123456789 or username',
177
+ description: 'The broadcaster user ID or username. If a username is provided, it will be automatically converted to user ID.',
178
+ },
420
179
  {
421
180
  displayName: 'Reward ID',
422
181
  name: 'rewardId',
423
182
  type: 'string',
424
- displayOptions: {
425
- show: {
426
- resource: ['customReward'],
427
- operation: ['update', 'delete'],
428
- },
429
- },
430
183
  default: '',
431
184
  required: true,
432
185
  placeholder: 'e.g. 92af127c-7326-4483-a52b-b0da0be61c01',
@@ -438,12 +191,6 @@ exports.customRewardFields = [
438
191
  type: 'collection',
439
192
  placeholder: 'Add Field',
440
193
  default: {},
441
- displayOptions: {
442
- show: {
443
- resource: ['customReward'],
444
- operation: ['update'],
445
- },
446
- },
447
194
  options: [
448
195
  {
449
196
  displayName: 'Background Color',
@@ -561,4 +308,270 @@ exports.customRewardFields = [
561
308
  ],
562
309
  },
563
310
  ];
311
+ const deleteFields = [
312
+ {
313
+ displayName: 'Broadcaster ID or Username',
314
+ name: 'broadcasterId',
315
+ type: 'string',
316
+ default: '',
317
+ required: true,
318
+ placeholder: 'e.g. 123456789 or username',
319
+ description: 'The broadcaster user ID or username. If a username is provided, it will be automatically converted to user ID.',
320
+ },
321
+ {
322
+ displayName: 'Reward ID',
323
+ name: 'rewardId',
324
+ type: 'string',
325
+ default: '',
326
+ required: true,
327
+ placeholder: 'e.g. 92af127c-7326-4483-a52b-b0da0be61c01',
328
+ description: 'The ID of the custom reward',
329
+ },
330
+ ];
331
+ exports.customRewardOperations = [
332
+ {
333
+ displayName: 'Operation',
334
+ name: 'operation',
335
+ type: 'options',
336
+ noDataExpression: true,
337
+ displayOptions: {
338
+ show: {
339
+ resource: ['customReward'],
340
+ },
341
+ },
342
+ options: [
343
+ {
344
+ name: 'Create',
345
+ value: 'create',
346
+ action: 'Create a custom reward',
347
+ description: 'Create a custom channel points reward',
348
+ routing: {
349
+ request: {
350
+ method: 'POST',
351
+ url: '/channel_points/custom_rewards',
352
+ },
353
+ send: {
354
+ preSend: [
355
+ async function (requestOptions) {
356
+ const broadcasterIdInput = this.getNodeParameter('broadcasterId', 0);
357
+ const broadcasterId = await userIdConverter_1.resolveUserIdOrUsername.call(this, broadcasterIdInput);
358
+ requestOptions.qs = { broadcaster_id: broadcasterId };
359
+ const body = {
360
+ title: this.getNodeParameter('title', 0),
361
+ cost: this.getNodeParameter('cost', 0),
362
+ };
363
+ const additionalFields = this.getNodeParameter('additionalFields', 0, {});
364
+ if (additionalFields.prompt) {
365
+ body.prompt = additionalFields.prompt;
366
+ }
367
+ if (additionalFields.isEnabled !== undefined) {
368
+ body.is_enabled = additionalFields.isEnabled;
369
+ }
370
+ if (additionalFields.backgroundColor) {
371
+ body.background_color = additionalFields.backgroundColor;
372
+ }
373
+ if (additionalFields.isUserInputRequired !== undefined) {
374
+ body.is_user_input_required = additionalFields.isUserInputRequired;
375
+ }
376
+ if (additionalFields.isMaxPerStreamEnabled !== undefined) {
377
+ body.is_max_per_stream_enabled = additionalFields.isMaxPerStreamEnabled;
378
+ }
379
+ if (additionalFields.maxPerStream) {
380
+ body.max_per_stream = additionalFields.maxPerStream;
381
+ }
382
+ if (additionalFields.isMaxPerUserPerStreamEnabled !== undefined) {
383
+ body.is_max_per_user_per_stream_enabled = additionalFields.isMaxPerUserPerStreamEnabled;
384
+ }
385
+ if (additionalFields.maxPerUserPerStream) {
386
+ body.max_per_user_per_stream = additionalFields.maxPerUserPerStream;
387
+ }
388
+ if (additionalFields.isGlobalCooldownEnabled !== undefined) {
389
+ body.is_global_cooldown_enabled = additionalFields.isGlobalCooldownEnabled;
390
+ }
391
+ if (additionalFields.globalCooldownSeconds) {
392
+ body.global_cooldown_seconds = additionalFields.globalCooldownSeconds;
393
+ }
394
+ if (additionalFields.shouldRedemptionsSkipRequestQueue !== undefined) {
395
+ body.should_redemptions_skip_request_queue = additionalFields.shouldRedemptionsSkipRequestQueue;
396
+ }
397
+ requestOptions.body = body;
398
+ return requestOptions;
399
+ },
400
+ ],
401
+ },
402
+ output: {
403
+ postReceive: [
404
+ {
405
+ type: 'rootProperty',
406
+ properties: {
407
+ property: 'data',
408
+ },
409
+ },
410
+ {
411
+ type: 'setKeyValue',
412
+ properties: {
413
+ index: 0,
414
+ },
415
+ },
416
+ ],
417
+ },
418
+ },
419
+ },
420
+ {
421
+ name: 'Get',
422
+ value: 'get',
423
+ action: 'Get custom rewards',
424
+ description: 'Get custom channel points rewards for a broadcaster',
425
+ routing: {
426
+ request: {
427
+ method: 'GET',
428
+ url: '/channel_points/custom_rewards',
429
+ },
430
+ send: {
431
+ preSend: [
432
+ async function (requestOptions) {
433
+ const broadcasterIdInput = this.getNodeParameter('broadcasterId', 0);
434
+ const broadcasterId = await userIdConverter_1.resolveUserIdOrUsername.call(this, broadcasterIdInput);
435
+ const qs = { broadcaster_id: broadcasterId };
436
+ const additionalFields = this.getNodeParameter('additionalFields', 0, {});
437
+ if (additionalFields.id) {
438
+ qs.id = additionalFields.id;
439
+ }
440
+ if (additionalFields.onlyManageableRewards !== undefined) {
441
+ qs.only_manageable_rewards = additionalFields.onlyManageableRewards;
442
+ }
443
+ requestOptions.qs = qs;
444
+ return requestOptions;
445
+ },
446
+ ],
447
+ },
448
+ output: {
449
+ postReceive: [
450
+ {
451
+ type: 'rootProperty',
452
+ properties: {
453
+ property: 'data',
454
+ },
455
+ },
456
+ ],
457
+ },
458
+ },
459
+ },
460
+ {
461
+ name: 'Update',
462
+ value: 'update',
463
+ action: 'Update a custom reward',
464
+ description: 'Update a custom channel points reward',
465
+ routing: {
466
+ request: {
467
+ method: 'PATCH',
468
+ url: '/channel_points/custom_rewards',
469
+ },
470
+ send: {
471
+ preSend: [
472
+ async function (requestOptions) {
473
+ const broadcasterIdInput = this.getNodeParameter('broadcasterId', 0);
474
+ const broadcasterId = await userIdConverter_1.resolveUserIdOrUsername.call(this, broadcasterIdInput);
475
+ const id = this.getNodeParameter('rewardId', 0);
476
+ requestOptions.qs = { broadcaster_id: broadcasterId, id };
477
+ const body = {};
478
+ const updateFields = this.getNodeParameter('updateFields', 0, {});
479
+ if (updateFields.title) {
480
+ body.title = updateFields.title;
481
+ }
482
+ if (updateFields.cost) {
483
+ body.cost = updateFields.cost;
484
+ }
485
+ if (updateFields.prompt !== undefined) {
486
+ body.prompt = updateFields.prompt;
487
+ }
488
+ if (updateFields.isEnabled !== undefined) {
489
+ body.is_enabled = updateFields.isEnabled;
490
+ }
491
+ if (updateFields.backgroundColor) {
492
+ body.background_color = updateFields.backgroundColor;
493
+ }
494
+ if (updateFields.isUserInputRequired !== undefined) {
495
+ body.is_user_input_required = updateFields.isUserInputRequired;
496
+ }
497
+ if (updateFields.isMaxPerStreamEnabled !== undefined) {
498
+ body.is_max_per_stream_enabled = updateFields.isMaxPerStreamEnabled;
499
+ }
500
+ if (updateFields.maxPerStream) {
501
+ body.max_per_stream = updateFields.maxPerStream;
502
+ }
503
+ if (updateFields.isMaxPerUserPerStreamEnabled !== undefined) {
504
+ body.is_max_per_user_per_stream_enabled = updateFields.isMaxPerUserPerStreamEnabled;
505
+ }
506
+ if (updateFields.maxPerUserPerStream) {
507
+ body.max_per_user_per_stream = updateFields.maxPerUserPerStream;
508
+ }
509
+ if (updateFields.isGlobalCooldownEnabled !== undefined) {
510
+ body.is_global_cooldown_enabled = updateFields.isGlobalCooldownEnabled;
511
+ }
512
+ if (updateFields.globalCooldownSeconds) {
513
+ body.global_cooldown_seconds = updateFields.globalCooldownSeconds;
514
+ }
515
+ if (updateFields.isPaused !== undefined) {
516
+ body.is_paused = updateFields.isPaused;
517
+ }
518
+ if (updateFields.shouldRedemptionsSkipRequestQueue !== undefined) {
519
+ body.should_redemptions_skip_request_queue = updateFields.shouldRedemptionsSkipRequestQueue;
520
+ }
521
+ requestOptions.body = body;
522
+ return requestOptions;
523
+ },
524
+ ],
525
+ },
526
+ output: {
527
+ postReceive: [
528
+ {
529
+ type: 'rootProperty',
530
+ properties: {
531
+ property: 'data',
532
+ },
533
+ },
534
+ {
535
+ type: 'setKeyValue',
536
+ properties: {
537
+ index: 0,
538
+ },
539
+ },
540
+ ],
541
+ },
542
+ },
543
+ },
544
+ {
545
+ name: 'Delete',
546
+ value: 'delete',
547
+ action: 'Delete a custom reward',
548
+ description: 'Delete a custom channel points reward',
549
+ routing: {
550
+ request: {
551
+ method: 'DELETE',
552
+ url: '/channel_points/custom_rewards',
553
+ },
554
+ send: {
555
+ preSend: [
556
+ async function (requestOptions) {
557
+ const broadcasterIdInput = this.getNodeParameter('broadcasterId', 0);
558
+ const broadcasterId = await userIdConverter_1.resolveUserIdOrUsername.call(this, broadcasterIdInput);
559
+ const id = this.getNodeParameter('rewardId', 0);
560
+ requestOptions.qs = { broadcaster_id: broadcasterId, id };
561
+ return requestOptions;
562
+ },
563
+ ],
564
+ },
565
+ },
566
+ },
567
+ ],
568
+ default: 'get',
569
+ },
570
+ ];
571
+ exports.customRewardFields = [
572
+ ...(0, updateDisplayOptions_1.updateDisplayOptions)({ show: { resource: ['customReward'], operation: ['create'] } }, createFields),
573
+ ...(0, updateDisplayOptions_1.updateDisplayOptions)({ show: { resource: ['customReward'], operation: ['get'] } }, getFields),
574
+ ...(0, updateDisplayOptions_1.updateDisplayOptions)({ show: { resource: ['customReward'], operation: ['update'] } }, updateFields),
575
+ ...(0, updateDisplayOptions_1.updateDisplayOptions)({ show: { resource: ['customReward'], operation: ['delete'] } }, deleteFields),
576
+ ];
564
577
  //# sourceMappingURL=CustomReward.js.map