@gyldendalas/gyldendal-divine-api 0.3.0 → 0.3.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.
package/dist/index.js CHANGED
@@ -53,7 +53,14 @@ var BaseService = class {
53
53
  timeout
54
54
  }) {
55
55
  const method = "GET";
56
- return await this.callAsync({ url, body: null, method, headers, addAuthHeaders, timeout });
56
+ return await this.callAsync({
57
+ url,
58
+ body: null,
59
+ method,
60
+ headers,
61
+ addAuthHeaders,
62
+ timeout
63
+ });
57
64
  }
58
65
  async putAsync({
59
66
  url,
@@ -63,7 +70,14 @@ var BaseService = class {
63
70
  timeout
64
71
  }) {
65
72
  const method = "PUT";
66
- return await this.callAsync({ url, body, method, headers, addAuthHeaders, timeout });
73
+ return await this.callAsync({
74
+ url,
75
+ body,
76
+ method,
77
+ headers,
78
+ addAuthHeaders,
79
+ timeout
80
+ });
67
81
  }
68
82
  async postAsync({
69
83
  url,
@@ -73,7 +87,14 @@ var BaseService = class {
73
87
  timeout
74
88
  }) {
75
89
  const method = "POST";
76
- return await this.callAsync({ url, body, method, headers, addAuthHeaders, timeout });
90
+ return await this.callAsync({
91
+ url,
92
+ body,
93
+ method,
94
+ headers,
95
+ addAuthHeaders,
96
+ timeout
97
+ });
77
98
  }
78
99
  async deleteAsync({
79
100
  url,
@@ -82,7 +103,14 @@ var BaseService = class {
82
103
  timeout
83
104
  }) {
84
105
  const method = "DELETE";
85
- return await this.callAsync({ url, body: null, method, headers, addAuthHeaders, timeout });
106
+ return await this.callAsync({
107
+ url,
108
+ body: null,
109
+ method,
110
+ headers,
111
+ addAuthHeaders,
112
+ timeout
113
+ });
86
114
  }
87
115
  async patchAsync({
88
116
  url,
@@ -92,7 +120,14 @@ var BaseService = class {
92
120
  timeout
93
121
  }) {
94
122
  const method = "PATCH";
95
- return await this.callAsync({ url, body, method, headers, addAuthHeaders, timeout });
123
+ return await this.callAsync({
124
+ url,
125
+ body,
126
+ method,
127
+ headers,
128
+ addAuthHeaders,
129
+ timeout
130
+ });
96
131
  }
97
132
  async callAsync({
98
133
  url,
@@ -115,7 +150,10 @@ var BaseService = class {
115
150
  signal: AbortSignal.timeout(timeout)
116
151
  });
117
152
  if (!response.ok) {
118
- throw new HTTPError(`Got ${response.status} while calling ${response.url}`, response);
153
+ throw new HTTPError(
154
+ `Got ${response.status} while calling ${response.url}`,
155
+ response
156
+ );
119
157
  }
120
158
  return response;
121
159
  }
@@ -169,7 +207,12 @@ var TaggingService = class extends base_service_default {
169
207
  const url = `${this.getUrlPrefix()}/tags`;
170
208
  const headers = new Headers();
171
209
  headers.append("Content-Type", "application/json");
172
- const response = await this.postAsync({ url, headers, body: JSON.stringify(tag), timeout });
210
+ const response = await this.postAsync({
211
+ url,
212
+ headers,
213
+ body: JSON.stringify(tag),
214
+ timeout
215
+ });
173
216
  return await response.json();
174
217
  }
175
218
  async updateTag({
@@ -179,7 +222,12 @@ var TaggingService = class extends base_service_default {
179
222
  const url = `${this.getUrlPrefix()}/tags`;
180
223
  const headers = new Headers();
181
224
  headers.append("Content-Type", "application/json");
182
- const response = await this.putAsync({ url, headers, body: JSON.stringify(tag), timeout });
225
+ const response = await this.putAsync({
226
+ url,
227
+ headers,
228
+ body: JSON.stringify(tag),
229
+ timeout
230
+ });
183
231
  return await response.json();
184
232
  }
185
233
  async deleteTag({
@@ -229,7 +277,12 @@ var PollyService = class extends base_service_default {
229
277
  const url = `${this.getUrlPrefix()}/synthesizeSpeech`;
230
278
  const headers = new Headers();
231
279
  headers.append("Content-Type", "application/json");
232
- const response = await this.postAsync({ url, headers, body: JSON.stringify(body), timeout });
280
+ const response = await this.postAsync({
281
+ url,
282
+ headers,
283
+ body: JSON.stringify(body),
284
+ timeout
285
+ });
233
286
  return response.json();
234
287
  }
235
288
  };
@@ -257,7 +310,13 @@ var CookieConsentLog = class extends base_service_default {
257
310
  const url = `${this.getUrlPrefix()}/log`;
258
311
  const headers = new Headers();
259
312
  headers.append("Content-Type", "application/json");
260
- const response = await this.postAsync({ url, headers, body: JSON.stringify(body), addAuthHeaders: false, timeout });
313
+ const response = await this.postAsync({
314
+ url,
315
+ headers,
316
+ body: JSON.stringify(body),
317
+ addAuthHeaders: false,
318
+ timeout
319
+ });
261
320
  return response.text();
262
321
  }
263
322
  };
@@ -290,7 +349,12 @@ var HighlightService = class extends base_service_default {
290
349
  const url = `${this.getUrlPrefix()}/v2/search`;
291
350
  const headers = new Headers();
292
351
  headers.append("Content-Type", "application/json");
293
- const response = await this.postAsync({ url, headers, body: JSON.stringify(search), timeout });
352
+ const response = await this.postAsync({
353
+ url,
354
+ headers,
355
+ body: JSON.stringify(search),
356
+ timeout
357
+ });
294
358
  return response.json();
295
359
  }
296
360
  async deleteHighlightOrNote({
@@ -346,7 +410,12 @@ var HighlightService = class extends base_service_default {
346
410
  const url = `${this.getUrlPrefix()}/v2/isbn/${isbn}/pid/${pid}/key/${key}`;
347
411
  const headers = new Headers();
348
412
  headers.set("Content-Type", "application/json");
349
- const response = await this.putAsync({ url, headers, body: JSON.stringify(payload), timeout });
413
+ const response = await this.putAsync({
414
+ url,
415
+ headers,
416
+ body: JSON.stringify(payload),
417
+ timeout
418
+ });
350
419
  return response.json();
351
420
  }
352
421
  async addHighlightOrNote({
@@ -358,7 +427,12 @@ var HighlightService = class extends base_service_default {
358
427
  const url = `${this.getUrlPrefix()}/v2/isbn/${isbn}/pid/${pid}`;
359
428
  const headers = new Headers();
360
429
  headers.set("Content-Type", "application/json");
361
- const response = await this.postAsync({ url, headers, body: JSON.stringify(payload), timeout });
430
+ const response = await this.postAsync({
431
+ url,
432
+ headers,
433
+ body: JSON.stringify(payload),
434
+ timeout
435
+ });
362
436
  return response.json();
363
437
  }
364
438
  };
@@ -410,7 +484,12 @@ var UserSettingsClientSettings = class extends user_settings_base_default {
410
484
  const url = `${this.getUrlPrefix()}/clientsettings/isbn/${isbn}`;
411
485
  const headers = new Headers();
412
486
  headers.set("Content-Type", "application/json");
413
- const response = await this.putAsync({ url, headers, body: JSON.stringify(settings), timeout });
487
+ const response = await this.putAsync({
488
+ url,
489
+ headers,
490
+ body: JSON.stringify(settings),
491
+ timeout
492
+ });
414
493
  return response.json();
415
494
  }
416
495
  async deleteSettings({
@@ -438,7 +517,12 @@ var UserSettingsBookmarks = class extends user_settings_base_default {
438
517
  headers.set("external-user-id", externalUserId);
439
518
  }
440
519
  headers.set("Content-Type", "application/json");
441
- const response = await this.putAsync({ url, headers, body: JSON.stringify(bookmark), timeout });
520
+ const response = await this.putAsync({
521
+ url,
522
+ headers,
523
+ body: JSON.stringify(bookmark),
524
+ timeout
525
+ });
442
526
  return response.json();
443
527
  }
444
528
  async deleteBookmark({
@@ -499,7 +583,12 @@ var UserSettingsContinue = class extends user_settings_base_default {
499
583
  headers.set("external-user-id", externalUserId);
500
584
  }
501
585
  headers.set("Content-Type", "application/json");
502
- const response = await this.putAsync({ url, headers, body: JSON.stringify(continueBody), timeout });
586
+ const response = await this.putAsync({
587
+ url,
588
+ headers,
589
+ body: JSON.stringify(continueBody),
590
+ timeout
591
+ });
503
592
  return response.json();
504
593
  }
505
594
  async deleteContinue({
@@ -543,20 +632,21 @@ var UserSettingsMRU = class extends user_settings_base_default {
543
632
  headers.set("external-user-id", externalUserId);
544
633
  }
545
634
  headers.set("Content-Type", "application/json");
546
- const response = await this.postAsync({ url, headers, body: JSON.stringify(mru), timeout });
635
+ const response = await this.postAsync({
636
+ url,
637
+ headers,
638
+ body: JSON.stringify(mru),
639
+ timeout
640
+ });
547
641
  return response.json();
548
642
  }
549
- async clearMRU({
550
- timeout = 5e3
551
- }) {
643
+ async clearMRU({ timeout = 5e3 }) {
552
644
  const url = `${this.getUrlPrefix()}/mru`;
553
645
  const headers = new Headers();
554
646
  await this.deleteAsync({ url, headers, timeout });
555
647
  return;
556
648
  }
557
- async getMRU({
558
- timeout = 5e3
559
- }) {
649
+ async getMRU({ timeout = 5e3 }) {
560
650
  let url = `${this.getUrlPrefix()}/mru`;
561
651
  const headers = new Headers();
562
652
  const response = await this.getAsync({ url, headers, timeout });
@@ -587,7 +677,12 @@ var PdfGeneratorService = class extends base_service_default {
587
677
  const url = `${this.getUrlPrefix()}/sitemap`;
588
678
  const headers = new Headers();
589
679
  headers.append("Content-Type", "application/json");
590
- const response = await this.postAsync({ url, headers, body: JSON.stringify(body), timeout });
680
+ const response = await this.postAsync({
681
+ url,
682
+ headers,
683
+ body: JSON.stringify(body),
684
+ timeout
685
+ });
591
686
  return response.json();
592
687
  }
593
688
  async pdfFromWritingTask({
@@ -597,7 +692,12 @@ var PdfGeneratorService = class extends base_service_default {
597
692
  const url = `${this.getUrlPrefix()}/writingTask`;
598
693
  const headers = new Headers();
599
694
  headers.append("Content-Type", "application/json");
600
- const response = await this.postAsync({ url, headers, body: JSON.stringify(body), timeout });
695
+ const response = await this.postAsync({
696
+ url,
697
+ headers,
698
+ body: JSON.stringify(body),
699
+ timeout
700
+ });
601
701
  return response.json();
602
702
  }
603
703
  async pdfFromNotes({
@@ -607,7 +707,12 @@ var PdfGeneratorService = class extends base_service_default {
607
707
  const url = `${this.getUrlPrefix()}/notes`;
608
708
  const headers = new Headers();
609
709
  headers.append("Content-Type", "application/json");
610
- const response = await this.postAsync({ url, headers, body: JSON.stringify(body), timeout });
710
+ const response = await this.postAsync({
711
+ url,
712
+ headers,
713
+ body: JSON.stringify(body),
714
+ timeout
715
+ });
611
716
  return response.json();
612
717
  }
613
718
  };
@@ -627,114 +732,126 @@ var UserFolders = class extends tagging_service_default {
627
732
  const payloadObject = JSON.parse(payload);
628
733
  return `user_${payloadObject.authns}_${payloadObject.user}`;
629
734
  }
630
- throw new Error("The UserFolders service must be invoked with a valid bearer token");
735
+ throw new Error(
736
+ "The UserFolders service must be invoked with a valid bearer token"
737
+ );
631
738
  }
632
739
  /**
633
- * Create a folder.
634
- * @param folder_name The name of the folder.
635
- * @param parent_folder_uuid The UUID of the parent folder. If no parent folder is provided, the folder is created at the root level.
636
- * @param color The color of the folder.
637
- * @param timeout The timeout for the request in milliseconds.
638
- *
639
- * @return Folder
640
- **/
740
+ * Create a folder.
741
+ * @param folder_name The name of the folder.
742
+ * @param parent_folder_uuid The UUID of the parent folder. If no parent folder is provided, the folder is created at the root level.
743
+ * @param color The color of the folder.
744
+ * @param timeout The timeout for the request in milliseconds.
745
+ *
746
+ * @return Folder
747
+ **/
641
748
  async createFolder({
642
749
  folder_name,
643
750
  parent_folder_uuid,
644
751
  color,
645
752
  timeout = 3e3
646
753
  }) {
647
- const folder_payload = JSON.stringify({ "folder": folder_name, "color": color });
648
- const tag = await this.createTag(
649
- {
650
- tag: {
651
- identity: await this.getIdentity(),
652
- resource_type: "myaccount_user_folder",
653
- resource_name: uuidv4(),
654
- tag_name: parent_folder_uuid ?? this.hasNoParent,
655
- tag_value: Buffer.from(folder_payload).toString("base64")
656
- },
657
- timeout
658
- }
659
- );
660
- return { name: folder_name, uuid: tag["resource_name"], parent: parent_folder_uuid, created_at: tag["created_at"] };
754
+ const folder_payload = JSON.stringify({
755
+ folder: folder_name,
756
+ color
757
+ });
758
+ const tag = await this.createTag({
759
+ tag: {
760
+ identity: await this.getIdentity(),
761
+ resource_type: "myaccount_user_folder",
762
+ resource_name: uuidv4(),
763
+ tag_name: parent_folder_uuid ?? this.hasNoParent,
764
+ tag_value: Buffer.from(folder_payload).toString("base64")
765
+ },
766
+ timeout
767
+ });
768
+ return {
769
+ name: folder_name,
770
+ uuid: tag["resource_name"],
771
+ parent: parent_folder_uuid,
772
+ created_at: tag["created_at"]
773
+ };
661
774
  }
662
775
  /**
663
- * Update a folder. Only name and color can be changed.
664
- *
665
- * @param folder_uuid The UUID of the folder.
666
- * @param folder_name The new name of the folder.
667
- * @param color The new color of the folder.
668
- * @param timeout The timeout for the request in milliseconds.
669
- *
670
- * @return Folder
671
- **/
776
+ * Update a folder. Only name and color can be changed.
777
+ *
778
+ * @param folder_uuid The UUID of the folder.
779
+ * @param folder_name The new name of the folder.
780
+ * @param color The new color of the folder.
781
+ * @param timeout The timeout for the request in milliseconds.
782
+ *
783
+ * @return Folder
784
+ **/
672
785
  async updateFolder({
673
786
  folder_uuid,
674
787
  folder_name,
675
788
  color,
676
789
  timeout = 3e3
677
790
  }) {
678
- const tags = await this.getTagsByResource(
679
- {
680
- identity: await this.getIdentity(),
681
- resource_type: "myaccount_user_folder",
682
- resource_name: folder_uuid,
683
- timeout
684
- }
685
- );
791
+ const tags = await this.getTagsByResource({
792
+ identity: await this.getIdentity(),
793
+ resource_type: "myaccount_user_folder",
794
+ resource_name: folder_uuid,
795
+ timeout
796
+ });
686
797
  if (tags.length === 0) {
687
798
  throw new Error(`Folder with UUID ${folder_uuid} not found`);
688
799
  }
689
800
  const tag = tags[0];
690
- const folder_payload = JSON.parse(Buffer.from(tag["tag_value"], "base64").toString());
801
+ const folder_payload = JSON.parse(
802
+ Buffer.from(tag["tag_value"], "base64").toString()
803
+ );
691
804
  const new_folder_name = folder_name ?? folder_payload["folder"];
692
805
  const new_color = color ?? folder_payload["color"];
693
- const new_folder_payload = JSON.stringify({ "folder": new_folder_name, "color": new_color });
694
- const updatedTag = await this.updateTag(
695
- {
696
- tag: {
697
- identity: await this.getIdentity(),
698
- resource_type: "myaccount_user_folder",
699
- resource_name: folder_uuid,
700
- tag_name: tag["tag_name"],
701
- tag_value: Buffer.from(new_folder_payload).toString("base64")
702
- },
703
- timeout
704
- }
705
- );
806
+ const new_folder_payload = JSON.stringify({
807
+ folder: new_folder_name,
808
+ color: new_color
809
+ });
810
+ const updatedTag = await this.updateTag({
811
+ tag: {
812
+ identity: await this.getIdentity(),
813
+ resource_type: "myaccount_user_folder",
814
+ resource_name: folder_uuid,
815
+ tag_name: tag["tag_name"],
816
+ tag_value: Buffer.from(new_folder_payload).toString("base64")
817
+ },
818
+ timeout
819
+ });
706
820
  const parent = tag["tag_name"] === this.hasNoParent ? void 0 : tag["tag_name"];
707
- return { name: new_folder_name, uuid: folder_uuid, parent, created_at: updatedTag["created_at"] };
821
+ return {
822
+ name: new_folder_name,
823
+ uuid: folder_uuid,
824
+ parent,
825
+ created_at: updatedTag["created_at"]
826
+ };
708
827
  }
709
828
  /**
710
- * List all folders in the user's account.
711
- *
712
- * @param timeout The timeout for the request in milliseconds.
713
- *
714
- * @return Folder[]
715
- **/
829
+ * List all folders in the user's account.
830
+ *
831
+ * @param timeout The timeout for the request in milliseconds.
832
+ *
833
+ * @return Folder[]
834
+ **/
716
835
  async listAllFolders({
717
836
  timeout = 3e3
718
837
  }) {
719
- const tags = await this.getTagsByResource(
720
- {
721
- identity: await this.getIdentity(),
722
- resource_type: "myaccount_user_folder",
723
- timeout
724
- }
725
- );
838
+ const tags = await this.getTagsByResource({
839
+ identity: await this.getIdentity(),
840
+ resource_type: "myaccount_user_folder",
841
+ timeout
842
+ });
726
843
  let folders = [];
727
844
  for (const tag of tags) {
728
- const folder_payload = JSON.parse(Buffer.from(tag["tag_value"], "base64").toString());
729
- folders.push(
730
- {
731
- name: folder_payload["folder"],
732
- color: folder_payload["color"],
733
- uuid: tag["resource_name"],
734
- parent: tag["tag_name"] === this.hasNoParent ? void 0 : tag["tag_name"],
735
- created_at: tag["created_at"]
736
- }
845
+ const folder_payload = JSON.parse(
846
+ Buffer.from(tag["tag_value"], "base64").toString()
737
847
  );
848
+ folders.push({
849
+ name: folder_payload["folder"],
850
+ color: folder_payload["color"],
851
+ uuid: tag["resource_name"],
852
+ parent: tag["tag_name"] === this.hasNoParent ? void 0 : tag["tag_name"],
853
+ created_at: tag["created_at"]
854
+ });
738
855
  }
739
856
  return folders;
740
857
  }
@@ -745,7 +862,7 @@ var UserFolders = class extends tagging_service_default {
745
862
  * @param timeout The timeout for the request in milliseconds.
746
863
  *
747
864
  * @return Folder[]
748
- **/
865
+ **/
749
866
  async listNextFolderLevel({
750
867
  parent_folder_uuid,
751
868
  timeout = 3e3
@@ -754,52 +871,50 @@ var UserFolders = class extends tagging_service_default {
754
871
  if (!parent_folder_uuid) {
755
872
  parent_folder_uuid = this.hasNoParent;
756
873
  }
757
- tags = await this.getTagsByName(
758
- {
759
- identity: await this.getIdentity(),
760
- resource_type: "myaccount_user_folder",
761
- tag_name: parent_folder_uuid,
762
- timeout
763
- }
764
- );
874
+ tags = await this.getTagsByName({
875
+ identity: await this.getIdentity(),
876
+ resource_type: "myaccount_user_folder",
877
+ tag_name: parent_folder_uuid,
878
+ timeout
879
+ });
765
880
  let folders = [];
766
881
  for (const tag of tags) {
767
- const folder_payload = JSON.parse(Buffer.from(tag["tag_value"], "base64").toString());
768
- folders.push(
769
- {
770
- name: folder_payload["folder"],
771
- color: folder_payload["color"],
772
- uuid: tag["resource_name"],
773
- parent: tag["tag_name"] === this.hasNoParent ? void 0 : tag["tag_name"],
774
- created_at: tag["created_at"]
775
- }
882
+ const folder_payload = JSON.parse(
883
+ Buffer.from(tag["tag_value"], "base64").toString()
776
884
  );
885
+ folders.push({
886
+ name: folder_payload["folder"],
887
+ color: folder_payload["color"],
888
+ uuid: tag["resource_name"],
889
+ parent: tag["tag_name"] === this.hasNoParent ? void 0 : tag["tag_name"],
890
+ created_at: tag["created_at"]
891
+ });
777
892
  }
778
893
  return folders;
779
894
  }
780
895
  /**
781
- * List the content of a folder.
782
- *
783
- * @param folder_uuid The UUID of the folder.
784
- * @param timeout The timeout for the request in milliseconds.
785
- *
786
- * @return (Folder | FolderContent)[]
787
- **/
896
+ * List the content of a folder.
897
+ *
898
+ * @param folder_uuid The UUID of the folder.
899
+ * @param timeout The timeout for the request in milliseconds.
900
+ *
901
+ * @return (Folder | FolderContent)[]
902
+ **/
788
903
  async getFolderContent({
789
904
  folder_uuid,
790
905
  timeout = 3e3
791
906
  }) {
792
- let tags = await this.getTagsByName(
793
- {
794
- identity: await this.getIdentity(),
795
- tag_name: folder_uuid,
796
- timeout
797
- }
798
- );
907
+ let tags = await this.getTagsByName({
908
+ identity: await this.getIdentity(),
909
+ tag_name: folder_uuid,
910
+ timeout
911
+ });
799
912
  let content = [];
800
913
  for (const tag of tags) {
801
914
  if (tag["resource_type"] === "myaccount_user_folder") {
802
- const folder_payload = JSON.parse(Buffer.from(tag["tag_value"], "base64").toString());
915
+ const folder_payload = JSON.parse(
916
+ Buffer.from(tag["tag_value"], "base64").toString()
917
+ );
803
918
  content.push({
804
919
  name: folder_payload["folder"],
805
920
  color: folder_payload["color"],
@@ -808,14 +923,12 @@ var UserFolders = class extends tagging_service_default {
808
923
  created_at: tag["created_at"]
809
924
  });
810
925
  } else {
811
- content.push(
812
- {
813
- type: tag["resource_type"],
814
- identifier: tag["resource_name"],
815
- folder_uuid: tag["tag_name"],
816
- created_at: tag["created_at"]
817
- }
818
- );
926
+ content.push({
927
+ type: tag["resource_type"],
928
+ identifier: tag["resource_name"],
929
+ folder_uuid: tag["tag_name"],
930
+ created_at: tag["created_at"]
931
+ });
819
932
  }
820
933
  }
821
934
  return content;
@@ -828,20 +941,18 @@ var UserFolders = class extends tagging_service_default {
828
941
  * @param timeout The timeout for the request in milliseconds.
829
942
  *
830
943
  * @return FolderContent
831
- **/
944
+ **/
832
945
  async addInternetbookToFolder({
833
946
  folder_uuid,
834
947
  isbn,
835
948
  timeout = 3e3
836
949
  }) {
837
- return await this.addContentToFolder(
838
- {
839
- folder_uuid,
840
- resource_type: "internetbook",
841
- resource_name: isbn,
842
- timeout
843
- }
844
- );
950
+ return await this.addContentToFolder({
951
+ folder_uuid,
952
+ resource_type: "internetbook",
953
+ resource_name: isbn,
954
+ timeout
955
+ });
845
956
  }
846
957
  /**
847
958
  * Remove a book from a folder.
@@ -851,20 +962,18 @@ var UserFolders = class extends tagging_service_default {
851
962
  * @param timeout The timeout for the request in milliseconds.
852
963
  *
853
964
  * @return void
854
- **/
965
+ **/
855
966
  async removeInternetbookFromFolder({
856
967
  folder_uuid,
857
968
  isbn,
858
969
  timeout = 3e3
859
970
  }) {
860
- await this.removeContentFromFolder(
861
- {
862
- folder_uuid,
863
- resource_type: "internetbook",
864
- resource_name: isbn,
865
- timeout
866
- }
867
- );
971
+ await this.removeContentFromFolder({
972
+ folder_uuid,
973
+ resource_type: "internetbook",
974
+ resource_name: isbn,
975
+ timeout
976
+ });
868
977
  }
869
978
  /**
870
979
  * Create a new folder content element.
@@ -875,26 +984,29 @@ var UserFolders = class extends tagging_service_default {
875
984
  * @param timeout The timeout for the request in milliseconds.
876
985
  *
877
986
  * @return FolderContent
878
- **/
987
+ **/
879
988
  async addContentToFolder({
880
989
  folder_uuid,
881
990
  resource_type,
882
991
  resource_name,
883
992
  timeout = 3e3
884
993
  }) {
885
- const tag = await this.createTag(
886
- {
887
- tag: {
888
- identity: await this.getIdentity(),
889
- resource_type,
890
- resource_name,
891
- tag_name: folder_uuid,
892
- tag_value: "MYACCOUNT_USER_FOLDER"
893
- },
894
- timeout
895
- }
896
- );
897
- return { type: resource_type, identifier: resource_name, folder_uuid, created_at: tag["created_at"] };
994
+ const tag = await this.createTag({
995
+ tag: {
996
+ identity: await this.getIdentity(),
997
+ resource_type,
998
+ resource_name,
999
+ tag_name: folder_uuid,
1000
+ tag_value: "MYACCOUNT_USER_FOLDER"
1001
+ },
1002
+ timeout
1003
+ });
1004
+ return {
1005
+ type: resource_type,
1006
+ identifier: resource_name,
1007
+ folder_uuid,
1008
+ created_at: tag["created_at"]
1009
+ };
898
1010
  }
899
1011
  /**
900
1012
  * Remove a folder content element.
@@ -905,22 +1017,20 @@ var UserFolders = class extends tagging_service_default {
905
1017
  * @param timeout The timeout for the request in milliseconds.
906
1018
  *
907
1019
  * @return void
908
- **/
1020
+ **/
909
1021
  async removeContentFromFolder({
910
1022
  folder_uuid,
911
1023
  resource_name,
912
1024
  resource_type,
913
1025
  timeout = 3e3
914
1026
  }) {
915
- await this.deleteTag(
916
- {
917
- identity: await this.getIdentity(),
918
- resource_type,
919
- resource_name,
920
- tag_name: folder_uuid,
921
- timeout
922
- }
923
- );
1027
+ await this.deleteTag({
1028
+ identity: await this.getIdentity(),
1029
+ resource_type,
1030
+ resource_name,
1031
+ tag_name: folder_uuid,
1032
+ timeout
1033
+ });
924
1034
  }
925
1035
  /**
926
1036
  * Delete a folder.
@@ -929,19 +1039,17 @@ var UserFolders = class extends tagging_service_default {
929
1039
  * @param timeout The timeout for the request in milliseconds.
930
1040
  *
931
1041
  * @return void
932
- **/
1042
+ **/
933
1043
  async deleteFolder({
934
1044
  folder_uuid,
935
1045
  timeout = 3e3
936
1046
  }) {
937
- await this.deleteTag(
938
- {
939
- identity: await this.getIdentity(),
940
- resource_type: "myaccount_user_folder",
941
- resource_name: folder_uuid,
942
- timeout
943
- }
944
- );
1047
+ await this.deleteTag({
1048
+ identity: await this.getIdentity(),
1049
+ resource_type: "myaccount_user_folder",
1050
+ resource_name: folder_uuid,
1051
+ timeout
1052
+ });
945
1053
  }
946
1054
  /**
947
1055
  * Delete all folders. Note, this will not delete the content of the folders.
@@ -949,17 +1057,15 @@ var UserFolders = class extends tagging_service_default {
949
1057
  * @param timeout The timeout for the request in milliseconds.
950
1058
  *
951
1059
  * @return void
952
- **/
1060
+ **/
953
1061
  async deleteAllFolders({
954
1062
  timeout = 3e3
955
1063
  }) {
956
- await this.deleteTag(
957
- {
958
- identity: await this.getIdentity(),
959
- resource_type: "myaccount_user_folder",
960
- timeout
961
- }
962
- );
1064
+ await this.deleteTag({
1065
+ identity: await this.getIdentity(),
1066
+ resource_type: "myaccount_user_folder",
1067
+ timeout
1068
+ });
963
1069
  }
964
1070
  };
965
1071
 
@@ -1008,10 +1114,19 @@ var AIBotService = class extends base_service_default {
1008
1114
  body,
1009
1115
  timeout = 1e4
1010
1116
  }) {
1011
- const url = await this.constructChatUrl({ interactivityId, isbn, stream: false });
1117
+ const url = await this.constructChatUrl({
1118
+ interactivityId,
1119
+ isbn,
1120
+ stream: false
1121
+ });
1012
1122
  const headers = new Headers();
1013
1123
  headers.append("Content-Type", "application/json");
1014
- const response = await this.postAsync({ url, headers, body: JSON.stringify(body), timeout });
1124
+ const response = await this.postAsync({
1125
+ url,
1126
+ headers,
1127
+ body: JSON.stringify(body),
1128
+ timeout
1129
+ });
1015
1130
  return response.json();
1016
1131
  }
1017
1132
  async streamingChat({
@@ -1020,10 +1135,19 @@ var AIBotService = class extends base_service_default {
1020
1135
  body,
1021
1136
  timeout = 1e4
1022
1137
  }) {
1023
- const url = await this.constructChatUrl({ interactivityId, isbn, stream: true });
1138
+ const url = await this.constructChatUrl({
1139
+ interactivityId,
1140
+ isbn,
1141
+ stream: true
1142
+ });
1024
1143
  const headers = new Headers();
1025
1144
  headers.append("Content-Type", "application/json");
1026
- const response = await this.postAsync({ url, headers, body: JSON.stringify(body), timeout });
1145
+ const response = await this.postAsync({
1146
+ url,
1147
+ headers,
1148
+ body: JSON.stringify(body),
1149
+ timeout
1150
+ });
1027
1151
  const responseBody = response.body;
1028
1152
  if (!responseBody) {
1029
1153
  throw new Error("Response body is null");
@@ -1278,7 +1402,7 @@ var QuizService = class extends base_service_default {
1278
1402
  const url = `${this.getUrlPrefix()}/shared/quiz/${quizSessionId}`;
1279
1403
  const method = archive ? "DELETE" : "PATCH";
1280
1404
  const headers = this.makeHeaders(extraHeaders);
1281
- const res = method === "DELETE" ? await this.deleteAsync({ url, headers, timeout }) : await this.postAsync({
1405
+ const res = method === "DELETE" ? await this.deleteAsync({ url, headers, timeout }) : await this.patchAsync({
1282
1406
  url,
1283
1407
  headers,
1284
1408
  body: null,