@5minds/node-red-contrib-processcube 1.1.4-feature-bc1698-m0kn1ci4 → 1.1.4-feature-f2fee5-m0kpqgkx

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.
@@ -31,27 +31,21 @@ module.exports = function (RED) {
31
31
  }
32
32
 
33
33
  async function subscribe() {
34
- const eventHandlers = {
35
- created: () =>
36
- client.notification.onExternalTaskCreated(externalTaskCallback('created'), {
34
+ switch (config.eventtype) {
35
+ case 'created':
36
+ return await client.notification.onExternalTaskCreated(externalTaskCallback(), {
37
37
  identity: currentIdentity,
38
- }),
39
- locked: () =>
40
- client.notification.onExternalTaskLocked(externalTaskCallback('locked'), {
38
+ });
39
+ case 'locked':
40
+ return await client.notification.onExternalTaskLocked(externalTaskCallback(), {
41
41
  identity: currentIdentity,
42
- }),
43
- unlocked: () =>
44
- client.notification.onExternalTaskUnlocked(externalTaskCallback('unlocked'), {
42
+ });
43
+ case 'unlocked':
44
+ return await client.notification.onExternalTaskUnlocked(externalTaskCallback(), {
45
45
  identity: currentIdentity,
46
- }),
47
- };
48
-
49
- const handler = eventHandlers[config.eventtype];
50
-
51
- if (handler) {
52
- return await handler();
53
- } else {
54
- console.error('No such event: ' + config.eventtype);
46
+ });
47
+ default:
48
+ console.error('no such event: ' + config.eventtype);
55
49
  }
56
50
  }
57
51
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube",
3
- "version": "1.1.4-feature-bc1698-m0kn1ci4",
3
+ "version": "1.1.4-feature-f2fee5-m0kpqgkx",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for ProcessCube",
6
6
  "scripts": {
@@ -46,23 +46,25 @@ module.exports = function (RED) {
46
46
  }
47
47
 
48
48
  async function subscribe() {
49
- const eventHandlers = {
50
- new: () => client.userTasks.onUserTaskWaiting(userTaskCallback(), { identity: currentIdentity }),
51
- finished: () =>
52
- client.userTasks.onUserTaskFinished(userTaskCallback(), { identity: currentIdentity }),
53
- reserved: () =>
54
- client.userTasks.onUserTaskReserved(userTaskCallback(), { identity: currentIdentity }),
55
- 'reservation-canceled': () =>
56
- client.userTasks.onUserTaskReservationCanceled(userTaskCallback(), {
49
+ switch (config.eventtype) {
50
+ case 'new':
51
+ return await client.userTasks.onUserTaskWaiting(userTaskCallback(), {
57
52
  identity: currentIdentity,
58
- }),
59
- };
60
-
61
- const handler = eventHandlers[config.eventtype];
62
- if (handler) {
63
- return await handler();
64
- } else {
65
- console.error('no such event: ' + config.eventtype);
53
+ });
54
+ case 'finished':
55
+ return await client.userTasks.onUserTaskFinished(userTaskCallback(), {
56
+ identity: currentIdentity,
57
+ });
58
+ case 'reserved':
59
+ return await client.userTasks.onUserTaskReserved(userTaskCallback(), {
60
+ identity: currentIdentity,
61
+ });
62
+ case 'reservation-canceled':
63
+ return await client.userTasks.onUserTaskReservationCanceled(userTaskCallback(), {
64
+ identity: currentIdentity,
65
+ });
66
+ default:
67
+ console.error('no such event: ' + config.eventtype);
66
68
  }
67
69
  }
68
70