crisp-api 9.13.0 → 10.0.3

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 (116) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +2 -2
  3. package/dist/crisp.d.ts +179 -0
  4. package/dist/crisp.js +773 -0
  5. package/dist/resources/BaseResource.d.ts +21 -0
  6. package/dist/resources/BaseResource.js +26 -0
  7. package/dist/resources/BucketURL.d.ts +37 -0
  8. package/dist/resources/BucketURL.js +35 -0
  9. package/dist/resources/MediaAnimation.d.ts +20 -0
  10. package/dist/resources/MediaAnimation.js +40 -0
  11. package/dist/resources/PluginConnect.d.ts +59 -0
  12. package/dist/resources/PluginConnect.js +79 -0
  13. package/dist/resources/PluginSubscription.d.ts +112 -0
  14. package/dist/resources/PluginSubscription.js +130 -0
  15. package/dist/resources/WebsiteAnalytics.d.ts +20 -0
  16. package/dist/resources/WebsiteAnalytics.js +37 -0
  17. package/dist/resources/WebsiteAvailability.d.ts +40 -0
  18. package/dist/resources/WebsiteAvailability.js +46 -0
  19. package/dist/resources/WebsiteBase.d.ts +69 -0
  20. package/dist/resources/WebsiteBase.js +77 -0
  21. package/dist/resources/WebsiteBatch.d.ts +61 -0
  22. package/dist/resources/WebsiteBatch.js +76 -0
  23. package/dist/resources/WebsiteCampaign.d.ts +208 -0
  24. package/dist/resources/WebsiteCampaign.js +201 -0
  25. package/dist/resources/WebsiteConversation.d.ts +710 -0
  26. package/dist/resources/WebsiteConversation.js +607 -0
  27. package/dist/resources/WebsiteHelpdesk.d.ts +356 -0
  28. package/dist/resources/WebsiteHelpdesk.js +593 -0
  29. package/dist/resources/WebsiteOperator.d.ts +88 -0
  30. package/dist/resources/WebsiteOperator.js +99 -0
  31. package/dist/resources/WebsitePeople.d.ts +257 -0
  32. package/dist/resources/WebsitePeople.js +282 -0
  33. package/dist/resources/WebsiteSettings.d.ts +168 -0
  34. package/dist/resources/WebsiteSettings.js +42 -0
  35. package/dist/resources/WebsiteVerify.d.ts +47 -0
  36. package/dist/resources/WebsiteVerify.js +56 -0
  37. package/dist/resources/WebsiteVisitors.d.ts +122 -0
  38. package/dist/resources/WebsiteVisitors.js +98 -0
  39. package/dist/resources/index.d.ts +20 -0
  40. package/dist/resources/index.js +42 -0
  41. package/dist/services/bucket.d.ts +19 -0
  42. package/dist/services/bucket.js +31 -0
  43. package/dist/services/media.d.ts +19 -0
  44. package/dist/services/media.js +31 -0
  45. package/dist/services/plugin.d.ts +20 -0
  46. package/dist/services/plugin.js +33 -0
  47. package/dist/services/website.d.ts +30 -0
  48. package/dist/services/website.js +53 -0
  49. package/eslint.config.mjs +208 -0
  50. package/lib/crisp.ts +1006 -0
  51. package/lib/resources/BaseResource.ts +37 -0
  52. package/lib/resources/BucketURL.ts +58 -0
  53. package/lib/resources/MediaAnimation.ts +44 -0
  54. package/lib/resources/PluginConnect.ts +135 -0
  55. package/lib/resources/PluginSubscription.ts +236 -0
  56. package/lib/resources/WebsiteAnalytics.ts +41 -0
  57. package/lib/resources/WebsiteAvailability.ts +74 -0
  58. package/lib/resources/WebsiteBase.ts +119 -0
  59. package/lib/resources/WebsiteBatch.ts +116 -0
  60. package/lib/resources/WebsiteCampaign.ts +432 -0
  61. package/lib/resources/WebsiteConversation.ts +1507 -0
  62. package/lib/resources/WebsiteHelpdesk.ts +1024 -0
  63. package/lib/resources/WebsiteOperator.ts +183 -0
  64. package/lib/resources/WebsitePeople.ts +568 -0
  65. package/lib/resources/WebsiteSettings.ts +207 -0
  66. package/lib/resources/WebsiteVerify.ts +90 -0
  67. package/lib/resources/WebsiteVisitors.ts +219 -0
  68. package/lib/resources/index.ts +28 -0
  69. package/lib/services/bucket.ts +36 -0
  70. package/lib/services/media.ts +36 -0
  71. package/lib/services/plugin.ts +40 -0
  72. package/lib/services/website.ts +70 -0
  73. package/package.json +16 -11
  74. package/tsconfig.json +12 -5
  75. package/lib/crisp.js +0 -1171
  76. package/lib/resources/BucketURL.js +0 -34
  77. package/lib/resources/MediaAnimation.js +0 -41
  78. package/lib/resources/PluginConnect.js +0 -119
  79. package/lib/resources/PluginSubscription.js +0 -234
  80. package/lib/resources/WebsiteAnalytics.js +0 -37
  81. package/lib/resources/WebsiteAvailability.js +0 -48
  82. package/lib/resources/WebsiteBase.js +0 -100
  83. package/lib/resources/WebsiteBatch.js +0 -92
  84. package/lib/resources/WebsiteCampaign.js +0 -396
  85. package/lib/resources/WebsiteConversation.js +0 -1261
  86. package/lib/resources/WebsiteHelpdesk.js +0 -1198
  87. package/lib/resources/WebsiteOperator.js +0 -167
  88. package/lib/resources/WebsitePeople.js +0 -516
  89. package/lib/resources/WebsiteSettings.js +0 -50
  90. package/lib/resources/WebsiteVerify.js +0 -79
  91. package/lib/resources/WebsiteVisitors.js +0 -148
  92. package/lib/services/Bucket.js +0 -28
  93. package/lib/services/Media.js +0 -28
  94. package/lib/services/Plugin.js +0 -29
  95. package/lib/services/Website.js +0 -39
  96. package/types/crisp.d.ts +0 -151
  97. package/types/resources/BucketURL.d.ts +0 -15
  98. package/types/resources/MediaAnimation.d.ts +0 -15
  99. package/types/resources/PluginConnect.d.ts +0 -15
  100. package/types/resources/PluginSubscription.d.ts +0 -15
  101. package/types/resources/WebsiteAnalytics.d.ts +0 -15
  102. package/types/resources/WebsiteAvailability.d.ts +0 -15
  103. package/types/resources/WebsiteBase.d.ts +0 -15
  104. package/types/resources/WebsiteBatch.d.ts +0 -15
  105. package/types/resources/WebsiteCampaign.d.ts +0 -15
  106. package/types/resources/WebsiteConversation.d.ts +0 -15
  107. package/types/resources/WebsiteHelpdesk.d.ts +0 -15
  108. package/types/resources/WebsiteOperator.d.ts +0 -15
  109. package/types/resources/WebsitePeople.d.ts +0 -15
  110. package/types/resources/WebsiteSettings.d.ts +0 -15
  111. package/types/resources/WebsiteVerify.d.ts +0 -15
  112. package/types/resources/WebsiteVisitors.d.ts +0 -15
  113. package/types/services/Bucket.d.ts +0 -14
  114. package/types/services/Media.d.ts +0 -14
  115. package/types/services/Plugin.d.ts +0 -14
  116. package/types/services/Website.d.ts +0 -14
@@ -0,0 +1,1507 @@
1
+ /*
2
+ * node-crisp-api
3
+ *
4
+ * Copyright 2022, Crisp IM SAS
5
+ * Author: Baptiste Jamin <baptiste@crisp.chat>
6
+ */
7
+
8
+ /**************************************************************************
9
+ * IMPORTS
10
+ ***************************************************************************/
11
+
12
+ // PROJECT: RESOURCES
13
+ import BaseResource from "./BaseResource";
14
+
15
+ /**************************************************************************
16
+ * TYPES + INTERFACES
17
+ ***************************************************************************/
18
+
19
+ export interface Conversation {
20
+ session_id: string;
21
+ website_id: string;
22
+ inbox_id?: string;
23
+ people_id?: string;
24
+ state?: ConversationState;
25
+ status?: number;
26
+ is_verified?: boolean;
27
+ is_blocked?: boolean;
28
+ availability?: string;
29
+ active?: ConversationActive;
30
+ last_message?: string;
31
+ preview_message?: ConversationPreviewMessage;
32
+ topic?: string;
33
+ verifications?: ConversationVerification[];
34
+ participants?: ConversationParticipant[];
35
+ mentions?: string[];
36
+ compose?: ConversationCompose;
37
+ unread?: ConversationUnread;
38
+ assigned?: ConversationAssigned;
39
+ meta?: ConversationMeta;
40
+ created_at?: number;
41
+ updated_at?: number;
42
+ waiting_since?: number;
43
+ }
44
+
45
+ type ConversationNew = {
46
+ session_id?: string;
47
+ }
48
+
49
+ export interface ConversationActive {
50
+ now?: boolean;
51
+ last?: number;
52
+ }
53
+
54
+ export interface ConversationPreviewMessage {
55
+ type?: string;
56
+ from?: string;
57
+ excerpt?: string;
58
+ fingerprint?: number;
59
+ }
60
+
61
+ export interface ConversationCompose {
62
+ operator?: ConversationComposeAtom;
63
+ visitor?: ConversationComposeAtom;
64
+ }
65
+
66
+ export interface ConversationComposeAtom {
67
+ type?: string;
68
+ excerpt?: string;
69
+ timestamp?: number;
70
+ user?: ConversationComposeAtomUser;
71
+ automated?: boolean;
72
+ }
73
+
74
+ export interface ConversationComposeAtomUser {
75
+ user_id?: string;
76
+ nickname?: string;
77
+ avatar?: string;
78
+ }
79
+
80
+ export interface ConversationUnread {
81
+ operator?: number;
82
+ visitor?: number;
83
+ }
84
+
85
+ export interface ConversationAssigned {
86
+ user_id?: string;
87
+ }
88
+
89
+ export interface ConversationVerification {
90
+ identity?: string;
91
+ method?: string;
92
+ annotation?: string;
93
+ }
94
+
95
+ export interface ConversationParticipant {
96
+ type?: string;
97
+ target?: string;
98
+ }
99
+
100
+ export interface ConversationParticipants {
101
+ participants?: ConversationParticipant[];
102
+ }
103
+
104
+ export interface ConversationParticipantsSave {
105
+ participants?: ConversationParticipant[];
106
+ }
107
+
108
+ export interface ConversationMeta {
109
+ nickname: string;
110
+ email?: string;
111
+ phone?: string;
112
+ ip?: string;
113
+ avatar?: string;
114
+ data?: Record<string, unknown>;
115
+ connection?: ConnectionInfo;
116
+ device?: DeviceInfo;
117
+ segments?: string[];
118
+ }
119
+
120
+ export interface ConnectionInfo {
121
+ isp?: string;
122
+ asn?: string;
123
+ }
124
+
125
+ export interface DeviceInfo {
126
+ capabilities?: string[];
127
+ geolocation?: GeolocationInfo;
128
+ system?: SystemInfo;
129
+ timezone?: number;
130
+ locales?: string[];
131
+ }
132
+
133
+ export interface GeolocationInfo {
134
+ country?: string;
135
+ region?: string;
136
+ city?: string;
137
+ coordinates?: Coordinates;
138
+ }
139
+
140
+ export interface Coordinates {
141
+ latitude?: number;
142
+ longitude?: number;
143
+ }
144
+
145
+ export interface SystemInfo {
146
+ os?: OSInfo;
147
+ engine?: EngineInfo;
148
+ browser?: BrowserInfo;
149
+ useragent?: string;
150
+ }
151
+
152
+ export interface OSInfo {
153
+ version?: string;
154
+ name?: string;
155
+ }
156
+
157
+ export interface EngineInfo {
158
+ name?: string;
159
+ version?: string;
160
+ }
161
+
162
+ export interface BrowserInfo {
163
+ major?: string;
164
+ version?: string;
165
+ name?: string;
166
+ }
167
+
168
+ export type ConversationMessageType =
169
+ | "text"
170
+ | "file"
171
+ | "animation"
172
+ | "audio"
173
+ | "carousel"
174
+ | "note"
175
+ | "picker"
176
+ | "field";
177
+
178
+ export type ConversationState = "pending" | "unresolved" | "resolved";
179
+
180
+ export type ConversationContent = (
181
+ string |
182
+ ConversationFileMessageContent |
183
+ ConversationAnimationMessageContent |
184
+ ConversationAudioMessageContent |
185
+ ConversationPickerMessageContent |
186
+ ConversationFieldMessageContent |
187
+ ConversationCarouselMessageContent |
188
+ ConversationEventMessageContent
189
+ )
190
+
191
+ export interface ConversationMessage {
192
+ session_id?: string;
193
+ website_id?: string;
194
+ type?: ConversationMessageType;
195
+ from?: string;
196
+ origin?: string;
197
+ content?: ConversationContent;
198
+ preview?: ConversationMessagePreview[];
199
+ mentions?: string[];
200
+ read?: string;
201
+ delivered?: string;
202
+ ignored?: Record<string, ConversationMessageIgnored>;
203
+ edited?: boolean;
204
+ translated?: boolean;
205
+ automated?: boolean;
206
+ fingerprint?: number;
207
+ timestamp?: number;
208
+ user?: ConversationMessageUser;
209
+ references?: ConversationMessageReference[];
210
+ original?: ConversationMessageOriginal;
211
+ }
212
+
213
+ export interface ConversationFileMessageContent {
214
+ name?: string;
215
+ url?: string;
216
+ type?: string;
217
+ }
218
+
219
+ export interface ConversationAnimationMessageContent {
220
+ url?: string;
221
+ type?: string;
222
+ }
223
+
224
+ export interface ConversationAudioMessageContent {
225
+ url?: string;
226
+ type?: string;
227
+ duration?: number;
228
+ }
229
+
230
+ export interface ConversationPickerMessageContent {
231
+ id?: string;
232
+ text?: string;
233
+ choices?: ConversationPickerMessageContentChoice[];
234
+ required?: boolean;
235
+ }
236
+
237
+ export interface ConversationPickerMessageContentChoice {
238
+ value?: string;
239
+ icon?: string;
240
+ label?: string;
241
+ selected?: boolean;
242
+ action?: ConversationPickerMessageContentChoiceAction;
243
+ }
244
+
245
+ export interface ConversationPickerMessageContentChoiceAction {
246
+ type?: string;
247
+ target?: string;
248
+ }
249
+
250
+ export interface ConversationFieldMessageContent {
251
+ id?: string;
252
+ text?: string;
253
+ explain?: string;
254
+ value?: string;
255
+ required?: boolean;
256
+ }
257
+
258
+ export interface ConversationCarouselMessageContent {
259
+ text?: string;
260
+ targets?: ConversationCarouselMessageContentTarget[];
261
+ }
262
+
263
+ export interface ConversationCarouselMessageContentTarget {
264
+ title?: string;
265
+ description?: string;
266
+ image?: string;
267
+ actions?: ConversationCarouselMessageContentTargetAction[];
268
+ }
269
+
270
+ export interface ConversationCarouselMessageContentTargetAction {
271
+ label?: string;
272
+ url?: string;
273
+ }
274
+
275
+ export interface ConversationEventMessageContent {
276
+ namespace?: string;
277
+ text?: string;
278
+ }
279
+
280
+ export interface ConversationMessagePreview {
281
+ url?: string;
282
+ website?: string;
283
+ title?: string;
284
+ preview?: ConversationMessagePreviewInformation;
285
+ stamped?: boolean;
286
+ }
287
+
288
+ export interface ConversationMessagePreviewInformation {
289
+ excerpt?: string;
290
+ image?: string;
291
+ embed?: string;
292
+ }
293
+
294
+ export interface ConversationMessageIgnored {
295
+ type?: string;
296
+ reason?: string;
297
+ }
298
+
299
+ export interface ConversationMessageUser {
300
+ type?: string;
301
+ user_id?: string;
302
+ nickname?: string;
303
+ avatar?: string;
304
+ }
305
+
306
+ export interface ConversationMessageReference {
307
+ type?: string;
308
+ name?: string;
309
+ target?: string;
310
+ }
311
+
312
+ export interface ConversationMessageOriginal {
313
+ original_id?: string;
314
+ }
315
+
316
+ export type ConversationMessageNew = (
317
+ ConversationTextMessageNew |
318
+ ConversationFileMessageNew |
319
+ ConversationAnimationMessageNew |
320
+ ConversationAudioMessageNew |
321
+ ConversationPickerMessageNew |
322
+ ConversationFieldMessageNew |
323
+ ConversationCarouselMessageNew |
324
+ ConversationNoteMessageNew |
325
+ ConversationEventMessageNew
326
+ )
327
+
328
+ export interface ConversationTextMessageNew {
329
+ type: "text" | "note";
330
+ from: string;
331
+ origin: string;
332
+ content: unknown;
333
+ mentions?: string[];
334
+ fingerprint?: number;
335
+ user?: ConversationMessageUser;
336
+ references?: ConversationMessageReference[];
337
+ original?: ConversationMessageOriginal;
338
+ timestamp?: number;
339
+ stealth?: boolean;
340
+ translated?: boolean;
341
+ automated?: boolean;
342
+ }
343
+
344
+ export interface ConversationFileMessageNew {
345
+ type: "file";
346
+ from?: string;
347
+ origin?: string;
348
+ content?: ConversationFileMessageContent;
349
+ mentions?: string[];
350
+ fingerprint?: number;
351
+ user?: ConversationMessageUser;
352
+ references?: ConversationMessageReference[];
353
+ original?: ConversationMessageOriginal;
354
+ timestamp?: number;
355
+ stealth?: boolean;
356
+ translated?: boolean;
357
+ automated?: boolean;
358
+ }
359
+
360
+ export interface ConversationAnimationMessageNew {
361
+ type: "animation";
362
+ from?: string;
363
+ origin?: string;
364
+ content?: ConversationAnimationMessageContent;
365
+ mentions?: string[];
366
+ fingerprint?: number;
367
+ user?: ConversationMessageUser;
368
+ references?: ConversationMessageReference[];
369
+ original?: ConversationMessageOriginal;
370
+ timestamp?: number;
371
+ stealth?: boolean;
372
+ translated?: boolean;
373
+ automated?: boolean;
374
+ }
375
+
376
+ export interface ConversationAudioMessageNew {
377
+ type: "audio";
378
+ from?: string;
379
+ origin?: string;
380
+ content?: ConversationAudioMessageContent;
381
+ mentions?: string[];
382
+ fingerprint?: number;
383
+ user?: ConversationMessageUser;
384
+ references?: ConversationMessageReference[];
385
+ original?: ConversationMessageOriginal;
386
+ timestamp?: number;
387
+ stealth?: boolean;
388
+ translated?: boolean;
389
+ automated?: boolean;
390
+ }
391
+
392
+ export interface ConversationPickerMessageNew {
393
+ type: "picker";
394
+ from?: string;
395
+ origin?: string;
396
+ content?: ConversationPickerMessageContent;
397
+ mentions?: string[];
398
+ fingerprint?: number;
399
+ user?: ConversationMessageUser;
400
+ references?: ConversationMessageReference[];
401
+ original?: ConversationMessageOriginal;
402
+ timestamp?: number;
403
+ stealth?: boolean;
404
+ translated?: boolean;
405
+ automated?: boolean;
406
+ }
407
+
408
+ export interface ConversationFieldMessageNew {
409
+ type: "field";
410
+ from?: string;
411
+ origin?: string;
412
+ content?: ConversationFieldMessageContent;
413
+ mentions?: string[];
414
+ fingerprint?: number;
415
+ user?: ConversationMessageUser;
416
+ references?: ConversationMessageReference[];
417
+ original?: ConversationMessageOriginal;
418
+ timestamp?: number;
419
+ stealth?: boolean;
420
+ translated?: boolean;
421
+ automated?: boolean;
422
+ }
423
+
424
+ export interface ConversationCarouselMessageNew {
425
+ type: "carousel";
426
+ from?: string;
427
+ origin?: string;
428
+ content?: ConversationCarouselMessageContent;
429
+ mentions?: string[];
430
+ fingerprint?: number;
431
+ user?: ConversationMessageUser;
432
+ references?: ConversationMessageReference[];
433
+ original?: ConversationMessageOriginal;
434
+ timestamp?: number;
435
+ stealth?: boolean;
436
+ translated?: boolean;
437
+ automated?: boolean;
438
+ }
439
+
440
+ export interface ConversationNoteMessageNew extends ConversationTextMessageNew {
441
+ type: "note";
442
+ }
443
+
444
+ export interface ConversationEventMessageNew {
445
+ type: "event";
446
+ from?: string;
447
+ origin?: string;
448
+ content?: ConversationEventMessageContent;
449
+ mentions?: string[];
450
+ fingerprint?: number;
451
+ user?: ConversationMessageUser;
452
+ references?: ConversationMessageReference[];
453
+ original?: ConversationMessageOriginal;
454
+ timestamp?: number;
455
+ stealth?: boolean;
456
+ translated?: boolean;
457
+ automated?: boolean;
458
+ }
459
+
460
+ export interface ConversationComposeMessageNew {
461
+ type: string;
462
+ from: string;
463
+ excerpt?: string;
464
+ stealth?: boolean;
465
+ automated?: boolean;
466
+ }
467
+
468
+ export interface ConversationSuggestedSegment {
469
+ segment?: string;
470
+ count?: number;
471
+ }
472
+
473
+ export interface ConversationSuggestedData {
474
+ key?: string;
475
+ count?: number;
476
+ }
477
+
478
+ export interface ConversationSpam {
479
+ spam_id?: string;
480
+ type?: string;
481
+ reason?: string;
482
+ metadata?: Record<string, unknown>;
483
+ headers?: Record<string, unknown>;
484
+ timestamp?: number;
485
+ }
486
+
487
+ export interface ConversationSpamContent extends ConversationSpam {
488
+ content?: Record<string, unknown>;
489
+ }
490
+
491
+ export interface ConversationReadMessageMark {
492
+ from?: string;
493
+ origin?: string;
494
+ fingerprints?: number[];
495
+ }
496
+
497
+ export interface ConversationUnreadMessageMark {
498
+ from?: string;
499
+ }
500
+
501
+ export interface ConversationRoutingAssignUpdate {
502
+ assigned?: ConversationRoutingAssignUpdateAssigned;
503
+ silent?: boolean;
504
+ }
505
+
506
+ export interface ConversationRoutingAssignUpdateAssigned {
507
+ user_id?: string;
508
+ }
509
+
510
+ export interface ConversationOriginal {
511
+ website_id?: string;
512
+ session_id?: string;
513
+ original_id?: string;
514
+ type?: string;
515
+ /* eslint-disable @typescript-eslint/no-explicit-any */
516
+ headers?: Record<string, any>;
517
+ content?: string;
518
+ timestamp?: number;
519
+ }
520
+
521
+ export interface ConversationPage {
522
+ page_title?: string;
523
+ page_url?: string;
524
+ page_referrer?: string;
525
+ timestamp?: number;
526
+ }
527
+
528
+ export interface ConversationEvent {
529
+ text?: string;
530
+ data?: Record<string, any>;
531
+ color?: string;
532
+ timestamp?: number;
533
+ }
534
+
535
+ export interface ConversationFile {
536
+ name?: string;
537
+ type?: string;
538
+ url?: string;
539
+ fingerprint?: number;
540
+ timestamp?: number;
541
+ }
542
+
543
+ export interface ConversationStateData {
544
+ state?: ConversationState;
545
+ }
546
+
547
+ export interface ConversationBlock {
548
+ blocked?: boolean;
549
+ }
550
+
551
+ export interface ConversationVerify {
552
+ verified?: boolean;
553
+ verifications?: ConversationVerification[];
554
+ }
555
+
556
+ export interface ConversationVerifyIdentityRequest {
557
+ identity?: string;
558
+ method?: string;
559
+ recipient?: string;
560
+ }
561
+
562
+ export interface ConversationVerifyIdentityRedeem {
563
+ identity?: string;
564
+ token?: string;
565
+ recipient?: string;
566
+ }
567
+
568
+ export interface ConversationBrowsing {
569
+ browsing_id?: string;
570
+ browsing_token?: string;
571
+ useragent?: string;
572
+ }
573
+
574
+ export interface ConversationCall {
575
+ call_id?: string;
576
+ }
577
+
578
+ /**************************************************************************
579
+ * CLASSES
580
+ ***************************************************************************/
581
+
582
+ /**
583
+ * Crisp WebsiteConversation Resource
584
+ * @class
585
+ */
586
+ class WebsiteConversation extends BaseResource {
587
+ /**
588
+ * List Conversations
589
+ */
590
+ listConversations(
591
+ websiteID: string, pageNumber: number = 1
592
+ ): Promise<Conversation[]> {
593
+ return this.crisp.get(
594
+ this.crisp.prepareRestUrl(["website", websiteID, "conversations", String(pageNumber)])
595
+ );
596
+ };
597
+
598
+ /**
599
+ * List Suggested Conversation Segments
600
+ */
601
+ listSuggestedConversationSegments(
602
+ websiteID: string, pageNumber: number = 1
603
+ ): Promise<ConversationSuggestedSegment[]> {
604
+ return this.crisp.get(
605
+ this.crisp.prepareRestUrl([
606
+ "website", websiteID, "conversations", "suggest", "segments", String(pageNumber)
607
+ ])
608
+ );
609
+ };
610
+
611
+ /**
612
+ * Delete Suggested Conversation Segment
613
+ */
614
+ deleteSuggestedConversationSegment(websiteID: string, segment: string) {
615
+ return this.crisp.delete(
616
+ this.crisp.prepareRestUrl([
617
+ "website", websiteID, "conversations", "suggest", "segment"
618
+ ]),
619
+
620
+ null,
621
+
622
+ {
623
+ segment: segment
624
+ }
625
+ );
626
+ };
627
+
628
+ /**
629
+ * List Suggested Conversation Data Keys
630
+ */
631
+ listSuggestedConversationDataKeys(
632
+ websiteID: string, pageNumber: number = 1
633
+ ): Promise<ConversationSuggestedData[]> {
634
+ return this.crisp.get(
635
+ this.crisp.prepareRestUrl([
636
+ "website", websiteID, "conversations", "suggest", "data", String(pageNumber)
637
+ ])
638
+ );
639
+ };
640
+
641
+ /**
642
+ * Delete Suggested Conversation Data Key
643
+ */
644
+ deleteSuggestedConversationDataKey(websiteID: string, key: string) {
645
+ return this.crisp.delete(
646
+ this.crisp.prepareRestUrl([
647
+ "website", websiteID, "conversations", "suggest", "data"
648
+ ]),
649
+
650
+ null,
651
+
652
+ {
653
+ key: key
654
+ }
655
+ );
656
+ };
657
+
658
+ /**
659
+ * List Spam Conversations
660
+ */
661
+ listSpamConversations(
662
+ websiteID: string, pageNumber: number = 1
663
+ ): Promise<ConversationSpam[]> {
664
+ return this.crisp.get(
665
+ this.crisp.prepareRestUrl([
666
+ "website", websiteID, "conversations", "spams", String(pageNumber)
667
+ ])
668
+ );
669
+ };
670
+
671
+ /**
672
+ * Resolve Spam Conversation Content
673
+ */
674
+ resolveSpamConversationContent(
675
+ websiteID: string, spamID: string
676
+ ): Promise<ConversationSpamContent> {
677
+ return this.crisp.get(
678
+ this.crisp.prepareRestUrl([
679
+ "website", websiteID, "conversations", "spam", spamID, "content"
680
+ ])
681
+ );
682
+ };
683
+
684
+ /**
685
+ * Submit Spam Conversation Decision
686
+ */
687
+ submitSpamConversationDecision(
688
+ websiteID: string, spamID: string, action: string
689
+ ) {
690
+ return this.crisp.post(
691
+ this.crisp.prepareRestUrl([
692
+ "website", websiteID, "conversations", "spam", spamID, "decision"
693
+ ]),
694
+
695
+ null,
696
+
697
+ {
698
+ action: action
699
+ }
700
+ );
701
+ };
702
+
703
+ /**
704
+ * Create A New Conversation
705
+ */
706
+ createNewConversation(websiteID: string): Promise<ConversationNew> {
707
+ return this.crisp.post(
708
+ this.crisp.prepareRestUrl(["website", websiteID, "conversation"]),
709
+
710
+ null,
711
+
712
+ null
713
+ );
714
+ };
715
+
716
+ /**
717
+ * Check If Conversation Exists
718
+ */
719
+ checkConversationExists(websiteID: string, sessionID: string) {
720
+ return this.crisp.head(
721
+ this.crisp.prepareRestUrl([
722
+ "website", websiteID, "conversation", sessionID
723
+ ])
724
+ );
725
+ };
726
+
727
+ /**
728
+ * Get A Conversation
729
+ */
730
+ getConversation(websiteID: string, sessionID: string): Promise<Conversation> {
731
+ return this.crisp.get(
732
+ this.crisp.prepareRestUrl([
733
+ "website", websiteID, "conversation", sessionID
734
+ ])
735
+ );
736
+ };
737
+
738
+ /**
739
+ * Remove A Conversation
740
+ */
741
+ removeConversation(websiteID: string, sessionID: string) {
742
+ return this.crisp.delete(
743
+ this.crisp.prepareRestUrl([
744
+ "website", websiteID, "conversation", sessionID
745
+ ])
746
+ );
747
+ };
748
+
749
+ /**
750
+ * Initiate A Conversation With Existing Session
751
+ */
752
+ initiateConversationWithExistingSession(websiteID: string, sessionID: string) {
753
+ return this.crisp.post(
754
+ this.crisp.prepareRestUrl([
755
+ "website", websiteID, "conversation", sessionID, "initiate"
756
+ ]),
757
+
758
+ null,
759
+
760
+ null
761
+ );
762
+ };
763
+
764
+ /**
765
+ * Get Messages In Conversation
766
+ */
767
+ getMessagesInConversation(
768
+ websiteID: string, sessionID: string, timestampBefore?: string|number
769
+ ): Promise<ConversationMessage[]> {
770
+ // Generate query
771
+ let query = {};
772
+
773
+ if (timestampBefore) {
774
+ // @ts-ignore
775
+ query.timestamp_before = String(timestampBefore);
776
+ }
777
+
778
+ return this.crisp.get(
779
+ this.crisp.prepareRestUrl([
780
+ "website", websiteID, "conversation", sessionID, "messages"
781
+ ]),
782
+
783
+ query
784
+ );
785
+ };
786
+
787
+ /**
788
+ * Send A Message In Conversation
789
+ */
790
+ sendMessageInConversation(
791
+ websiteID: string, sessionID: string, message: ConversationMessageNew
792
+ ) {
793
+ return this.crisp.post(
794
+ this.crisp.prepareRestUrl([
795
+ "website", websiteID, "conversation", sessionID, "message"
796
+ ]),
797
+
798
+ null, message
799
+ );
800
+ };
801
+
802
+ /**
803
+ * Get A Message In Conversation
804
+ */
805
+ getMessageInConversation(
806
+ websiteID: string, sessionID: string, fingerprint: number
807
+ ): Promise<ConversationMessage> {
808
+ return this.crisp.get(
809
+ this.crisp.prepareRestUrl([
810
+ "website", websiteID, "conversation", sessionID, "message", String(fingerprint)
811
+ ])
812
+ );
813
+ };
814
+
815
+ /**
816
+ * Update A Message In Conversation
817
+ */
818
+ updateMessageInConversation(
819
+ websiteID: string, sessionID: string, fingerprint: number, content: ConversationContent
820
+ ) {
821
+ return this.crisp.patch(
822
+ this.crisp.prepareRestUrl([
823
+ "website", websiteID, "conversation", sessionID, "message", String(fingerprint)
824
+ ]),
825
+
826
+ null,
827
+
828
+ {
829
+ content: content
830
+ }
831
+ );
832
+ };
833
+
834
+ /**
835
+ * Remove A Message In Conversation
836
+ */
837
+ removeMessageInConversation(
838
+ websiteID: string, sessionID: string, fingerprint: number
839
+ ) {
840
+ return this.crisp.delete(
841
+ this.crisp.prepareRestUrl([
842
+ "website", websiteID, "conversation", sessionID, "message", String(fingerprint)
843
+ ])
844
+ );
845
+ };
846
+
847
+ /**
848
+ * Compose A Message In Conversation
849
+ */
850
+ composeMessageInConversation(
851
+ websiteID: string, sessionID: string, compose: ConversationComposeMessageNew
852
+ ) {
853
+ return this.crisp.patch(
854
+ this.crisp.prepareRestUrl([
855
+ "website", websiteID, "conversation", sessionID, "compose"
856
+ ]),
857
+
858
+ null, compose
859
+ );
860
+ };
861
+
862
+ /**
863
+ * Mark Messages As Read In Conversation
864
+ */
865
+ markMessagesReadInConversation(
866
+ websiteID: string, sessionID: string, read: ConversationReadMessageMark
867
+ ) {
868
+ return this.crisp.patch(
869
+ this.crisp.prepareRestUrl([
870
+ "website", websiteID, "conversation", sessionID, "read"
871
+ ]),
872
+
873
+ null, read
874
+ );
875
+ };
876
+
877
+ /**
878
+ * Mark Conversation As Unread
879
+ */
880
+ markConversationAsUnread(
881
+ websiteID: string, sessionID: string, unread: ConversationUnreadMessageMark
882
+ ) {
883
+ return this.crisp.patch(
884
+ this.crisp.prepareRestUrl([
885
+ "website", websiteID, "conversation", sessionID, "unread"
886
+ ]),
887
+
888
+ null, unread
889
+ );
890
+ };
891
+
892
+ /**
893
+ * Mark Messages As Delivered In Conversation
894
+ */
895
+ markMessagesDeliveredInConversation(
896
+ websiteID: string, sessionID: string, delivered: ConversationReadMessageMark
897
+ ) {
898
+ return this.crisp.patch(
899
+ this.crisp.prepareRestUrl([
900
+ "website", websiteID, "conversation", sessionID, "delivered"
901
+ ]),
902
+
903
+ null, delivered
904
+ );
905
+ };
906
+
907
+ /**
908
+ * Update Conversation Open State
909
+ */
910
+ updateConversationOpenState(
911
+ websiteID: string, sessionID: string, opened: boolean
912
+ ) {
913
+ return this.crisp.patch(
914
+ this.crisp.prepareRestUrl([
915
+ "website", websiteID, "conversation", sessionID, "open"
916
+ ]),
917
+
918
+ null,
919
+
920
+ {
921
+ opened: (opened || false)
922
+ }
923
+ );
924
+ };
925
+
926
+ /**
927
+ * Get Conversation Routing Assign
928
+ */
929
+ getConversationRoutingAssign(websiteID: string, sessionID: string) {
930
+ return this.crisp.get(
931
+ this.crisp.prepareRestUrl([
932
+ "website", websiteID, "conversation", sessionID, "routing"
933
+ ])
934
+ );
935
+ };
936
+
937
+ /**
938
+ * Assign Conversation Routing
939
+ */
940
+ assignConversationRouting(
941
+ websiteID: string, sessionID: string, assign: ConversationRoutingAssignUpdate
942
+ ) {
943
+ return this.crisp.patch(
944
+ this.crisp.prepareRestUrl([
945
+ "website", websiteID, "conversation", sessionID, "routing"
946
+ ]),
947
+
948
+ null, assign
949
+ );
950
+ };
951
+
952
+ /**
953
+ * Update Conversation Inbox
954
+ */
955
+ updateConversationInbox(
956
+ websiteID: string, sessionID: string, inboxID: string
957
+ ) {
958
+ return this.crisp.patch(
959
+ this.crisp.prepareRestUrl([
960
+ "website", websiteID, "conversation", sessionID, "inbox"
961
+ ]),
962
+
963
+ null,
964
+
965
+ {
966
+ inbox_id: inboxID
967
+ }
968
+ );
969
+ }
970
+
971
+ /**
972
+ * Get Conversation Metas
973
+ */
974
+ getConversationMetas(
975
+ websiteID: string, sessionID: string
976
+ ): Promise<ConversationMeta> {
977
+ return this.crisp.get(
978
+ this.crisp.prepareRestUrl([
979
+ "website", websiteID, "conversation", sessionID, "meta"
980
+ ])
981
+ );
982
+ }
983
+
984
+ /**
985
+ * Update Conversation Metas
986
+ */
987
+ updateConversationMetas(
988
+ websiteID: string, sessionID: string, metas: ConversationMeta
989
+ ) {
990
+ return this.crisp.patch(
991
+ this.crisp.prepareRestUrl([
992
+ "website", websiteID, "conversation", sessionID, "meta"
993
+ ]),
994
+
995
+ null, metas
996
+ );
997
+ }
998
+
999
+ /**
1000
+ * Get An Original Message In Conversation
1001
+ */
1002
+ getOriginalMessageInConversation(
1003
+ websiteID: string, sessionID: string, originalID: string
1004
+ ): Promise<ConversationOriginal> {
1005
+ return this.crisp.get(
1006
+ this.crisp.prepareRestUrl([
1007
+ "website", websiteID, "conversation", sessionID, "original", originalID
1008
+ ])
1009
+ );
1010
+ }
1011
+
1012
+ /**
1013
+ * List Conversation Pages
1014
+ */
1015
+ listConversationPages(
1016
+ websiteID: string, sessionID: string, pageNumber: number = 1
1017
+ ): Promise<ConversationPage[]> {
1018
+ return this.crisp.get(
1019
+ this.crisp.prepareRestUrl([
1020
+ "website", websiteID, "conversation", sessionID, "pages", String(pageNumber)
1021
+ ])
1022
+ );
1023
+ };
1024
+
1025
+ /**
1026
+ * List Conversation Events
1027
+ */
1028
+ listConversationEvents(
1029
+ websiteID: string, sessionID: string, pageNumber: number = 1
1030
+ ): Promise<ConversationEvent[]> {
1031
+ return this.crisp.get(
1032
+ this.crisp.prepareRestUrl([
1033
+ "website", websiteID, "conversation", sessionID, "events", String(pageNumber)
1034
+ ])
1035
+ );
1036
+ };
1037
+
1038
+ /**
1039
+ * List Conversation Files
1040
+ */
1041
+ listConversationFiles(
1042
+ websiteID: string, sessionID: string, pageNumber: number = 1
1043
+ ): Promise<ConversationFile[]> {
1044
+ return this.crisp.get(
1045
+ this.crisp.prepareRestUrl([
1046
+ "website", websiteID, "conversation", sessionID, "files", String(pageNumber)
1047
+ ])
1048
+ );
1049
+ };
1050
+
1051
+ /**
1052
+ * Get Conversation State
1053
+ */
1054
+ getConversationState(
1055
+ websiteID: string, sessionID: string
1056
+ ): Promise<ConversationStateData> {
1057
+ return this.crisp.get(
1058
+ this.crisp.prepareRestUrl([
1059
+ "website", websiteID, "conversation", sessionID, "state"
1060
+ ])
1061
+ );
1062
+ };
1063
+
1064
+ /**
1065
+ * Change Conversation State
1066
+ */
1067
+ changeConversationState(
1068
+ websiteID: string, sessionID: string, state: ConversationState
1069
+ ) {
1070
+ return this.crisp.patch(
1071
+ this.crisp.prepareRestUrl([
1072
+ "website", websiteID, "conversation", sessionID, "state"
1073
+ ]),
1074
+
1075
+ null,
1076
+
1077
+ {
1078
+ state: state
1079
+ }
1080
+ );
1081
+ };
1082
+
1083
+ /**
1084
+ * Get Conversation Participants
1085
+ */
1086
+ getConversationParticipants(
1087
+ websiteID: string, sessionID: string
1088
+ ): Promise<ConversationParticipant[]> {
1089
+ return this.crisp.get(
1090
+ this.crisp.prepareRestUrl([
1091
+ "website", websiteID, "conversation", sessionID, "participants"
1092
+ ])
1093
+ );
1094
+ };
1095
+
1096
+ /**
1097
+ * Save Conversation Participants
1098
+ */
1099
+ saveConversationParticipants(
1100
+ websiteID: string, sessionID: string, participants: ConversationParticipantsSave
1101
+ ) {
1102
+ return this.crisp.put(
1103
+ this.crisp.prepareRestUrl([
1104
+ "website", websiteID, "conversation", sessionID, "participants"
1105
+ ]),
1106
+
1107
+ null, participants
1108
+ );
1109
+ };
1110
+
1111
+ /**
1112
+ * Get Block Status For Conversation
1113
+ */
1114
+ getBlockStatusForConversation(
1115
+ websiteID: string, sessionID: string
1116
+ ): Promise<ConversationBlock> {
1117
+ return this.crisp.get(
1118
+ this.crisp.prepareRestUrl([
1119
+ "website", websiteID, "conversation", sessionID, "block"
1120
+ ])
1121
+ );
1122
+ };
1123
+
1124
+ /**
1125
+ * Block Incoming Messages For Conversation
1126
+ */
1127
+ blockIncomingMessagesForConversation(
1128
+ websiteID: string, sessionID: string, blocked: boolean
1129
+ ) {
1130
+ return this.crisp.patch(
1131
+ this.crisp.prepareRestUrl([
1132
+ "website", websiteID, "conversation", sessionID, "block"
1133
+ ]),
1134
+
1135
+ null,
1136
+
1137
+ {
1138
+ blocked: (blocked || false)
1139
+ }
1140
+ );
1141
+ };
1142
+
1143
+ /**
1144
+ * Get Verify Status For Conversation
1145
+ */
1146
+ getVerifyStatusForConversation(
1147
+ websiteID: string, sessionID: string
1148
+ ): Promise<ConversationVerify> {
1149
+ return this.crisp.get(
1150
+ this.crisp.prepareRestUrl([
1151
+ "website", websiteID, "conversation", sessionID, "verify"
1152
+ ])
1153
+ );
1154
+ };
1155
+
1156
+ /**
1157
+ * Update Verify Status For Conversation
1158
+ */
1159
+ updateVerifyStatusForConversation(
1160
+ websiteID: string, sessionID: string, verified: boolean
1161
+ ) {
1162
+ return this.crisp.patch(
1163
+ this.crisp.prepareRestUrl([
1164
+ "website", websiteID, "conversation", sessionID, "verify"
1165
+ ]),
1166
+
1167
+ null,
1168
+
1169
+ {
1170
+ verified: (verified || false)
1171
+ }
1172
+ );
1173
+ };
1174
+
1175
+ /**
1176
+ * Request Identity Verification For Conversation
1177
+ */
1178
+ requestIdentityVerificationForConversation(
1179
+ websiteID: string, sessionID: string,
1180
+ verification: ConversationVerifyIdentityRequest
1181
+ ) {
1182
+ return this.crisp.post(
1183
+ this.crisp.prepareRestUrl([
1184
+ "website", websiteID, "conversation", sessionID, "verify", "identity"
1185
+ ]),
1186
+
1187
+ null, verification
1188
+ );
1189
+ };
1190
+
1191
+ /**
1192
+ * Redeem Identity Verification Link For Conversation
1193
+ */
1194
+ redeemIdentityVerificationLinkForConversation(
1195
+ websiteID: string, sessionID: string,
1196
+ verification: ConversationVerifyIdentityRedeem
1197
+ ) {
1198
+ return this.crisp.put(
1199
+ this.crisp.prepareRestUrl([
1200
+ "website", websiteID, "conversation", sessionID, "verify", "identity",
1201
+ "link"
1202
+ ]),
1203
+
1204
+ null, verification
1205
+ );
1206
+ };
1207
+
1208
+ /**
1209
+ * Request Email Transcript For Conversation
1210
+ */
1211
+ requestEmailTranscriptForConversation(
1212
+ websiteID: string, sessionID: string, to: string, email?: string
1213
+ ) {
1214
+ // Generate body
1215
+ let body = {
1216
+ to: to
1217
+ };
1218
+
1219
+ if (email) {
1220
+ // @ts-ignore
1221
+ body.email = email;
1222
+ }
1223
+
1224
+ return this.crisp.post(
1225
+ this.crisp.prepareRestUrl([
1226
+ "website", websiteID, "conversation", sessionID, "transcript"
1227
+ ]),
1228
+
1229
+ null, body
1230
+ );
1231
+ };
1232
+
1233
+ /**
1234
+ * Request Chatbox Binding Purge For Conversation
1235
+ */
1236
+ requestChatboxBindingPurgeForConversation(
1237
+ websiteID: string, sessionID: string
1238
+ ) {
1239
+ return this.crisp.post(
1240
+ this.crisp.prepareRestUrl([
1241
+ "website", websiteID, "conversation", sessionID, "purge"
1242
+ ]),
1243
+
1244
+ null,
1245
+
1246
+ null
1247
+ );
1248
+ };
1249
+
1250
+ /**
1251
+ * Request User Feedback For Conversation
1252
+ */
1253
+ requestUserFeedbackForConversation(websiteID: string, sessionID: string) {
1254
+ return this.crisp.post(
1255
+ this.crisp.prepareRestUrl([
1256
+ "website", websiteID, "conversation", sessionID, "feedback"
1257
+ ]),
1258
+
1259
+ null,
1260
+
1261
+ null
1262
+ );
1263
+ };
1264
+
1265
+ /**
1266
+ * List Browsing Sessions For Conversation
1267
+ */
1268
+ listBrowsingSessionsForConversation(
1269
+ websiteID: string, sessionID: string
1270
+ ): Promise<ConversationBrowsing[]> {
1271
+ return this.crisp.get(
1272
+ this.crisp.prepareRestUrl([
1273
+ "website", websiteID, "conversation", sessionID, "browsing"
1274
+ ])
1275
+ );
1276
+ };
1277
+
1278
+ /**
1279
+ * Initiate Browsing Session For Conversation
1280
+ */
1281
+ initiateBrowsingSessionForConversation(websiteID: string, sessionID: string) {
1282
+ return this.crisp.post(
1283
+ this.crisp.prepareRestUrl([
1284
+ "website", websiteID, "conversation", sessionID, "browsing"
1285
+ ]),
1286
+
1287
+ null,
1288
+
1289
+ null
1290
+ );
1291
+ };
1292
+
1293
+ /**
1294
+ * Send Action To An Existing Browsing Session
1295
+ */
1296
+ sendActionToExistingBrowsingSession(
1297
+ websiteID: string, sessionID: string, browsingID: string, action: string
1298
+ ) {
1299
+ return this.crisp.patch(
1300
+ this.crisp.prepareRestUrl([
1301
+ "website", websiteID, "conversation", sessionID, "browsing", browsingID
1302
+ ]),
1303
+
1304
+ null,
1305
+
1306
+ {
1307
+ action: action
1308
+ }
1309
+ );
1310
+ };
1311
+
1312
+ /**
1313
+ * Assist Existing Browsing Session
1314
+ */
1315
+ assistExistingBrowsingSession(
1316
+ websiteID: string, sessionID: string, browsingID: string, assist: object
1317
+ ) {
1318
+ return this.crisp.patch(
1319
+ this.crisp.prepareRestUrl([
1320
+ "website", websiteID, "conversation", sessionID, "browsing", browsingID,
1321
+ "assist"
1322
+ ]),
1323
+
1324
+ null, assist
1325
+ );
1326
+ };
1327
+
1328
+ /**
1329
+ * Initiate New Call Session For Conversation
1330
+ */
1331
+ initiateNewCallSessionForConversation(
1332
+ websiteID: string, sessionID: string, mode: string
1333
+ ) {
1334
+ return this.crisp.post(
1335
+ this.crisp.prepareRestUrl([
1336
+ "website", websiteID, "conversation", sessionID, "call"
1337
+ ]),
1338
+
1339
+ null,
1340
+
1341
+ {
1342
+ mode: (mode || "audio")
1343
+ }
1344
+ );
1345
+ };
1346
+
1347
+ /**
1348
+ * Get Ongoing Call Session For Conversation
1349
+ */
1350
+ getOngoingCallSessionForConversation(
1351
+ websiteID: string, sessionID: string
1352
+ ): Promise<ConversationCall> {
1353
+ return this.crisp.get(
1354
+ this.crisp.prepareRestUrl([
1355
+ "website", websiteID, "conversation", sessionID, "call"
1356
+ ])
1357
+ );
1358
+ };
1359
+
1360
+ /**
1361
+ * Abort Ongoing Call Session For Conversation
1362
+ */
1363
+ abortOngoingCallSessionForConversation(
1364
+ websiteID: string, sessionID: string, callID: string
1365
+ ) {
1366
+ return this.crisp.delete(
1367
+ this.crisp.prepareRestUrl([
1368
+ "website", websiteID, "conversation", sessionID, "call", callID
1369
+ ])
1370
+ );
1371
+ };
1372
+
1373
+ /**
1374
+ * Transmit Signaling On Ongoing Call Session
1375
+ */
1376
+ transmitSignalingOnOngoingCallSession(
1377
+ websiteID: string, sessionID: string, callID: string, payload: object
1378
+ ) {
1379
+ return this.crisp.patch(
1380
+ this.crisp.prepareRestUrl([
1381
+ "website", websiteID, "conversation", sessionID, "call", callID
1382
+ ]),
1383
+
1384
+ null, payload
1385
+ );
1386
+ };
1387
+
1388
+ /**
1389
+ * Deliver Widget Button Action For Conversation
1390
+ */
1391
+ deliverWidgetButtonActionForConversation(
1392
+ websiteID: string, sessionID: string, pluginID: string, sectionID: string,
1393
+ itemID: string, data: object, value?: string
1394
+ ) {
1395
+ // Generate body
1396
+ let body = {
1397
+ section_id: sectionID,
1398
+ item_id: itemID,
1399
+ data: data
1400
+ };
1401
+
1402
+ if (typeof value !== "undefined") {
1403
+ // @ts-ignore
1404
+ body.value = value;
1405
+ }
1406
+
1407
+ return this.crisp.post(
1408
+ this.crisp.prepareRestUrl([
1409
+ "website", websiteID, "conversation", sessionID, "widget", pluginID,
1410
+ "button"
1411
+ ]),
1412
+
1413
+ null, body
1414
+ );
1415
+ };
1416
+
1417
+ /**
1418
+ * Deliver Widget Data Fetch Action For Conversation
1419
+ */
1420
+ deliverWidgetDataFetchActionForConversation(
1421
+ websiteID: string, sessionID: string, pluginID: string, sectionID: string,
1422
+ itemID: string, data: object
1423
+ ) {
1424
+ return this.crisp.post(
1425
+ this.crisp.prepareRestUrl([
1426
+ "website", websiteID, "conversation", sessionID, "widget", pluginID,
1427
+ "data"
1428
+ ]),
1429
+
1430
+ null,
1431
+
1432
+ {
1433
+ section_id: sectionID,
1434
+ item_id: itemID,
1435
+ data: data
1436
+ }
1437
+ );
1438
+ };
1439
+
1440
+ /**
1441
+ * Deliver Widget Data Edit Action For Conversation
1442
+ */
1443
+ deliverWidgetDataEditActionForConversation(
1444
+ websiteID: string, sessionID: string, pluginID: string, sectionID: string,
1445
+ itemID: string, value: string
1446
+ ) {
1447
+ return this.crisp.post(
1448
+ this.crisp.prepareRestUrl([
1449
+ "website", websiteID, "conversation", sessionID, "widget", pluginID,
1450
+ "data"
1451
+ ]),
1452
+
1453
+ null,
1454
+
1455
+ {
1456
+ section_id: sectionID,
1457
+ item_id: itemID,
1458
+ value: value
1459
+ }
1460
+ );
1461
+ };
1462
+
1463
+ /**
1464
+ * Schedule A Reminder For Conversation
1465
+ */
1466
+ scheduleReminderForConversation(
1467
+ websiteID: string, sessionID: string, date: string, note: string
1468
+ ) {
1469
+ return this.crisp.post(
1470
+ this.crisp.prepareRestUrl([
1471
+ "website", websiteID, "conversation", sessionID, "reminder"
1472
+ ]),
1473
+
1474
+ null,
1475
+
1476
+ {
1477
+ date: date,
1478
+ note: note
1479
+ }
1480
+ );
1481
+ };
1482
+
1483
+ /**
1484
+ * Report Conversation
1485
+ */
1486
+ reportConversation(
1487
+ websiteID: string, sessionID: string, flag: string
1488
+ ) {
1489
+ return this.crisp.post(
1490
+ this.crisp.prepareRestUrl([
1491
+ "website", websiteID, "conversation", sessionID, "report"
1492
+ ]),
1493
+
1494
+ null,
1495
+
1496
+ {
1497
+ flag: flag
1498
+ }
1499
+ );
1500
+ };
1501
+ }
1502
+
1503
+ /**************************************************************************
1504
+ * EXPORTS
1505
+ ***************************************************************************/
1506
+
1507
+ export default WebsiteConversation;