crisp-api 7.4.2 → 8.0.1

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.
@@ -0,0 +1,1172 @@
1
+ /*
2
+ * node-crisp-api
3
+ *
4
+ * Copyright 2023, Crisp IM SAS
5
+ * Author: Valerian Saliou <valerian@valeriansaliou.name>
6
+ */
7
+
8
+
9
+ "use strict";
10
+
11
+
12
+ /**
13
+ * Crisp WebsiteHelpdesk Resource
14
+ * @class
15
+ * @classdesc This is the Crisp Website Helpdesk Resource
16
+ */
17
+ function WebsiteHelpdesk(service, crisp) {
18
+ /**
19
+ * Check If Helpdesk Exists
20
+ * @memberof WebsiteConversation
21
+ * @public
22
+ * @method checkHelpdeskExists
23
+ * @param {string} websiteID
24
+ * @return {Promise}
25
+ */
26
+ service.checkHelpdeskExists = function(websiteID) {
27
+ return crisp.head(
28
+ crisp._prepareRestUrl(["website", websiteID, "helpdesk"])
29
+ );
30
+ };
31
+
32
+ /**
33
+ * Resolve Helpdesk
34
+ * @memberof WebsiteConversation
35
+ * @public
36
+ * @method resolveHelpdesk
37
+ * @param {string} websiteID
38
+ * @return {Promise}
39
+ */
40
+ service.resolveHelpdesk = function(websiteID) {
41
+ return crisp.get(
42
+ crisp._prepareRestUrl(["website", websiteID, "helpdesk"])
43
+ );
44
+ };
45
+
46
+ /**
47
+ * Initialize Helpdesk
48
+ * @memberof WebsiteConversation
49
+ * @public
50
+ * @method initializeHelpdesk
51
+ * @param {string} websiteID
52
+ * @param {string} name
53
+ * @param {string} domainBasic
54
+ * @return {Promise}
55
+ */
56
+ service.initializeHelpdesk = function(websiteID, name, domainBasic) {
57
+ return crisp.post(
58
+ crisp._prepareRestUrl(["website", websiteID, "helpdesk"]), null,
59
+
60
+ {
61
+ name : name,
62
+ domain_basic : domainBasic
63
+ }
64
+ );
65
+ };
66
+
67
+ /**
68
+ * Delete Helpdesk
69
+ * @memberof WebsiteConversation
70
+ * @public
71
+ * @method deleteHelpdesk
72
+ * @param {string} websiteID
73
+ * @param {string} verify
74
+ * @return {Promise}
75
+ */
76
+ service.deleteHelpdesk = function(websiteID, verify) {
77
+ return crisp.delete(
78
+ crisp._prepareRestUrl(["website", websiteID, "helpdesk"]), null,
79
+
80
+ {
81
+ verify : verify
82
+ }
83
+ );
84
+ };
85
+
86
+ /**
87
+ * List Helpdesk Locales
88
+ * @memberof WebsiteConversation
89
+ * @public
90
+ * @method listHelpdeskLocales
91
+ * @param {string} websiteID
92
+ * @param {number} pageNumber
93
+ * @return {Promise}
94
+ */
95
+ service.listHelpdeskLocales = function(websiteID, pageNumber) {
96
+ return crisp.get(
97
+ crisp._prepareRestUrl([
98
+ "website", websiteID, "helpdesk", "locales", pageNumber
99
+ ])
100
+ );
101
+ };
102
+
103
+ /**
104
+ * Add Helpdesk Locale
105
+ * @memberof WebsiteConversation
106
+ * @public
107
+ * @method addHelpdeskLocale
108
+ * @param {string} websiteID
109
+ * @param {string} locale
110
+ * @return {Promise}
111
+ */
112
+ service.addHelpdeskLocale = function(websiteID, locale) {
113
+ return crisp.post(
114
+ crisp._prepareRestUrl(["website", websiteID, "helpdesk", "locale"]),
115
+
116
+ null,
117
+
118
+ {
119
+ locale : locale
120
+ }
121
+ );
122
+ };
123
+
124
+ /**
125
+ * Check If Helpdesk Locale Exists
126
+ * @memberof WebsiteConversation
127
+ * @public
128
+ * @method checkHelpdeskLocaleExists
129
+ * @param {string} websiteID
130
+ * @param {string} locale
131
+ * @return {Promise}
132
+ */
133
+ service.checkHelpdeskLocaleExists = function(websiteID, locale) {
134
+ return crisp.head(
135
+ crisp._prepareRestUrl([
136
+ "website", websiteID, "helpdesk", "locale", locale
137
+ ])
138
+ );
139
+ };
140
+
141
+ /**
142
+ * Resolve Helpdesk Locale
143
+ * @memberof WebsiteConversation
144
+ * @public
145
+ * @method resolveHelpdeskLocale
146
+ * @param {string} websiteID
147
+ * @param {string} locale
148
+ * @return {Promise}
149
+ */
150
+ service.resolveHelpdeskLocale = function(websiteID, locale) {
151
+ return crisp.get(
152
+ crisp._prepareRestUrl([
153
+ "website", websiteID, "helpdesk", "locale", locale
154
+ ])
155
+ );
156
+ };
157
+
158
+ /**
159
+ * Delete Helpdesk Locale
160
+ * @memberof WebsiteConversation
161
+ * @public
162
+ * @method deleteHelpdeskLocale
163
+ * @param {string} websiteID
164
+ * @param {string} locale
165
+ * @return {Promise}
166
+ */
167
+ service.deleteHelpdeskLocale = function(websiteID, locale) {
168
+ return crisp.delete(
169
+ crisp._prepareRestUrl([
170
+ "website", websiteID, "helpdesk", "locale", locale
171
+ ])
172
+ );
173
+ };
174
+
175
+ /**
176
+ * List Helpdesk Locale Articles
177
+ * @memberof WebsiteConversation
178
+ * @public
179
+ * @method listHelpdeskLocaleArticles
180
+ * @param {string} websiteID
181
+ * @param {string} locale
182
+ * @param {number} pageNumber
183
+ * @return {Promise}
184
+ */
185
+ service.listHelpdeskLocaleArticles = function(websiteID, locale, pageNumber) {
186
+ return crisp.get(
187
+ crisp._prepareRestUrl([
188
+ "website", websiteID, "helpdesk", "locale", locale, "articles",
189
+ pageNumber
190
+ ])
191
+ );
192
+ };
193
+
194
+ /**
195
+ * Add A New Helpdesk Locale Article
196
+ * @memberof WebsiteConversation
197
+ * @public
198
+ * @method addNewHelpdeskLocaleArticle
199
+ * @param {string} websiteID
200
+ * @param {string} locale
201
+ * @param {string} title
202
+ * @return {Promise}
203
+ */
204
+ service.addNewHelpdeskLocaleArticle = function(websiteID, locale, title) {
205
+ return crisp.post(
206
+ crisp._prepareRestUrl([
207
+ "website", websiteID, "helpdesk", "locale", locale, "article"
208
+ ]),
209
+
210
+ null,
211
+
212
+ {
213
+ title : title
214
+ }
215
+ );
216
+ };
217
+
218
+ /**
219
+ * Check If Helpdesk Locale Article Exists
220
+ * @memberof WebsiteConversation
221
+ * @public
222
+ * @method checkHelpdeskLocaleArticleExists
223
+ * @param {string} websiteID
224
+ * @param {string} locale
225
+ * @param {string} articleId
226
+ * @return {Promise}
227
+ */
228
+ service.checkHelpdeskLocaleArticleExists = function(
229
+ websiteID, locale, articleId
230
+ ) {
231
+ return crisp.head(
232
+ crisp._prepareRestUrl([
233
+ "website", websiteID, "helpdesk", "locale", locale, "article", articleId
234
+ ])
235
+ );
236
+ };
237
+
238
+ /**
239
+ * Resolve Helpdesk Locale Article
240
+ * @memberof WebsiteConversation
241
+ * @public
242
+ * @method resolveHelpdeskLocaleArticle
243
+ * @param {string} websiteID
244
+ * @param {string} locale
245
+ * @param {string} articleId
246
+ * @return {Promise}
247
+ */
248
+ service.resolveHelpdeskLocaleArticle = function(
249
+ websiteID, locale, articleId
250
+ ) {
251
+ return crisp.get(
252
+ crisp._prepareRestUrl([
253
+ "website", websiteID, "helpdesk", "locale", locale, "article",
254
+ articleId
255
+ ])
256
+ );
257
+ };
258
+
259
+ /**
260
+ * Save Helpdesk Locale Article
261
+ * @memberof WebsiteConversation
262
+ * @public
263
+ * @method saveHelpdeskLocaleArticle
264
+ * @param {string} websiteID
265
+ * @param {string} locale
266
+ * @param {string} articleId
267
+ * @param {object} article
268
+ * @return {Promise}
269
+ */
270
+ service.saveHelpdeskLocaleArticle = function(
271
+ websiteID, locale, articleId, article
272
+ ) {
273
+ return crisp.put(
274
+ crisp._prepareRestUrl([
275
+ "website", websiteID, "helpdesk", "locale", locale, "article",
276
+ articleId
277
+ ]),
278
+
279
+ null, article
280
+ );
281
+ };
282
+
283
+ /**
284
+ * Update Helpdesk Locale Article
285
+ * @memberof WebsiteConversation
286
+ * @public
287
+ * @method updateHelpdeskLocaleArticle
288
+ * @param {string} websiteID
289
+ * @param {string} locale
290
+ * @param {string} articleId
291
+ * @param {object} article
292
+ * @return {Promise}
293
+ */
294
+ service.updateHelpdeskLocaleArticle = function(
295
+ websiteID, locale, articleId, article
296
+ ) {
297
+ return crisp.patch(
298
+ crisp._prepareRestUrl([
299
+ "website", websiteID, "helpdesk", "locale", locale, "article",
300
+ articleId
301
+ ]),
302
+
303
+ null, article
304
+ );
305
+ };
306
+
307
+ /**
308
+ * Delete Helpdesk Locale Article
309
+ * @memberof WebsiteConversation
310
+ * @public
311
+ * @method deleteHelpdeskLocaleArticle
312
+ * @param {string} websiteID
313
+ * @param {string} locale
314
+ * @param {string} articleId
315
+ * @return {Promise}
316
+ */
317
+ service.deleteHelpdeskLocaleArticle = function(websiteID, locale, articleId) {
318
+ return crisp.delete(
319
+ crisp._prepareRestUrl([
320
+ "website", websiteID, "helpdesk", "locale", locale, "article",
321
+ articleId
322
+ ])
323
+ );
324
+ };
325
+
326
+ /**
327
+ * Resolve Helpdesk Locale Article Category
328
+ * @memberof WebsiteConversation
329
+ * @public
330
+ * @method resolveHelpdeskLocaleArticleCategory
331
+ * @param {string} websiteID
332
+ * @param {string} locale
333
+ * @param {string} articleId
334
+ * @return {Promise}
335
+ */
336
+ service.resolveHelpdeskLocaleArticleCategory = function(
337
+ websiteID, locale, articleId
338
+ ) {
339
+ return crisp.get(
340
+ crisp._prepareRestUrl([
341
+ "website", websiteID, "helpdesk", "locale", locale, "article",
342
+ articleId, "category"
343
+ ])
344
+ );
345
+ };
346
+
347
+ /**
348
+ * Update Helpdesk Locale Article Category
349
+ * @memberof WebsiteConversation
350
+ * @public
351
+ * @method updateHelpdeskLocaleArticleCategory
352
+ * @param {string} websiteID
353
+ * @param {string} locale
354
+ * @param {string} articleId
355
+ * @param {string} categoryId
356
+ * @param {string} [sectionId]
357
+ * @return {Promise}
358
+ */
359
+ service.updateHelpdeskLocaleArticleCategory = function(
360
+ websiteID, locale, articleId, categoryId, sectionId
361
+ ) {
362
+ // Generate body
363
+ var _body = {
364
+ category_id : categoryId
365
+ };
366
+
367
+ if (sectionId !== undefined) {
368
+ _body.section_id = sectionId;
369
+ }
370
+
371
+ return crisp.patch(
372
+ crisp._prepareRestUrl([
373
+ "website", websiteID, "helpdesk", "locale", locale, "article",
374
+ articleId, "category"
375
+ ]),
376
+
377
+ null, _body
378
+ );
379
+ };
380
+
381
+ /**
382
+ * List Helpdesk Locale Article Alternates
383
+ * @memberof WebsiteConversation
384
+ * @public
385
+ * @method listHelpdeskLocaleArticleAlternates
386
+ * @param {string} websiteID
387
+ * @param {string} locale
388
+ * @param {string} articleId
389
+ * @return {Promise}
390
+ */
391
+ service.listHelpdeskLocaleArticleAlternates = function(
392
+ websiteID, locale, articleId
393
+ ) {
394
+ return crisp.get(
395
+ crisp._prepareRestUrl([
396
+ "website", websiteID, "helpdesk", "locale", locale, "article",
397
+ articleId, "alternates"
398
+ ])
399
+ );
400
+ };
401
+
402
+ /**
403
+ * Check If Helpdesk Locale Article Alternate Exists
404
+ * @memberof WebsiteConversation
405
+ * @public
406
+ * @method checkHelpdeskLocaleArticleAlternateExists
407
+ * @param {string} websiteID
408
+ * @param {string} locale
409
+ * @param {string} articleId
410
+ * @param {string} localeLinked
411
+ * @return {Promise}
412
+ */
413
+ service.checkHelpdeskLocaleArticleAlternateExists = function(
414
+ websiteID, locale, articleId, localeLinked
415
+ ) {
416
+ return crisp.head(
417
+ crisp._prepareRestUrl([
418
+ "website", websiteID, "helpdesk", "locale", locale, "article",
419
+ articleId, "alternate", localeLinked
420
+ ])
421
+ );
422
+ };
423
+ /**
424
+ * Resolve Helpdesk Locale Article Alternate
425
+ * @memberof WebsiteConversation
426
+ * @public
427
+ * @method resolveHelpdeskLocaleArticleAlternate
428
+ * @param {string} websiteID
429
+ * @param {string} locale
430
+ * @param {string} articleId
431
+ * @param {string} localeLinked
432
+ * @return {Promise}
433
+ */
434
+ service.resolveHelpdeskLocaleArticleAlternate = function(
435
+ websiteID, locale, articleId, localeLinked
436
+ ) {
437
+ return crisp.get(
438
+ crisp._prepareRestUrl([
439
+ "website", websiteID, "helpdesk", "locale", locale, "article",
440
+ articleId, "alternate", localeLinked
441
+ ])
442
+ );
443
+ };
444
+
445
+ /**
446
+ * Save Helpdesk Locale Article Alternate
447
+ * @memberof WebsiteConversation
448
+ * @public
449
+ * @method saveHelpdeskLocaleArticleAlternate
450
+ * @param {string} websiteID
451
+ * @param {string} locale
452
+ * @param {string} articleId
453
+ * @param {string} localeLinked
454
+ * @param {string} articleIdLinked
455
+ * @return {Promise}
456
+ */
457
+ service.saveHelpdeskLocaleArticleAlternate = function(
458
+ websiteID, locale, articleId, localeLinked, articleIdLinked
459
+ ) {
460
+ return crisp.put(
461
+ crisp._prepareRestUrl([
462
+ "website", websiteID, "helpdesk", "locale", locale, "article",
463
+ articleId, "alternate", localeLinked
464
+ ]),
465
+
466
+ null,
467
+
468
+ {
469
+ article_id : articleIdLinked
470
+ }
471
+ );
472
+ };
473
+
474
+ /**
475
+ * Delete Helpdesk Locale Article Alternate
476
+ * @memberof WebsiteConversation
477
+ * @public
478
+ * @method deleteHelpdeskLocaleArticleAlternate
479
+ * @param {string} websiteID
480
+ * @param {string} locale
481
+ * @param {string} articleId
482
+ * @param {string} localeLinked
483
+ * @return {Promise}
484
+ */
485
+ service.deleteHelpdeskLocaleArticleAlternate = function(
486
+ websiteID, locale, articleId, localeLinked
487
+ ) {
488
+ return crisp.delete(
489
+ crisp._prepareRestUrl([
490
+ "website", websiteID, "helpdesk", "locale", locale, "article",
491
+ articleId, "alternate", localeLinked
492
+ ])
493
+ );
494
+ };
495
+
496
+ /**
497
+ * Publish Helpdesk Locale Article
498
+ * @memberof WebsiteConversation
499
+ * @public
500
+ * @method publishHelpdeskLocaleArticle
501
+ * @param {string} websiteID
502
+ * @param {string} locale
503
+ * @param {string} articleId
504
+ * @return {Promise}
505
+ */
506
+ service.publishHelpdeskLocaleArticle = function(
507
+ websiteID, locale, articleId
508
+ ) {
509
+ return crisp.post(
510
+ crisp._prepareRestUrl([
511
+ "website", websiteID, "helpdesk", "locale", locale, "article",
512
+ articleId, "publish"
513
+ ])
514
+ );
515
+ };
516
+
517
+ /**
518
+ * Unpublish Helpdesk Locale Article
519
+ * @memberof WebsiteConversation
520
+ * @public
521
+ * @method unpublishHelpdeskLocaleArticle
522
+ * @param {string} websiteID
523
+ * @param {string} locale
524
+ * @param {string} articleId
525
+ * @return {Promise}
526
+ */
527
+ service.unpublishHelpdeskLocaleArticle = function(
528
+ websiteID, locale, articleId
529
+ ) {
530
+ return crisp.post(
531
+ crisp._prepareRestUrl([
532
+ "website", websiteID, "helpdesk", "locale", locale, "article",
533
+ articleId, "unpublish"
534
+ ])
535
+ );
536
+ };
537
+
538
+ /**
539
+ * List Helpdesk Locale Categories
540
+ * @memberof WebsiteConversation
541
+ * @public
542
+ * @method listHelpdeskLocaleCategories
543
+ * @param {string} websiteID
544
+ * @param {string} locale
545
+ * @param {number} pageNumber
546
+ * @return {Promise}
547
+ */
548
+ service.listHelpdeskLocaleCategories = function(
549
+ websiteID, locale, pageNumber
550
+ ) {
551
+ return crisp.get(
552
+ crisp._prepareRestUrl([
553
+ "website", websiteID, "helpdesk", "locale", locale, "categories",
554
+ pageNumber
555
+ ])
556
+ );
557
+ };
558
+
559
+ /**
560
+ * Add Helpdesk Locale Category
561
+ * @memberof WebsiteConversation
562
+ * @public
563
+ * @method addHelpdeskLocaleCategory
564
+ * @param {string} websiteID
565
+ * @param {string} locale
566
+ * @param {string} name
567
+ * @return {Promise}
568
+ */
569
+ service.addHelpdeskLocaleCategory = function(websiteID, locale, name) {
570
+ return crisp.post(
571
+ crisp._prepareRestUrl([
572
+ "website", websiteID, "helpdesk", "locale", locale, "category"
573
+ ]),
574
+
575
+ null,
576
+
577
+ {
578
+ name : name
579
+ }
580
+ );
581
+ };
582
+
583
+ /**
584
+ * Check If Helpdesk Locale Category Exists
585
+ * @memberof WebsiteConversation
586
+ * @public
587
+ * @method checkHelpdeskLocaleCategoryExists
588
+ * @param {string} websiteID
589
+ * @param {string} locale
590
+ * @param {string} categoryId
591
+ * @return {Promise}
592
+ */
593
+ service.checkHelpdeskLocaleCategoryExists = function(
594
+ websiteID, locale, categoryId
595
+ ) {
596
+ return crisp.head(
597
+ crisp._prepareRestUrl([
598
+ "website", websiteID, "helpdesk", "locale", locale, "category",
599
+ categoryId
600
+ ])
601
+ );
602
+ };
603
+
604
+ /**
605
+ * Resolve Helpdesk Locale Category
606
+ * @memberof WebsiteConversation
607
+ * @public
608
+ * @method resolveHelpdeskLocaleCategory
609
+ * @param {string} websiteID
610
+ * @param {string} locale
611
+ * @param {string} categoryId
612
+ * @return {Promise}
613
+ */
614
+ service.resolveHelpdeskLocaleCategory = function(
615
+ websiteID, locale, categoryId
616
+ ) {
617
+ return crisp.get(
618
+ crisp._prepareRestUrl([
619
+ "website", websiteID, "helpdesk", "locale", locale, "category",
620
+ categoryId
621
+ ])
622
+ );
623
+ };
624
+
625
+ /**
626
+ * Save Helpdesk Locale Category
627
+ * @memberof WebsiteConversation
628
+ * @public
629
+ * @method saveHelpdeskLocaleCategory
630
+ * @param {string} websiteID
631
+ * @param {string} locale
632
+ * @param {string} categoryId
633
+ * @param {object} category
634
+ * @return {Promise}
635
+ */
636
+ service.saveHelpdeskLocaleCategory = function(
637
+ websiteID, locale, categoryId, category
638
+ ) {
639
+ return crisp.put(
640
+ crisp._prepareRestUrl([
641
+ "website", websiteID, "helpdesk", "locale", locale, "category",
642
+ categoryId
643
+ ]),
644
+
645
+ null, category
646
+ );
647
+ };
648
+ /**
649
+ * Update Helpdesk Locale Category
650
+ * @memberof WebsiteConversation
651
+ * @public
652
+ * @method updateHelpdeskLocaleCategory
653
+ * @param {string} websiteID
654
+ * @param {string} locale
655
+ * @param {string} categoryId
656
+ * @param {object} category
657
+ * @return {Promise}
658
+ */
659
+ service.updateHelpdeskLocaleCategory = function(
660
+ websiteID, locale, categoryId, category
661
+ ) {
662
+ return crisp.patch(
663
+ crisp._prepareRestUrl([
664
+ "website", websiteID, "helpdesk", "locale", locale, "category",
665
+ categoryId
666
+ ]),
667
+
668
+ null, category
669
+ );
670
+ };
671
+
672
+ /**
673
+ * Delete Helpdesk Locale Category
674
+ * @memberof WebsiteConversation
675
+ * @public
676
+ * @method deleteHelpdeskLocaleCategory
677
+ * @param {string} websiteID
678
+ * @param {string} locale
679
+ * @param {string} categoryId
680
+ * @return {Promise}
681
+ */
682
+ service.deleteHelpdeskLocaleCategory = function(
683
+ websiteID, locale, categoryId
684
+ ) {
685
+ return crisp.delete(
686
+ crisp._prepareRestUrl([
687
+ "website", websiteID, "helpdesk", "locale", locale, "category",
688
+ categoryId
689
+ ])
690
+ );
691
+ };
692
+
693
+ /**
694
+ * List Helpdesk Locale Sections
695
+ * @memberof WebsiteConversation
696
+ * @public
697
+ * @method listHelpdeskLocaleSections
698
+ * @param {string} websiteID
699
+ * @param {string} locale
700
+ * @param {string} categoryId
701
+ * @param {number} pageNumber
702
+ * @return {Promise}
703
+ */
704
+ service.listHelpdeskLocaleSections = function(
705
+ websiteID, locale, categoryId, pageNumber
706
+ ) {
707
+ return crisp.get(
708
+ crisp._prepareRestUrl([
709
+ "website", websiteID, "helpdesk", "locale", locale, "category",
710
+ categoryId, "sections", pageNumber
711
+ ])
712
+ );
713
+ };
714
+
715
+ /**
716
+ * Add Helpdesk Locale Section
717
+ * @memberof WebsiteConversation
718
+ * @public
719
+ * @method addHelpdeskLocaleSection
720
+ * @param {string} websiteID
721
+ * @param {string} locale
722
+ * @param {string} categoryId
723
+ * @param {string} name
724
+ * @return {Promise}
725
+ */
726
+ service.addHelpdeskLocaleSection = function(
727
+ websiteID, locale, categoryId, name
728
+ ) {
729
+ return crisp.post(
730
+ crisp._prepareRestUrl([
731
+ "website", websiteID, "helpdesk", "locale", locale, "category",
732
+ categoryId, "section"
733
+ ]),
734
+
735
+ null,
736
+
737
+ {
738
+ name : name
739
+ }
740
+ );
741
+ };
742
+
743
+ /**
744
+ * Check If Helpdesk Locale Section Exists
745
+ * @memberof WebsiteConversation
746
+ * @public
747
+ * @method checkHelpdeskLocaleSectionExists
748
+ * @param {string} websiteID
749
+ * @param {string} locale
750
+ * @param {string} categoryId
751
+ * @param {string} sectionId
752
+ * @return {Promise}
753
+ */
754
+ service.checkHelpdeskLocaleSectionExists = function(
755
+ websiteID, locale, categoryId, sectionId
756
+ ) {
757
+ return crisp.head(
758
+ crisp._prepareRestUrl([
759
+ "website", websiteID, "helpdesk", "locale", locale, "category",
760
+ categoryId, "section", sectionId
761
+ ])
762
+ );
763
+ };
764
+
765
+ /**
766
+ * Resolve Helpdesk Locale Section
767
+ * @memberof WebsiteConversation
768
+ * @public
769
+ * @method resolveHelpdeskLocaleSection
770
+ * @param {string} websiteID
771
+ * @param {string} locale
772
+ * @param {string} categoryId
773
+ * @param {string} sectionId
774
+ * @return {Promise}
775
+ */
776
+ service.resolveHelpdeskLocaleSection = function(
777
+ websiteID, locale, categoryId, sectionId
778
+ ) {
779
+ return crisp.get(
780
+ crisp._prepareRestUrl([
781
+ "website", websiteID, "helpdesk", "locale", locale, "category",
782
+ categoryId, "section", sectionId
783
+ ])
784
+ );
785
+ };
786
+
787
+ /**
788
+ * Save Helpdesk Locale Section
789
+ * @memberof WebsiteConversation
790
+ * @public
791
+ * @method saveHelpdeskLocaleSection
792
+ * @param {string} websiteID
793
+ * @param {string} locale
794
+ * @param {string} categoryId
795
+ * @param {string} sectionId
796
+ * @param {object} section
797
+ * @return {Promise}
798
+ */
799
+ service.saveHelpdeskLocaleSection = function(
800
+ websiteID, locale, categoryId, sectionId, section
801
+ ) {
802
+ return crisp.put(
803
+ crisp._prepareRestUrl([
804
+ "website", websiteID, "helpdesk", "locale", locale, "category",
805
+ categoryId, "section", sectionId
806
+ ]),
807
+
808
+ null, section
809
+ );
810
+ };
811
+
812
+ /**
813
+ * Update Helpdesk Locale Section
814
+ * @memberof WebsiteConversation
815
+ * @public
816
+ * @method updateHelpdeskLocaleSection
817
+ * @param {string} websiteID
818
+ * @param {string} locale
819
+ * @param {string} categoryId
820
+ * @param {string} sectionId
821
+ * @param {object} section
822
+ * @return {Promise}
823
+ */
824
+ service.updateHelpdeskLocaleSection = function(
825
+ websiteID, locale, categoryId, sectionId, section
826
+ ) {
827
+ return crisp.patch(
828
+ crisp._prepareRestUrl([
829
+ "website", websiteID, "helpdesk", "locale", locale, "category",
830
+ categoryId, "section", sectionId
831
+ ]),
832
+
833
+ null, section
834
+ );
835
+ };
836
+
837
+ /**
838
+ * Delete Helpdesk Locale Section
839
+ * @memberof WebsiteConversation
840
+ * @public
841
+ * @method deleteHelpdeskLocaleSection
842
+ * @param {string} websiteID
843
+ * @param {string} locale
844
+ * @param {string} categoryId
845
+ * @param {string} sectionId
846
+ * @return {Promise}
847
+ */
848
+ service.deleteHelpdeskLocaleSection = function(
849
+ websiteID, locale, categoryId, sectionId
850
+ ) {
851
+ return crisp.delete(
852
+ crisp._prepareRestUrl([
853
+ "website", websiteID, "helpdesk", "locale", locale, "category",
854
+ categoryId, "section", sectionId
855
+ ])
856
+ );
857
+ };
858
+
859
+ /**
860
+ * Map Helpdesk Locale Feedback Ratings
861
+ * @memberof WebsiteConversation
862
+ * @public
863
+ * @method mapHelpdeskLocaleFeedbackRatings
864
+ * @param {string} websiteID
865
+ * @param {string} locale
866
+ * @param {string} [filterDateStart]
867
+ * @param {string} [filterDateEnd]
868
+ * @return {Promise}
869
+ */
870
+ service.mapHelpdeskLocaleFeedbackRatings = function(
871
+ websiteID, locale, filterDateStart, filterDateEnd
872
+ ) {
873
+ filterDateStart = (filterDateStart || null);
874
+ filterDateEnd = (filterDateEnd || null);
875
+
876
+ // Generate query
877
+ var _query = {};
878
+
879
+ if (filterDateStart !== null) {
880
+ _query.filter_date_start = filterDateStart;
881
+ }
882
+ if (filterDateEnd !== null) {
883
+ _query.filter_date_end = filterDateEnd;
884
+ }
885
+
886
+ return crisp.get(
887
+ crisp._prepareRestUrl([
888
+ "website", websiteID, "helpdesk", "locale", locale, "feedback",
889
+ "ratings"
890
+ ]),
891
+
892
+ _query
893
+ );
894
+ };
895
+ /**
896
+ * List Helpdesk Locale Feedbacks
897
+ * @memberof WebsiteConversation
898
+ * @public
899
+ * @method listHelpdeskLocaleFeedbacks
900
+ * @param {string} websiteID
901
+ * @param {string} locale
902
+ * @param {number} pageNumber
903
+ * @param {string} [filterDateStart]
904
+ * @param {string} [filterDateEnd]
905
+ * @return {Promise}
906
+ */
907
+ service.listHelpdeskLocaleFeedbacks = function(
908
+ websiteID, locale, pageNumber, filterDateStart, filterDateEnd
909
+ ) {
910
+ filterDateStart = (filterDateStart || null);
911
+ filterDateEnd = (filterDateEnd || null);
912
+
913
+ // Generate query
914
+ var _query = {};
915
+
916
+ if (filterDateStart !== null) {
917
+ _query.filter_date_start = filterDateStart;
918
+ }
919
+ if (filterDateEnd !== null) {
920
+ _query.filter_date_end = filterDateEnd;
921
+ }
922
+
923
+ return crisp.get(
924
+ crisp._prepareRestUrl([
925
+ "website", websiteID, "helpdesk", "locale", locale, "feedback", "list",
926
+ pageNumber
927
+ ]),
928
+
929
+ _query
930
+ );
931
+ };
932
+
933
+ /**
934
+ * Import External Helpdesk To Locale
935
+ * @memberof WebsiteConversation
936
+ * @public
937
+ * @method importExternalHelpdeskToLocale
938
+ * @param {string} websiteID
939
+ * @param {string} locale
940
+ * @param {string} helpdeskUrl
941
+ * @return {Promise}
942
+ */
943
+ service.importExternalHelpdeskToLocale = function(
944
+ websiteID, locale, helpdeskUrl
945
+ ) {
946
+ return crisp.post(
947
+ crisp._prepareRestUrl([
948
+ "website", websiteID, "helpdesk", "locale", locale, "import"
949
+ ]),
950
+
951
+ null,
952
+
953
+ {
954
+ helpdesk_url : helpdeskUrl
955
+ }
956
+ );
957
+ };
958
+
959
+ /**
960
+ * Export Helpdesk Locale Articles
961
+ * @memberof WebsiteConversation
962
+ * @public
963
+ * @method exportHelpdeskLocaleArticles
964
+ * @param {string} websiteID
965
+ * @param {string} locale
966
+ * @return {Promise}
967
+ */
968
+ service.exportHelpdeskLocaleArticles = function(websiteID, locale) {
969
+ return crisp.post(
970
+ crisp._prepareRestUrl([
971
+ "website", websiteID, "helpdesk", "locale", locale, "export"
972
+ ])
973
+ );
974
+ };
975
+
976
+ /**
977
+ * List Helpdesk Redirections
978
+ * @memberof WebsiteConversation
979
+ * @public
980
+ * @method listHelpdeskRedirections
981
+ * @param {string} websiteID
982
+ * @param {number} pageNumber
983
+ * @return {Promise}
984
+ */
985
+ service.listHelpdeskRedirections = function(websiteID, pageNumber) {
986
+ return crisp.get(
987
+ crisp._prepareRestUrl([
988
+ "website", websiteID, "helpdesk", "redirections", pageNumber
989
+ ])
990
+ );
991
+ };
992
+
993
+ /**
994
+ * Add Helpdesk Redirection
995
+ * @memberof WebsiteConversation
996
+ * @public
997
+ * @method addHelpdeskRedirection
998
+ * @param {string} websiteID
999
+ * @param {string} redirectionPath
1000
+ * @param {string} redirectionTarget
1001
+ * @return {Promise}
1002
+ */
1003
+ service.addHelpdeskRedirection = function(
1004
+ websiteID, redirectionPath, redirectionTarget
1005
+ ) {
1006
+ return crisp.post(
1007
+ crisp._prepareRestUrl(["website", websiteID, "helpdesk", "redirection"]),
1008
+
1009
+ null,
1010
+
1011
+ {
1012
+ path : redirectionPath,
1013
+ target : redirectionTarget
1014
+ }
1015
+ );
1016
+ };
1017
+
1018
+ /**
1019
+ * Check If Helpdesk Redirection Exists
1020
+ * @memberof WebsiteConversation
1021
+ * @public
1022
+ * @method checkHelpdeskRedirectionExists
1023
+ * @param {string} websiteID
1024
+ * @param {string} redirectionId
1025
+ * @return {Promise}
1026
+ */
1027
+ service.checkHelpdeskRedirectionExists = function(websiteID, redirectionId) {
1028
+ return crisp.head(
1029
+ crisp._prepareRestUrl([
1030
+ "website", websiteID, "helpdesk", "redirection", redirectionId
1031
+ ])
1032
+ );
1033
+ };
1034
+
1035
+ /**
1036
+ * Resolve Helpdesk Redirection
1037
+ * @memberof WebsiteConversation
1038
+ * @public
1039
+ * @method resolveHelpdeskRedirection
1040
+ * @param {string} websiteID
1041
+ * @param {string} redirectionId
1042
+ * @return {Promise}
1043
+ */
1044
+ service.resolveHelpdeskRedirection = function(websiteID, redirectionId) {
1045
+ return crisp.get(
1046
+ crisp._prepareRestUrl([
1047
+ "website", websiteID, "helpdesk", "redirection", redirectionId
1048
+ ])
1049
+ );
1050
+ };
1051
+
1052
+ /**
1053
+ * Delete Helpdesk Redirection
1054
+ * @memberof WebsiteConversation
1055
+ * @public
1056
+ * @method deleteHelpdeskRedirection
1057
+ * @param {string} websiteID
1058
+ * @param {string} redirectionId
1059
+ * @return {Promise}
1060
+ */
1061
+ service.deleteHelpdeskRedirection = function(websiteID, redirectionId) {
1062
+ return crisp.delete(
1063
+ crisp._prepareRestUrl([
1064
+ "website", websiteID, "helpdesk", "redirection", redirectionId
1065
+ ])
1066
+ );
1067
+ };
1068
+
1069
+ /**
1070
+ * Resolve Helpdesk Settings
1071
+ * @memberof WebsiteConversation
1072
+ * @public
1073
+ * @method resolveHelpdeskSettings
1074
+ * @param {string} websiteID
1075
+ * @return {Promise}
1076
+ */
1077
+ service.resolveHelpdeskSettings = function(websiteID) {
1078
+ return crisp.get(
1079
+ crisp._prepareRestUrl(["website", websiteID, "helpdesk", "settings"])
1080
+ );
1081
+ };
1082
+
1083
+ /**
1084
+ * Save Helpdesk Settings
1085
+ * @memberof WebsiteConversation
1086
+ * @public
1087
+ * @method saveHelpdeskSettings
1088
+ * @param {string} websiteID
1089
+ * @param {object} settings
1090
+ * @return {Promise}
1091
+ */
1092
+ service.saveHelpdeskSettings = function(websiteID, settings) {
1093
+ return crisp.patch(
1094
+ crisp._prepareRestUrl(["website", websiteID, "helpdesk", "settings"]),
1095
+
1096
+ null, settings
1097
+ );
1098
+ };
1099
+
1100
+ /**
1101
+ * Resolve Helpdesk Domain
1102
+ * @memberof WebsiteConversation
1103
+ * @public
1104
+ * @method resolveHelpdeskDomain
1105
+ * @param {string} websiteID
1106
+ * @return {Promise}
1107
+ */
1108
+ service.resolveHelpdeskDomain = function(websiteID) {
1109
+ return crisp.get(
1110
+ crisp._prepareRestUrl(["website", websiteID, "helpdesk", "domain"])
1111
+ );
1112
+ };
1113
+
1114
+ /**
1115
+ * Request Helpdesk Domain Change
1116
+ * @memberof WebsiteConversation
1117
+ * @public
1118
+ * @method requestHelpdeskDomainChange
1119
+ * @param {string} websiteID
1120
+ * @param {string} basic
1121
+ * @param {string} custom
1122
+ * @return {Promise}
1123
+ */
1124
+ service.requestHelpdeskDomainChange = function(websiteID, basic, custom) {
1125
+ // Generate body
1126
+ var _body = {};
1127
+
1128
+ if (basic !== undefined) {
1129
+ _body.basic = basic;
1130
+ }
1131
+ if (custom !== undefined) {
1132
+ _body.custom = custom;
1133
+ }
1134
+
1135
+ return crisp.patch(
1136
+ crisp._prepareRestUrl(["website", websiteID, "helpdesk", "domain"]),
1137
+
1138
+ null, _body
1139
+ );
1140
+ };
1141
+
1142
+ /**
1143
+ * Generate Helpdesk Domain Setup Flow
1144
+ * @memberof WebsiteConversation
1145
+ * @public
1146
+ * @method generateHelpdeskDomainSetupFlow
1147
+ * @param {string} websiteID
1148
+ * @param {string} [custom]
1149
+ * @return {Promise}
1150
+ */
1151
+ service.generateHelpdeskDomainSetupFlow = function(websiteID, custom) {
1152
+ custom = (custom || null);
1153
+
1154
+ // Generate query
1155
+ var _query = {};
1156
+
1157
+ if (custom !== null) {
1158
+ _query.custom = custom;
1159
+ }
1160
+
1161
+ return crisp.get(
1162
+ crisp._prepareRestUrl([
1163
+ "website", websiteID, "helpdesk", "domain", "setup"
1164
+ ]),
1165
+
1166
+ _query
1167
+ );
1168
+ };
1169
+ }
1170
+
1171
+
1172
+ module.exports = WebsiteHelpdesk;