crisp-api 7.4.2 → 8.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.
@@ -0,0 +1,1165 @@
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
+ * @return {Promise}
567
+ */
568
+ service.addHelpdeskLocaleCategory = function(websiteID, locale) {
569
+ return crisp.post(
570
+ crisp._prepareRestUrl([
571
+ "website", websiteID, "helpdesk", "locale", locale, "category"
572
+ ])
573
+ );
574
+ };
575
+
576
+ /**
577
+ * Check If Helpdesk Locale Category Exists
578
+ * @memberof WebsiteConversation
579
+ * @public
580
+ * @method checkHelpdeskLocaleCategoryExists
581
+ * @param {string} websiteID
582
+ * @param {string} locale
583
+ * @param {string} categoryId
584
+ * @return {Promise}
585
+ */
586
+ service.checkHelpdeskLocaleCategoryExists = function(
587
+ websiteID, locale, categoryId
588
+ ) {
589
+ return crisp.head(
590
+ crisp._prepareRestUrl([
591
+ "website", websiteID, "helpdesk", "locale", locale, "category",
592
+ categoryId
593
+ ])
594
+ );
595
+ };
596
+
597
+ /**
598
+ * Resolve Helpdesk Locale Category
599
+ * @memberof WebsiteConversation
600
+ * @public
601
+ * @method resolveHelpdeskLocaleCategory
602
+ * @param {string} websiteID
603
+ * @param {string} locale
604
+ * @param {string} categoryId
605
+ * @return {Promise}
606
+ */
607
+ service.resolveHelpdeskLocaleCategory = function(
608
+ websiteID, locale, categoryId
609
+ ) {
610
+ return crisp.get(
611
+ crisp._prepareRestUrl([
612
+ "website", websiteID, "helpdesk", "locale", locale, "category",
613
+ categoryId
614
+ ])
615
+ );
616
+ };
617
+
618
+ /**
619
+ * Save Helpdesk Locale Category
620
+ * @memberof WebsiteConversation
621
+ * @public
622
+ * @method saveHelpdeskLocaleCategory
623
+ * @param {string} websiteID
624
+ * @param {string} locale
625
+ * @param {string} categoryId
626
+ * @param {object} category
627
+ * @return {Promise}
628
+ */
629
+ service.saveHelpdeskLocaleCategory = function(
630
+ websiteID, locale, categoryId, category
631
+ ) {
632
+ return crisp.put(
633
+ crisp._prepareRestUrl([
634
+ "website", websiteID, "helpdesk", "locale", locale, "category",
635
+ categoryId
636
+ ]),
637
+
638
+ null, category
639
+ );
640
+ };
641
+ /**
642
+ * Update Helpdesk Locale Category
643
+ * @memberof WebsiteConversation
644
+ * @public
645
+ * @method updateHelpdeskLocaleCategory
646
+ * @param {string} websiteID
647
+ * @param {string} locale
648
+ * @param {string} categoryId
649
+ * @param {object} category
650
+ * @return {Promise}
651
+ */
652
+ service.updateHelpdeskLocaleCategory = function(
653
+ websiteID, locale, categoryId, category
654
+ ) {
655
+ return crisp.patch(
656
+ crisp._prepareRestUrl([
657
+ "website", websiteID, "helpdesk", "locale", locale, "category",
658
+ categoryId
659
+ ]),
660
+
661
+ null, category
662
+ );
663
+ };
664
+
665
+ /**
666
+ * Delete Helpdesk Locale Category
667
+ * @memberof WebsiteConversation
668
+ * @public
669
+ * @method deleteHelpdeskLocaleCategory
670
+ * @param {string} websiteID
671
+ * @param {string} locale
672
+ * @param {string} categoryId
673
+ * @return {Promise}
674
+ */
675
+ service.deleteHelpdeskLocaleCategory = function(
676
+ websiteID, locale, categoryId
677
+ ) {
678
+ return crisp.delete(
679
+ crisp._prepareRestUrl([
680
+ "website", websiteID, "helpdesk", "locale", locale, "category",
681
+ categoryId
682
+ ])
683
+ );
684
+ };
685
+
686
+ /**
687
+ * List Helpdesk Locale Sections
688
+ * @memberof WebsiteConversation
689
+ * @public
690
+ * @method listHelpdeskLocaleSections
691
+ * @param {string} websiteID
692
+ * @param {string} locale
693
+ * @param {string} categoryId
694
+ * @param {number} pageNumber
695
+ * @return {Promise}
696
+ */
697
+ service.listHelpdeskLocaleSections = function(
698
+ websiteID, locale, categoryId, pageNumber
699
+ ) {
700
+ return crisp.get(
701
+ crisp._prepareRestUrl([
702
+ "website", websiteID, "helpdesk", "locale", locale, "category",
703
+ categoryId, "sections", pageNumber
704
+ ])
705
+ );
706
+ };
707
+
708
+ /**
709
+ * Add Helpdesk Locale Section
710
+ * @memberof WebsiteConversation
711
+ * @public
712
+ * @method addHelpdeskLocaleSection
713
+ * @param {string} websiteID
714
+ * @param {string} locale
715
+ * @param {string} categoryId
716
+ * @param {string} name
717
+ * @return {Promise}
718
+ */
719
+ service.addHelpdeskLocaleSection = function(
720
+ websiteID, locale, categoryId, name
721
+ ) {
722
+ return crisp.post(
723
+ crisp._prepareRestUrl([
724
+ "website", websiteID, "helpdesk", "locale", locale, "category",
725
+ categoryId, "section"
726
+ ]),
727
+
728
+ null,
729
+
730
+ {
731
+ name : name
732
+ }
733
+ );
734
+ };
735
+
736
+ /**
737
+ * Check If Helpdesk Locale Section Exists
738
+ * @memberof WebsiteConversation
739
+ * @public
740
+ * @method checkHelpdeskLocaleSectionExists
741
+ * @param {string} websiteID
742
+ * @param {string} locale
743
+ * @param {string} categoryId
744
+ * @param {string} sectionId
745
+ * @return {Promise}
746
+ */
747
+ service.checkHelpdeskLocaleSectionExists = function(
748
+ websiteID, locale, categoryId, sectionId
749
+ ) {
750
+ return crisp.head(
751
+ crisp._prepareRestUrl([
752
+ "website", websiteID, "helpdesk", "locale", locale, "category",
753
+ categoryId, "section", sectionId
754
+ ])
755
+ );
756
+ };
757
+
758
+ /**
759
+ * Resolve Helpdesk Locale Section
760
+ * @memberof WebsiteConversation
761
+ * @public
762
+ * @method resolveHelpdeskLocaleSection
763
+ * @param {string} websiteID
764
+ * @param {string} locale
765
+ * @param {string} categoryId
766
+ * @param {string} sectionId
767
+ * @return {Promise}
768
+ */
769
+ service.resolveHelpdeskLocaleSection = function(
770
+ websiteID, locale, categoryId, sectionId
771
+ ) {
772
+ return crisp.get(
773
+ crisp._prepareRestUrl([
774
+ "website", websiteID, "helpdesk", "locale", locale, "category",
775
+ categoryId, "section", sectionId
776
+ ])
777
+ );
778
+ };
779
+
780
+ /**
781
+ * Save Helpdesk Locale Section
782
+ * @memberof WebsiteConversation
783
+ * @public
784
+ * @method saveHelpdeskLocaleSection
785
+ * @param {string} websiteID
786
+ * @param {string} locale
787
+ * @param {string} categoryId
788
+ * @param {string} sectionId
789
+ * @param {object} section
790
+ * @return {Promise}
791
+ */
792
+ service.saveHelpdeskLocaleSection = function(
793
+ websiteID, locale, categoryId, sectionId, section
794
+ ) {
795
+ return crisp.put(
796
+ crisp._prepareRestUrl([
797
+ "website", websiteID, "helpdesk", "locale", locale, "category",
798
+ categoryId, "section", sectionId
799
+ ]),
800
+
801
+ null, section
802
+ );
803
+ };
804
+
805
+ /**
806
+ * Update Helpdesk Locale Section
807
+ * @memberof WebsiteConversation
808
+ * @public
809
+ * @method updateHelpdeskLocaleSection
810
+ * @param {string} websiteID
811
+ * @param {string} locale
812
+ * @param {string} categoryId
813
+ * @param {string} sectionId
814
+ * @param {object} section
815
+ * @return {Promise}
816
+ */
817
+ service.updateHelpdeskLocaleSection = function(
818
+ websiteID, locale, categoryId, sectionId, section
819
+ ) {
820
+ return crisp.patch(
821
+ crisp._prepareRestUrl([
822
+ "website", websiteID, "helpdesk", "locale", locale, "category",
823
+ categoryId, "section", sectionId
824
+ ]),
825
+
826
+ null, section
827
+ );
828
+ };
829
+
830
+ /**
831
+ * Delete Helpdesk Locale Section
832
+ * @memberof WebsiteConversation
833
+ * @public
834
+ * @method deleteHelpdeskLocaleSection
835
+ * @param {string} websiteID
836
+ * @param {string} locale
837
+ * @param {string} categoryId
838
+ * @param {string} sectionId
839
+ * @return {Promise}
840
+ */
841
+ service.deleteHelpdeskLocaleSection = function(
842
+ websiteID, locale, categoryId, sectionId
843
+ ) {
844
+ return crisp.delete(
845
+ crisp._prepareRestUrl([
846
+ "website", websiteID, "helpdesk", "locale", locale, "category",
847
+ categoryId, "section", sectionId
848
+ ])
849
+ );
850
+ };
851
+
852
+ /**
853
+ * Map Helpdesk Locale Feedback Ratings
854
+ * @memberof WebsiteConversation
855
+ * @public
856
+ * @method mapHelpdeskLocaleFeedbackRatings
857
+ * @param {string} websiteID
858
+ * @param {string} locale
859
+ * @param {string} [filterDateStart]
860
+ * @param {string} [filterDateEnd]
861
+ * @return {Promise}
862
+ */
863
+ service.mapHelpdeskLocaleFeedbackRatings = function(
864
+ websiteID, locale, filterDateStart, filterDateEnd
865
+ ) {
866
+ filterDateStart = (filterDateStart || null);
867
+ filterDateEnd = (filterDateEnd || null);
868
+
869
+ // Generate query
870
+ var _query = {};
871
+
872
+ if (filterDateStart !== null) {
873
+ _query.filter_date_start = filterDateStart;
874
+ }
875
+ if (filterDateEnd !== null) {
876
+ _query.filter_date_end = filterDateEnd;
877
+ }
878
+
879
+ return crisp.get(
880
+ crisp._prepareRestUrl([
881
+ "website", websiteID, "helpdesk", "locale", locale, "feedback",
882
+ "ratings"
883
+ ]),
884
+
885
+ _query
886
+ );
887
+ };
888
+ /**
889
+ * List Helpdesk Locale Feedbacks
890
+ * @memberof WebsiteConversation
891
+ * @public
892
+ * @method listHelpdeskLocaleFeedbacks
893
+ * @param {string} websiteID
894
+ * @param {string} locale
895
+ * @param {number} pageNumber
896
+ * @param {string} [filterDateStart]
897
+ * @param {string} [filterDateEnd]
898
+ * @return {Promise}
899
+ */
900
+ service.listHelpdeskLocaleFeedbacks = function(
901
+ websiteID, locale, pageNumber, filterDateStart, filterDateEnd
902
+ ) {
903
+ filterDateStart = (filterDateStart || null);
904
+ filterDateEnd = (filterDateEnd || null);
905
+
906
+ // Generate query
907
+ var _query = {};
908
+
909
+ if (filterDateStart !== null) {
910
+ _query.filter_date_start = filterDateStart;
911
+ }
912
+ if (filterDateEnd !== null) {
913
+ _query.filter_date_end = filterDateEnd;
914
+ }
915
+
916
+ return crisp.get(
917
+ crisp._prepareRestUrl([
918
+ "website", websiteID, "helpdesk", "locale", locale, "feedback", "list",
919
+ pageNumber
920
+ ]),
921
+
922
+ _query
923
+ );
924
+ };
925
+
926
+ /**
927
+ * Import External Helpdesk To Locale
928
+ * @memberof WebsiteConversation
929
+ * @public
930
+ * @method importExternalHelpdeskToLocale
931
+ * @param {string} websiteID
932
+ * @param {string} locale
933
+ * @param {string} helpdeskUrl
934
+ * @return {Promise}
935
+ */
936
+ service.importExternalHelpdeskToLocale = function(
937
+ websiteID, locale, helpdeskUrl
938
+ ) {
939
+ return crisp.post(
940
+ crisp._prepareRestUrl([
941
+ "website", websiteID, "helpdesk", "locale", locale, "import"
942
+ ]),
943
+
944
+ null,
945
+
946
+ {
947
+ helpdesk_url : helpdeskUrl
948
+ }
949
+ );
950
+ };
951
+
952
+ /**
953
+ * Export Helpdesk Locale Articles
954
+ * @memberof WebsiteConversation
955
+ * @public
956
+ * @method exportHelpdeskLocaleArticles
957
+ * @param {string} websiteID
958
+ * @param {string} locale
959
+ * @return {Promise}
960
+ */
961
+ service.exportHelpdeskLocaleArticles = function(websiteID, locale) {
962
+ return crisp.post(
963
+ crisp._prepareRestUrl([
964
+ "website", websiteID, "helpdesk", "locale", locale, "export"
965
+ ])
966
+ );
967
+ };
968
+
969
+ /**
970
+ * List Helpdesk Redirections
971
+ * @memberof WebsiteConversation
972
+ * @public
973
+ * @method listHelpdeskRedirections
974
+ * @param {string} websiteID
975
+ * @param {number} pageNumber
976
+ * @return {Promise}
977
+ */
978
+ service.listHelpdeskRedirections = function(websiteID, pageNumber) {
979
+ return crisp.get(
980
+ crisp._prepareRestUrl([
981
+ "website", websiteID, "helpdesk", "redirections", pageNumber
982
+ ])
983
+ );
984
+ };
985
+
986
+ /**
987
+ * Add Helpdesk Redirection
988
+ * @memberof WebsiteConversation
989
+ * @public
990
+ * @method addHelpdeskRedirection
991
+ * @param {string} websiteID
992
+ * @param {string} redirectionPath
993
+ * @param {string} redirectionTarget
994
+ * @return {Promise}
995
+ */
996
+ service.addHelpdeskRedirection = function(
997
+ websiteID, redirectionPath, redirectionTarget
998
+ ) {
999
+ return crisp.post(
1000
+ crisp._prepareRestUrl(["website", websiteID, "helpdesk", "redirection"]),
1001
+
1002
+ null,
1003
+
1004
+ {
1005
+ path : redirectionPath,
1006
+ target : redirectionTarget
1007
+ }
1008
+ );
1009
+ };
1010
+
1011
+ /**
1012
+ * Check If Helpdesk Redirection Exists
1013
+ * @memberof WebsiteConversation
1014
+ * @public
1015
+ * @method checkHelpdeskRedirectionExists
1016
+ * @param {string} websiteID
1017
+ * @param {string} redirectionId
1018
+ * @return {Promise}
1019
+ */
1020
+ service.checkHelpdeskRedirectionExists = function(websiteID, redirectionId) {
1021
+ return crisp.head(
1022
+ crisp._prepareRestUrl([
1023
+ "website", websiteID, "helpdesk", "redirection", redirectionId
1024
+ ])
1025
+ );
1026
+ };
1027
+
1028
+ /**
1029
+ * Resolve Helpdesk Redirection
1030
+ * @memberof WebsiteConversation
1031
+ * @public
1032
+ * @method resolveHelpdeskRedirection
1033
+ * @param {string} websiteID
1034
+ * @param {string} redirectionId
1035
+ * @return {Promise}
1036
+ */
1037
+ service.resolveHelpdeskRedirection = function(websiteID, redirectionId) {
1038
+ return crisp.get(
1039
+ crisp._prepareRestUrl([
1040
+ "website", websiteID, "helpdesk", "redirection", redirectionId
1041
+ ])
1042
+ );
1043
+ };
1044
+
1045
+ /**
1046
+ * Delete Helpdesk Redirection
1047
+ * @memberof WebsiteConversation
1048
+ * @public
1049
+ * @method deleteHelpdeskRedirection
1050
+ * @param {string} websiteID
1051
+ * @param {string} redirectionId
1052
+ * @return {Promise}
1053
+ */
1054
+ service.deleteHelpdeskRedirection = function(websiteID, redirectionId) {
1055
+ return crisp.delete(
1056
+ crisp._prepareRestUrl([
1057
+ "website", websiteID, "helpdesk", "redirection", redirectionId
1058
+ ])
1059
+ );
1060
+ };
1061
+
1062
+ /**
1063
+ * Resolve Helpdesk Settings
1064
+ * @memberof WebsiteConversation
1065
+ * @public
1066
+ * @method resolveHelpdeskSettings
1067
+ * @param {string} websiteID
1068
+ * @return {Promise}
1069
+ */
1070
+ service.resolveHelpdeskSettings = function(websiteID) {
1071
+ return crisp.get(
1072
+ crisp._prepareRestUrl(["website", websiteID, "helpdesk", "settings"])
1073
+ );
1074
+ };
1075
+
1076
+ /**
1077
+ * Save Helpdesk Settings
1078
+ * @memberof WebsiteConversation
1079
+ * @public
1080
+ * @method saveHelpdeskSettings
1081
+ * @param {string} websiteID
1082
+ * @param {object} settings
1083
+ * @return {Promise}
1084
+ */
1085
+ service.saveHelpdeskSettings = function(websiteID, settings) {
1086
+ return crisp.patch(
1087
+ crisp._prepareRestUrl(["website", websiteID, "helpdesk", "settings"]),
1088
+
1089
+ null, settings
1090
+ );
1091
+ };
1092
+
1093
+ /**
1094
+ * Resolve Helpdesk Domain
1095
+ * @memberof WebsiteConversation
1096
+ * @public
1097
+ * @method resolveHelpdeskDomain
1098
+ * @param {string} websiteID
1099
+ * @return {Promise}
1100
+ */
1101
+ service.resolveHelpdeskDomain = function(websiteID) {
1102
+ return crisp.get(
1103
+ crisp._prepareRestUrl(["website", websiteID, "helpdesk", "domain"])
1104
+ );
1105
+ };
1106
+
1107
+ /**
1108
+ * Request Helpdesk Domain Change
1109
+ * @memberof WebsiteConversation
1110
+ * @public
1111
+ * @method requestHelpdeskDomainChange
1112
+ * @param {string} websiteID
1113
+ * @param {string} basic
1114
+ * @param {string} custom
1115
+ * @return {Promise}
1116
+ */
1117
+ service.requestHelpdeskDomainChange = function(websiteID, basic, custom) {
1118
+ // Generate body
1119
+ var _body = {};
1120
+
1121
+ if (basic !== undefined) {
1122
+ _body.basic = basic;
1123
+ }
1124
+ if (custom !== undefined) {
1125
+ _body.custom = custom;
1126
+ }
1127
+
1128
+ return crisp.patch(
1129
+ crisp._prepareRestUrl(["website", websiteID, "helpdesk", "domain"]),
1130
+
1131
+ null, _body
1132
+ );
1133
+ };
1134
+
1135
+ /**
1136
+ * Generate Helpdesk Domain Setup Flow
1137
+ * @memberof WebsiteConversation
1138
+ * @public
1139
+ * @method generateHelpdeskDomainSetupFlow
1140
+ * @param {string} websiteID
1141
+ * @param {string} [custom]
1142
+ * @return {Promise}
1143
+ */
1144
+ service.generateHelpdeskDomainSetupFlow = function(websiteID, custom) {
1145
+ custom = (custom || null);
1146
+
1147
+ // Generate query
1148
+ var _query = {};
1149
+
1150
+ if (custom !== null) {
1151
+ _query.custom = custom;
1152
+ }
1153
+
1154
+ return crisp.get(
1155
+ crisp._prepareRestUrl([
1156
+ "website", websiteID, "helpdesk", "domain", "setup"
1157
+ ]),
1158
+
1159
+ _query
1160
+ );
1161
+ };
1162
+ }
1163
+
1164
+
1165
+ module.exports = WebsiteHelpdesk;