@orchesty/connector-zendesk 1.0.0 → 2.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 (70) hide show
  1. package/README.md +97 -0
  2. package/dist/Batch/ZendeskCreateWebhookConnector.js +6 -1
  3. package/dist/Batch/ZendeskDeleteWebhookConnector.js +5 -1
  4. package/dist/ZendeskApplication.js +1 -1
  5. package/dist/package.json +5 -2
  6. package/package.json +5 -2
  7. package/CHANGELOG.md +0 -7
  8. package/coverage/clover.xml +0 -241
  9. package/coverage/coverage-final.json +0 -11
  10. package/coverage/lcov-report/base.css +0 -224
  11. package/coverage/lcov-report/block-navigation.js +0 -87
  12. package/coverage/lcov-report/favicon.png +0 -0
  13. package/coverage/lcov-report/index.html +0 -161
  14. package/coverage/lcov-report/prettify.css +0 -1
  15. package/coverage/lcov-report/prettify.js +0 -2
  16. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  17. package/coverage/lcov-report/sorter.js +0 -210
  18. package/coverage/lcov-report/src/Batch/ZendeskCreateWebhookConnector.ts.html +0 -373
  19. package/coverage/lcov-report/src/Batch/ZendeskDeleteWebhookConnector.ts.html +0 -202
  20. package/coverage/lcov-report/src/Batch/ZendeskListTicketsBatch.ts.html +0 -337
  21. package/coverage/lcov-report/src/Batch/ZendeskListUsersBatch.ts.html +0 -247
  22. package/coverage/lcov-report/src/Batch/index.html +0 -161
  23. package/coverage/lcov-report/src/Connector/ZendeskCreateTicketConnector.ts.html +0 -319
  24. package/coverage/lcov-report/src/Connector/ZendeskCreateTriggerConnector.ts.html +0 -226
  25. package/coverage/lcov-report/src/Connector/ZendeskCreateUserConnector.ts.html +0 -265
  26. package/coverage/lcov-report/src/Connector/ZendeskDeleteTriggerConnector.ts.html +0 -223
  27. package/coverage/lcov-report/src/Connector/index.html +0 -161
  28. package/coverage/lcov-report/src/ZendeskApplication.ts.html +0 -448
  29. package/coverage/lcov-report/src/index.html +0 -116
  30. package/coverage/lcov-report/test/dataProvider.ts.html +0 -307
  31. package/coverage/lcov-report/test/index.html +0 -116
  32. package/coverage/lcov.info +0 -389
  33. package/jest.config.js +0 -13
  34. package/src/Batch/ZendeskCreateWebhookConnector.ts +0 -96
  35. package/src/Batch/ZendeskDeleteWebhookConnector.ts +0 -39
  36. package/src/Batch/ZendeskListTicketsBatch.ts +0 -84
  37. package/src/Batch/ZendeskListUsersBatch.ts +0 -54
  38. package/src/Batch/__tests__/Data/ZendeskListTicketsBatch/1-mock.json +0 -57
  39. package/src/Batch/__tests__/Data/ZendeskListTicketsBatch/input.json +0 -6
  40. package/src/Batch/__tests__/Data/ZendeskListTicketsBatch/mock.json +0 -106
  41. package/src/Batch/__tests__/Data/ZendeskListTicketsBatch/output.json +0 -18
  42. package/src/Batch/__tests__/Data/ZendeskListTicketsBatch/output1.json +0 -12
  43. package/src/Batch/__tests__/Data/ZendeskListUsersBatch/input.json +0 -6
  44. package/src/Batch/__tests__/Data/ZendeskListUsersBatch/mock.json +0 -161
  45. package/src/Batch/__tests__/Data/ZendeskListUsersBatch/output.json +0 -19
  46. package/src/Batch/__tests__/ZendeskListTicketsBatch.ts +0 -17
  47. package/src/Batch/__tests__/ZendeskListUsersBatch.ts +0 -17
  48. package/src/Connector/ZendeskCreateTicketConnector.ts +0 -78
  49. package/src/Connector/ZendeskCreateTriggerConnector.ts +0 -47
  50. package/src/Connector/ZendeskCreateUserConnector.ts +0 -60
  51. package/src/Connector/ZendeskDeleteTriggerConnector.ts +0 -46
  52. package/src/Connector/__tests__/Data/ZendeskCreateTicketConnector/input.json +0 -14
  53. package/src/Connector/__tests__/Data/ZendeskCreateTicketConnector/mock.json +0 -194
  54. package/src/Connector/__tests__/Data/ZendeskCreateTicketConnector/output.json +0 -194
  55. package/src/Connector/__tests__/Data/ZendeskCreateTriggerConnector/input.json +0 -11
  56. package/src/Connector/__tests__/Data/ZendeskCreateTriggerConnector/mock.json +0 -31
  57. package/src/Connector/__tests__/Data/ZendeskCreateTriggerConnector/output.json +0 -29
  58. package/src/Connector/__tests__/Data/ZendeskCreateUserConnector/input.json +0 -25
  59. package/src/Connector/__tests__/Data/ZendeskCreateUserConnector/mock.json +0 -45
  60. package/src/Connector/__tests__/Data/ZendeskCreateUserConnector/output.json +0 -44
  61. package/src/Connector/__tests__/ZendeskCreateTicketConnector.ts +0 -17
  62. package/src/Connector/__tests__/ZendeskCreateTriggerConnector.ts +0 -17
  63. package/src/Connector/__tests__/ZendeskCreateUserConnector.ts +0 -17
  64. package/src/ZendeskApplication.ts +0 -121
  65. package/src/types/trigger.types.ts +0 -19
  66. package/src/types/webhook.types.ts +0 -20
  67. package/test/dataProvider.ts +0 -74
  68. package/tsconfig.json +0 -8
  69. package/tsconfig.prod.json +0 -13
  70. package/tsconfig.prod.tsbuildinfo +0 -1
@@ -1,389 +0,0 @@
1
- TN:
2
- SF:src/ZendeskApplication.ts
3
- FN:21,(anonymous_10)
4
- FN:25,(anonymous_11)
5
- FN:29,(anonymous_12)
6
- FN:33,(anonymous_13)
7
- FN:37,(anonymous_14)
8
- FN:62,(anonymous_15)
9
- FN:66,(anonymous_16)
10
- FN:75,(anonymous_17)
11
- FN:83,(anonymous_18)
12
- FN:87,(anonymous_19)
13
- FN:91,(anonymous_20)
14
- FN:95,(anonymous_21)
15
- FN:99,(anonymous_22)
16
- FN:113,(anonymous_23)
17
- FN:117,(anonymous_24)
18
- FNF:15
19
- FNH:2
20
- FNDA:0,(anonymous_10)
21
- FNDA:11,(anonymous_11)
22
- FNDA:0,(anonymous_12)
23
- FNDA:0,(anonymous_13)
24
- FNDA:6,(anonymous_14)
25
- FNDA:0,(anonymous_15)
26
- FNDA:0,(anonymous_16)
27
- FNDA:0,(anonymous_17)
28
- FNDA:0,(anonymous_18)
29
- FNDA:0,(anonymous_19)
30
- FNDA:0,(anonymous_20)
31
- FNDA:0,(anonymous_21)
32
- FNDA:0,(anonymous_22)
33
- FNDA:0,(anonymous_23)
34
- FNDA:0,(anonymous_24)
35
- DA:1,5
36
- DA:3,5
37
- DA:4,5
38
- DA:5,5
39
- DA:6,5
40
- DA:8,5
41
- DA:9,5
42
- DA:10,5
43
- DA:11,5
44
- DA:12,5
45
- DA:15,5
46
- DA:17,5
47
- DA:18,5
48
- DA:19,5
49
- DA:22,0
50
- DA:26,11
51
- DA:30,0
52
- DA:34,0
53
- DA:44,6
54
- DA:45,6
55
- DA:47,6
56
- DA:48,6
57
- DA:54,6
58
- DA:55,3
59
- DA:58,6
60
- DA:63,0
61
- DA:67,0
62
- DA:72,0
63
- DA:76,0
64
- DA:77,0
65
- DA:84,0
66
- DA:88,0
67
- DA:92,0
68
- DA:96,0
69
- DA:100,0
70
- DA:105,0
71
- DA:106,0
72
- DA:107,0
73
- DA:110,0
74
- DA:114,0
75
- DA:118,0
76
- LF:41
77
- LH:22
78
- BRDA:54,0,0,3
79
- BRDA:54,0,1,3
80
- BRDA:77,1,0,0
81
- BRDA:77,1,1,0
82
- BRDA:77,1,2,0
83
- BRDA:77,1,3,0
84
- BRDA:106,2,0,0
85
- BRDA:106,2,1,0
86
- BRF:8
87
- BRH:2
88
- end_of_record
89
- TN:
90
- SF:src/Batch/ZendeskCreateWebhookConnector.ts
91
- FN:19,(anonymous_1)
92
- FN:23,(anonymous_2)
93
- FN:32,(anonymous_3)
94
- FN:41,(anonymous_4)
95
- FN:41,(anonymous_5)
96
- FN:77,(anonymous_6)
97
- FN:81,(anonymous_7)
98
- FNF:7
99
- FNH:1
100
- FNDA:5,(anonymous_1)
101
- FNDA:0,(anonymous_2)
102
- FNDA:0,(anonymous_3)
103
- FNDA:0,(anonymous_4)
104
- FNDA:0,(anonymous_5)
105
- FNDA:0,(anonymous_6)
106
- FNDA:0,(anonymous_7)
107
- DA:1,5
108
- DA:3,5
109
- DA:4,5
110
- DA:5,5
111
- DA:8,5
112
- DA:12,5
113
- DA:17,5
114
- DA:20,5
115
- DA:26,0
116
- DA:28,0
117
- DA:29,0
118
- DA:31,0
119
- DA:32,0
120
- DA:41,0
121
- DA:43,0
122
- DA:44,0
123
- DA:59,0
124
- DA:60,0
125
- DA:62,0
126
- DA:74,0
127
- DA:78,0
128
- DA:82,0
129
- LF:22
130
- LH:8
131
- BRDA:38,0,0,0
132
- BRDA:38,0,1,0
133
- BRF:2
134
- BRH:0
135
- end_of_record
136
- TN:
137
- SF:src/Batch/ZendeskDeleteWebhookConnector.ts
138
- FN:13,(anonymous_1)
139
- FN:17,(anonymous_2)
140
- FNF:2
141
- FNH:1
142
- FNDA:5,(anonymous_1)
143
- FNDA:0,(anonymous_2)
144
- DA:1,5
145
- DA:3,5
146
- DA:4,5
147
- DA:5,5
148
- DA:7,5
149
- DA:9,5
150
- DA:11,5
151
- DA:14,5
152
- DA:18,0
153
- DA:19,0
154
- DA:20,0
155
- DA:21,0
156
- DA:23,0
157
- DA:24,0
158
- DA:25,0
159
- DA:26,0
160
- DA:27,0
161
- DA:28,0
162
- DA:29,0
163
- DA:30,0
164
- DA:32,0
165
- DA:33,0
166
- DA:36,0
167
- LF:23
168
- LH:8
169
- BRDA:23,0,0,0
170
- BRDA:23,0,1,0
171
- BRDA:27,1,0,0
172
- BRDA:27,1,1,0
173
- BRDA:27,2,0,0
174
- BRDA:27,2,1,0
175
- BRF:6
176
- BRH:0
177
- end_of_record
178
- TN:
179
- SF:src/Batch/ZendeskListTicketsBatch.ts
180
- FN:9,(anonymous_1)
181
- FN:13,(anonymous_2)
182
- FNF:2
183
- FNH:2
184
- FNDA:5,(anonymous_1)
185
- FNDA:2,(anonymous_2)
186
- DA:1,5
187
- DA:2,5
188
- DA:5,5
189
- DA:7,5
190
- DA:10,5
191
- DA:14,2
192
- DA:15,2
193
- DA:16,2
194
- DA:22,2
195
- DA:23,2
196
- DA:25,2
197
- DA:26,2
198
- DA:27,1
199
- DA:30,2
200
- LF:14
201
- LH:14
202
- BRDA:25,0,0,2
203
- BRDA:25,0,1,0
204
- BRDA:26,1,0,1
205
- BRDA:26,1,1,1
206
- BRF:4
207
- BRH:3
208
- end_of_record
209
- TN:
210
- SF:src/Batch/ZendeskListUsersBatch.ts
211
- FN:10,(anonymous_1)
212
- FN:14,(anonymous_2)
213
- FNF:2
214
- FNH:2
215
- FNDA:5,(anonymous_1)
216
- FNDA:1,(anonymous_2)
217
- DA:1,5
218
- DA:2,5
219
- DA:6,5
220
- DA:8,5
221
- DA:11,5
222
- DA:15,1
223
- DA:16,1
224
- DA:17,1
225
- DA:23,1
226
- DA:24,1
227
- DA:26,1
228
- DA:27,1
229
- DA:28,0
230
- DA:31,1
231
- LF:14
232
- LH:13
233
- BRDA:26,0,0,1
234
- BRDA:26,0,1,0
235
- BRDA:27,1,0,0
236
- BRDA:27,1,1,1
237
- BRF:4
238
- BRH:2
239
- end_of_record
240
- TN:
241
- SF:src/Connector/ZendeskCreateTicketConnector.ts
242
- FN:9,(anonymous_1)
243
- FN:13,(anonymous_2)
244
- FNF:2
245
- FNH:2
246
- FNDA:5,(anonymous_1)
247
- FNDA:1,(anonymous_2)
248
- DA:1,5
249
- DA:2,5
250
- DA:5,5
251
- DA:7,5
252
- DA:10,5
253
- DA:14,1
254
- DA:16,1
255
- DA:17,1
256
- DA:18,1
257
- DA:20,1
258
- LF:10
259
- LH:10
260
- BRF:0
261
- BRH:0
262
- end_of_record
263
- TN:
264
- SF:src/Connector/ZendeskCreateTriggerConnector.ts
265
- FN:10,(anonymous_1)
266
- FN:14,(anonymous_2)
267
- FN:31,(anonymous_3)
268
- FN:35,(anonymous_4)
269
- FNF:4
270
- FNH:4
271
- FNDA:5,(anonymous_1)
272
- FNDA:1,(anonymous_2)
273
- FNDA:1,(anonymous_3)
274
- FNDA:1,(anonymous_4)
275
- DA:1,5
276
- DA:2,5
277
- DA:6,5
278
- DA:8,5
279
- DA:11,5
280
- DA:17,1
281
- DA:19,1
282
- DA:26,1
283
- DA:28,1
284
- DA:32,1
285
- DA:36,1
286
- LF:11
287
- LH:11
288
- BRF:0
289
- BRH:0
290
- end_of_record
291
- TN:
292
- SF:src/Connector/ZendeskCreateUserConnector.ts
293
- FN:9,(anonymous_1)
294
- FN:13,(anonymous_2)
295
- FNF:2
296
- FNH:2
297
- FNDA:5,(anonymous_1)
298
- FNDA:1,(anonymous_2)
299
- DA:1,5
300
- DA:2,5
301
- DA:5,5
302
- DA:7,5
303
- DA:10,5
304
- DA:14,1
305
- DA:16,1
306
- DA:17,1
307
- DA:18,1
308
- DA:20,1
309
- DA:22,1
310
- LF:11
311
- LH:11
312
- BRF:0
313
- BRH:0
314
- end_of_record
315
- TN:
316
- SF:src/Connector/ZendeskDeleteTriggerConnector.ts
317
- FN:9,(anonymous_1)
318
- FN:13,(anonymous_2)
319
- FN:32,(anonymous_3)
320
- FN:36,(anonymous_4)
321
- FNF:4
322
- FNH:1
323
- FNDA:5,(anonymous_1)
324
- FNDA:0,(anonymous_2)
325
- FNDA:0,(anonymous_3)
326
- FNDA:0,(anonymous_4)
327
- DA:1,5
328
- DA:2,5
329
- DA:5,5
330
- DA:7,5
331
- DA:10,5
332
- DA:16,0
333
- DA:18,0
334
- DA:27,0
335
- DA:29,0
336
- DA:33,0
337
- DA:37,0
338
- LF:11
339
- LH:5
340
- BRF:0
341
- BRH:0
342
- end_of_record
343
- TN:
344
- SF:test/dataProvider.ts
345
- FN:17,init
346
- FNF:1
347
- FNH:1
348
- FNDA:5,init
349
- DA:1,5
350
- DA:2,5
351
- DA:3,5
352
- DA:4,5
353
- DA:5,5
354
- DA:6,5
355
- DA:7,5
356
- DA:8,5
357
- DA:9,5
358
- DA:10,5
359
- DA:11,5
360
- DA:12,5
361
- DA:13,5
362
- DA:14,5
363
- DA:15,5
364
- DA:17,5
365
- DA:18,5
366
- DA:28,5
367
- DA:38,5
368
- DA:39,5
369
- DA:41,5
370
- DA:42,5
371
- DA:43,5
372
- DA:44,5
373
- DA:46,5
374
- DA:50,5
375
- DA:52,5
376
- DA:56,5
377
- DA:58,5
378
- DA:62,5
379
- DA:64,5
380
- DA:68,5
381
- DA:70,5
382
- DA:71,5
383
- DA:72,5
384
- DA:73,5
385
- LF:36
386
- LH:36
387
- BRF:0
388
- BRH:0
389
- end_of_record
package/jest.config.js DELETED
@@ -1,13 +0,0 @@
1
- const baseConfig = require('../../jest.config.js');
2
-
3
- module.exports = {
4
- ...baseConfig,
5
- roots: ["<rootDir>/src"],
6
- setupFiles: ["<rootDir>/../../.jest/testEnvs.ts"],
7
- setupFilesAfterEnv: ["<rootDir>/../../.jest/testLifecycle.ts"],
8
- globalSetup: "<rootDir>/../../.jest/globalSetup.ts",
9
- moduleNameMapper: {
10
- "^@orchesty/nodejs-connectors/test/(.*)$": "<rootDir>/../../test/$1",
11
- "^@orchesty/nodejs-connectors/lib/(.*)$": "<rootDir>/../../lib/$1",
12
- },
13
- }
@@ -1,96 +0,0 @@
1
- import Webhook from '@orchesty/nodejs-sdk/dist/lib/Application/Database/Webhook';
2
- import WebhookRepository from '@orchesty/nodejs-sdk/dist/lib/Application/Database/WebhookRepository';
3
- import ABatchNode from '@orchesty/nodejs-sdk/dist/lib/Batch/ABatchNode';
4
- import TopologyRunner from '@orchesty/nodejs-sdk/dist/lib/Topology/TopologyRunner';
5
- import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
6
- import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
7
- import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
8
- import crypto from 'crypto';
9
- import { ZendeskWebhook } from '../types/webhook.types';
10
- import ZendeskApplication from '../ZendeskApplication';
11
-
12
- export const ZENDESK_CREATE_WEBHOOK = 'zendesk-create-webhook';
13
-
14
- /* eslint-disable @typescript-eslint/naming-convention */
15
- /* eslint-disable no-await-in-loop */
16
-
17
- export default class ZendeskCreateWebhookConnector extends ABatchNode {
18
-
19
- public getName(): string {
20
- return ZENDESK_CREATE_WEBHOOK;
21
- }
22
-
23
- public async processAction(
24
- dto: BatchProcessDto<ZendeskCreateWebhookInput>,
25
- ): Promise<BatchProcessDto> {
26
- const repo = this.getDbClient().getRepository(Webhook) as WebhookRepository;
27
-
28
- const app = this.getApplication<ZendeskApplication>();
29
- const appInstall = await this.getApplicationInstallFromProcess(dto);
30
-
31
- const registered = await repo.findMany({ users: [appInstall.getUser()], apps: [appInstall.getName()] });
32
- const all = app.getWebhookSubscriptions().map((sub) => ({
33
- event: sub.getName(),
34
- token: this.getRandomToken(),
35
- node: sub.getNode(),
36
- name: sub.getName(),
37
- topology: sub.getTopology(),
38
- events: JSON.parse(sub.getParameters().events || '[]'),
39
- }));
40
-
41
- const unregistered = all.filter((wh) => !registered.find((reg) => reg.getName() === wh.event));
42
-
43
- for (const toRegister of unregistered) {
44
- const reqBody = {
45
- webhook: {
46
- endpoint: TopologyRunner.getWebhookUrl(
47
- toRegister.topology,
48
- toRegister.node,
49
- toRegister.token,
50
- ),
51
- http_method: 'POST',
52
- name: toRegister.name,
53
- request_format: 'json',
54
- status: 'active',
55
- subscriptions: toRegister.events,
56
- },
57
- };
58
-
59
- const requestDto = await app.getRequestDto(dto, appInstall, HttpMethods.POST, '/webhooks', reqBody);
60
- const data = (await this.getSender().send<Response>(requestDto)).getJsonBody();
61
-
62
- await repo.insert(
63
- new Webhook()
64
- .setWebhookId(data.webhook.id)
65
- .setUser(appInstall.getUser())
66
- .setNode(toRegister.node)
67
- .setToken(toRegister.token)
68
- .setApplication(app.getName())
69
- .setTopology(toRegister.topology)
70
- .setName(data.webhook.name),
71
- );
72
- }
73
-
74
- return dto;
75
- }
76
-
77
- protected getData(dto: ProcessDto<ZendeskCreateWebhookInput>): ZendeskCreateWebhookInput {
78
- return dto.getJsonData();
79
- }
80
-
81
- protected getRandomToken(): string {
82
- return crypto.randomBytes(64).toString('hex');
83
- }
84
-
85
- }
86
-
87
- interface Response {
88
- webhook: ZendeskWebhook;
89
- }
90
-
91
- export interface ZendeskCreateWebhookInput {
92
- topology: string;
93
- node: string;
94
- name: string;
95
- events: string[];
96
- }
@@ -1,39 +0,0 @@
1
- import Webhook from '@orchesty/nodejs-sdk/dist/lib/Application/Database/Webhook';
2
- import WebhookRepository from '@orchesty/nodejs-sdk/dist/lib/Application/Database/WebhookRepository';
3
- import ABatchNode from '@orchesty/nodejs-sdk/dist/lib/Batch/ABatchNode';
4
- import OnRepeatException from '@orchesty/nodejs-sdk/dist/lib/Exception/OnRepeatException';
5
- import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
6
- import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
7
- import { StatusCodes } from 'http-status-codes';
8
-
9
- export const ZENDESK_DELETE_WEBHOOK = 'zendesk-delete-webhook';
10
-
11
- export default class ZendeskDeleteWebhookConnector extends ABatchNode {
12
-
13
- public getName(): string {
14
- return ZENDESK_DELETE_WEBHOOK;
15
- }
16
-
17
- public async processAction(dto: BatchProcessDto): Promise<BatchProcessDto> {
18
- const app = this.getApplication();
19
- const appInstall = await this.getApplicationInstallFromProcess(dto, null);
20
- const repo = this.getDbClient().getRepository(Webhook) as WebhookRepository;
21
- const webhook = await repo.findOne({ users: [appInstall.getUser()], apps: [appInstall.getName()] });
22
-
23
- if (webhook) {
24
- const url = `/webhooks/${webhook.getWebhookId()}`;
25
- const requestDto = await app.getRequestDto(dto, appInstall, HttpMethods.DELETE, url);
26
- const res = await this.getSender().send(requestDto);
27
- if (res.getResponseCode() !== StatusCodes.OK && res.getResponseCode() !== StatusCodes.NOT_FOUND) {
28
- webhook.setUnsubscribeFailed(true);
29
- await repo.update(webhook);
30
- throw new OnRepeatException(300, 12, res.getBody());
31
- }
32
- await repo.remove(webhook);
33
- dto.setBatchCursor('1', true);
34
- }
35
-
36
- return dto;
37
- }
38
-
39
- }
@@ -1,84 +0,0 @@
1
- import ABatchNode from '@orchesty/nodejs-sdk/dist/lib/Batch/ABatchNode';
2
- import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
3
- import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
4
-
5
- export const NAME = 'zendesk-list-tickets-batch';
6
-
7
- export default class ZendeskListTicketsBatch extends ABatchNode {
8
-
9
- public getName(): string {
10
- return NAME;
11
- }
12
-
13
- public async processAction(dto: BatchProcessDto): Promise<BatchProcessDto> {
14
- const offset = dto.getBatchCursor('1');
15
- const appInstall = await this.getApplicationInstallFromProcess(dto);
16
- const req = await this.getApplication().getRequestDto(
17
- dto,
18
- appInstall,
19
- HttpMethods.GET,
20
- `/tickets.json?per_page=100&page=${offset}`,
21
- );
22
- const resp = await this.getSender().send<IResponse>(req, [200]);
23
- const response = resp.getJsonBody();
24
-
25
- dto.setItemList(response.tickets ?? []);
26
- if (response.next_page !== null) {
27
- dto.setBatchCursor((Number(offset) + 1).toString());
28
- }
29
-
30
- return dto;
31
- }
32
-
33
- }
34
-
35
- /* eslint-disable @typescript-eslint/naming-convention */
36
- interface IResponse {
37
- tickets: IOutput[];
38
- next_page: string;
39
- links: {
40
- next: string;
41
- prev: string;
42
- };
43
- }
44
-
45
- export interface IOutput {
46
- assignee_id: number;
47
- collaborator_ids: number[];
48
- created_at: string;
49
- custom_fields: [
50
- {
51
- id: number;
52
- value: string;
53
- },
54
- ];
55
- description: string;
56
- external_id: string;
57
- follower_ids: number[];
58
- group_id: number;
59
- has_incidents: boolean;
60
- id: number;
61
- organization_id: number;
62
- priority: string;
63
- problem_id: number;
64
- raw_subject: string;
65
- recipient: string;
66
- requester_id: number;
67
- satisfaction_rating: {
68
- comment: string;
69
- id: number;
70
- score: string;
71
- };
72
- sharing_agreement_ids: number[];
73
- status: string;
74
- subject: string;
75
- submitter_id: number;
76
- tags: string[];
77
- type: string;
78
- updated_at: string;
79
- url: string;
80
- via: {
81
- channel: string;
82
- };
83
- /* eslint-enable @typescript-eslint/naming-convention */
84
- }
@@ -1,54 +0,0 @@
1
- import ABatchNode from '@orchesty/nodejs-sdk/dist/lib/Batch/ABatchNode';
2
- import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
3
- import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
4
- import ZendeskApplication from '../ZendeskApplication';
5
-
6
- export const NAME = 'zendesk-list-users-batch';
7
-
8
- export default class ZendeskListUsersBatch extends ABatchNode {
9
-
10
- public getName(): string {
11
- return NAME;
12
- }
13
-
14
- public async processAction(dto: BatchProcessDto): Promise<BatchProcessDto> {
15
- const offset = dto.getBatchCursor('1');
16
- const appInstall = await this.getApplicationInstallFromProcess(dto);
17
- const req = await this.getApplication<ZendeskApplication>().getRequestDto(
18
- dto,
19
- appInstall,
20
- HttpMethods.GET,
21
- `/users.json?per_page=100&page=${offset}`,
22
- );
23
- const resp = await this.getSender().send<IResponse>(req, [200]);
24
- const response = resp.getJsonBody();
25
-
26
- dto.setItemList(response.users ?? []);
27
- if (response.meta.has_more) {
28
- dto.setBatchCursor((Number(offset) + 1).toString());
29
- }
30
-
31
- return dto;
32
- }
33
-
34
- }
35
-
36
- /* eslint-disable @typescript-eslint/naming-convention */
37
- interface IResponse {
38
- users: IOutput[];
39
- meta: {
40
- has_more: boolean;
41
- before_cursor: string;
42
- };
43
- links: {
44
- next: string;
45
- prev: string;
46
- };
47
- }
48
-
49
- export interface IOutput {
50
- id: number;
51
- name: string;
52
- }
53
-
54
- /* eslint-enable @typescript-eslint/naming-convention */