musora-content-services 1.3.10 → 1.3.11

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.
@@ -29,7 +29,7 @@
29
29
  <nav >
30
30
 
31
31
 
32
- <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Config.html">Config</a><ul class='methods'><li data-type='method'><a href="module-Config.html#.initializeService">initializeService</a></li></ul></li><li><a href="module-Railcontent-Services.html">Railcontent-Services</a><ul class='methods'><li data-type='method'><a href="module-Railcontent-Services.html#.addItemToPlaylist">addItemToPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.countAssignmentsAndLessons">countAssignmentsAndLessons</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.createPlaylist">createPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylist">deletePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylistItem">deletePlaylistItem</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylistLike">deletePlaylistLike</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.duplicatePlaylist">duplicatePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchAllCompletedStates">fetchAllCompletedStates</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCarouselCardData">fetchCarouselCardData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeIndexMetadata">fetchChallengeIndexMetadata</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeLessonData">fetchChallengeLessonData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeMetadata">fetchChallengeMetadata</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeUserActiveChallenges">fetchChallengeUserActiveChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedChallenges">fetchCompletedChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedContent">fetchCompletedContent</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedState">fetchCompletedState</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchContentInProgress">fetchContentInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchContentPageUserData">fetchContentPageUserData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchNextContentDataForParent">fetchNextContentDataForParent</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchOwnedChallenges">fetchOwnedChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPinnedPlaylists">fetchPinnedPlaylists</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylist">fetchPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylistItem">fetchPlaylistItem</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylistItems">fetchPlaylistItems</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchSongsInProgress">fetchSongsInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserAward">fetchUserAward</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserBadges">fetchUserBadges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserChallengeProgress">fetchUserChallengeProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserPlaylists">fetchUserPlaylists</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.likePlaylist">likePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.pinPlaylist">pinPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesCommunityNotification">postChallengesCommunityNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesCompleteLesson">postChallengesCompleteLesson</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesEnroll">postChallengesEnroll</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesEnrollmentNotification">postChallengesEnrollmentNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesHideCompletedBanner">postChallengesHideCompletedBanner</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesLeave">postChallengesLeave</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesSetStartDate">postChallengesSetStartDate</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesSoloNotification">postChallengesSoloNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesUnlock">postChallengesUnlock</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.reportPlaylist">reportPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.setStudentViewForUser">setStudentViewForUser</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.unpinPlaylist">unpinPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.updatePlaylist">updatePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.updatePlaylistItem">updatePlaylistItem</a></li></ul></li><li><a href="module-Sanity-Services.html">Sanity-Services</a><ul class='methods'><li data-type='method'><a href="module-Sanity-Services.html#.fetchAll">fetchAll</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllFilterOptions">fetchAllFilterOptions</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllPacks">fetchAllPacks</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchArtistLessons">fetchArtistLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchArtists">fetchArtists</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByRailContentId">fetchByRailContentId</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByRailContentIds">fetchByRailContentIds</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByReference">fetchByReference</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCoachLessons">fetchCoachLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCommentModContentData">fetchCommentModContentData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchFoundation">fetchFoundation</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchGenreLessons">fetchGenreLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchLessonContent">fetchLessonContent</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMetadata">fetchMetadata</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethod">fetchMethod</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodChildren">fetchMethodChildren</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodChildrenIds">fetchMethodChildrenIds</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodPreviousNextLesson">fetchMethodPreviousNextLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchNewReleases">fetchNewReleases</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchNextPreviousLesson">fetchNextPreviousLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackAll">fetchPackAll</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackData">fetchPackData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchParentForDownload">fetchParentForDownload</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedLessons">fetchRelatedLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedSongs">fetchRelatedSongs</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSanity">fetchSanity</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchScheduledReleases">fetchScheduledReleases</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchShowsData">fetchShowsData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongArtistCount">fetchSongArtistCount</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongById">fetchSongById</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchUpcomingEvents">fetchUpcomingEvents</a></li><li data-type='method'><a href="module-Sanity-Services.html#.jumpToContinueContent">jumpToContinueContent</a></li><li data-type='method'><a href="module-Sanity-Services.html#~handleCustomFetchAll">handleCustomFetchAll</a></li></ul></li></ul>
32
+ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Config.html">Config</a><ul class='methods'><li data-type='method'><a href="module-Config.html#.initializeService">initializeService</a></li></ul></li><li><a href="module-Railcontent-Services.html">Railcontent-Services</a><ul class='methods'><li data-type='method'><a href="module-Railcontent-Services.html#.addItemToPlaylist">addItemToPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.countAssignmentsAndLessons">countAssignmentsAndLessons</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.createPlaylist">createPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylist">deletePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylistItem">deletePlaylistItem</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.deletePlaylistLike">deletePlaylistLike</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.duplicatePlaylist">duplicatePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchAllCompletedStates">fetchAllCompletedStates</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCarouselCardData">fetchCarouselCardData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeIndexMetadata">fetchChallengeIndexMetadata</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeLessonData">fetchChallengeLessonData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeMetadata">fetchChallengeMetadata</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchChallengeUserActiveChallenges">fetchChallengeUserActiveChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedChallenges">fetchCompletedChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedContent">fetchCompletedContent</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchCompletedState">fetchCompletedState</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchContentInProgress">fetchContentInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchContentPageUserData">fetchContentPageUserData</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchNextContentDataForParent">fetchNextContentDataForParent</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchOwnedChallenges">fetchOwnedChallenges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPinnedPlaylists">fetchPinnedPlaylists</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylist">fetchPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylistItem">fetchPlaylistItem</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchPlaylistItems">fetchPlaylistItems</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchSongsInProgress">fetchSongsInProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserAward">fetchUserAward</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserBadges">fetchUserBadges</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserChallengeProgress">fetchUserChallengeProgress</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.fetchUserPlaylists">fetchUserPlaylists</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.likePlaylist">likePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.pinPlaylist">pinPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesCommunityNotification">postChallengesCommunityNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesCompleteLesson">postChallengesCompleteLesson</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesEnroll">postChallengesEnroll</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesEnrollmentNotification">postChallengesEnrollmentNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesHideCompletedBanner">postChallengesHideCompletedBanner</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesLeave">postChallengesLeave</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesSetStartDate">postChallengesSetStartDate</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesSoloNotification">postChallengesSoloNotification</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.postChallengesUnlock">postChallengesUnlock</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.reportPlaylist">reportPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.setStudentViewForUser">setStudentViewForUser</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.unpinPlaylist">unpinPlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.updatePlaylist">updatePlaylist</a></li><li data-type='method'><a href="module-Railcontent-Services.html#.updatePlaylistItem">updatePlaylistItem</a></li></ul></li><li><a href="module-Sanity-Services.html">Sanity-Services</a><ul class='methods'><li data-type='method'><a href="module-Sanity-Services.html#.fetchAll">fetchAll</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllFilterOptions">fetchAllFilterOptions</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchAllPacks">fetchAllPacks</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchArtistLessons">fetchArtistLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchArtists">fetchArtists</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByRailContentId">fetchByRailContentId</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByRailContentIds">fetchByRailContentIds</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchByReference">fetchByReference</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCoachLessons">fetchCoachLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchComingSoon">fetchComingSoon</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchCommentModContentData">fetchCommentModContentData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchFoundation">fetchFoundation</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchGenreLessons">fetchGenreLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchLeaving">fetchLeaving</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchLessonContent">fetchLessonContent</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMetadata">fetchMetadata</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethod">fetchMethod</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodChildren">fetchMethodChildren</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodChildrenIds">fetchMethodChildrenIds</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchMethodPreviousNextLesson">fetchMethodPreviousNextLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchNewReleases">fetchNewReleases</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchNextPreviousLesson">fetchNextPreviousLesson</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackAll">fetchPackAll</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchPackData">fetchPackData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchParentForDownload">fetchParentForDownload</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedLessons">fetchRelatedLessons</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchRelatedSongs">fetchRelatedSongs</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchReturning">fetchReturning</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSanity">fetchSanity</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchScheduledReleases">fetchScheduledReleases</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchShowsData">fetchShowsData</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongArtistCount">fetchSongArtistCount</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchSongById">fetchSongById</a></li><li data-type='method'><a href="module-Sanity-Services.html#.fetchUpcomingEvents">fetchUpcomingEvents</a></li><li data-type='method'><a href="module-Sanity-Services.html#.jumpToContinueContent">jumpToContinueContent</a></li><li data-type='method'><a href="module-Sanity-Services.html#~getNextAndPreviousQuarterDates">getNextAndPreviousQuarterDates</a></li><li data-type='method'><a href="module-Sanity-Services.html#~getQueryFromPage">getQueryFromPage</a></li><li data-type='method'><a href="module-Sanity-Services.html#~handleCustomFetchAll">handleCustomFetchAll</a></li></ul></li></ul>
33
33
 
34
34
  </nav>
35
35
 
@@ -48,9 +48,9 @@
48
48
  <pre class="prettyprint source linenums"><code>/**
49
49
  * @module Railcontent-Services
50
50
  */
51
- import {contentStatusCompleted} from "./contentProgress.js";
51
+ import { contentStatusCompleted } from './contentProgress.js'
52
52
 
53
- import { globalConfig } from "./config.js";
53
+ import { globalConfig } from './config.js'
54
54
 
55
55
  /**
56
56
  * Exported functions that are excluded from index generation.
@@ -58,17 +58,17 @@ import { globalConfig } from "./config.js";
58
58
  * @type {string[]}
59
59
  */
60
60
  const excludeFromGeneratedIndex = [
61
- 'fetchUserLikes',
62
- 'postContentLiked',
63
- 'postContentUnliked',
64
- 'postRecordWatchSession',
65
- 'postContentStarted',
66
- 'postContentCompleted',
67
- 'postContentReset',
68
- 'fetchUserPermissionsData'
69
- ];
70
-
71
- let challengeIndexMetaDataPromise = null;
61
+ 'fetchUserLikes',
62
+ 'postContentLiked',
63
+ 'postContentUnliked',
64
+ 'postRecordWatchSession',
65
+ 'postContentStarted',
66
+ 'postContentCompleted',
67
+ 'postContentReset',
68
+ 'fetchUserPermissionsData',
69
+ ]
70
+
71
+ let challengeIndexMetaDataPromise = null
72
72
 
73
73
  /**
74
74
  * Fetches the completion status of a specific lesson for the current user.
@@ -81,30 +81,29 @@ let challengeIndexMetaDataPromise = null;
81
81
  * .catch(error => console.error(error));
82
82
  */
83
83
  export async function fetchCompletedState(content_id) {
84
- const url = `/content/user_progress/${globalConfig.railcontentConfig.userId}?content_ids[]=${content_id}`;
85
-
86
- const headers = {
87
- 'Content-Type': 'application/json',
88
- 'Accept': 'application/json',
89
- 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
90
- };
91
-
92
- try {
93
- const response = await fetchAbsolute(url, {headers});
94
- const result = await response.json();
95
-
96
- if (result &amp;&amp; result[content_id]) {
97
- return result[content_id]; // Return the correct object
98
- } else {
99
- return null; // Handle unexpected structure
100
- }
101
- } catch (error) {
102
- console.error('Fetch error:', error);
103
- return null;
84
+ const url = `/content/user_progress/${globalConfig.railcontentConfig.userId}?content_ids[]=${content_id}`
85
+
86
+ const headers = {
87
+ 'Content-Type': 'application/json',
88
+ Accept: 'application/json',
89
+ 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token,
90
+ }
91
+
92
+ try {
93
+ const response = await fetchAbsolute(url, { headers })
94
+ const result = await response.json()
95
+
96
+ if (result &amp;&amp; result[content_id]) {
97
+ return result[content_id] // Return the correct object
98
+ } else {
99
+ return null // Handle unexpected structure
104
100
  }
101
+ } catch (error) {
102
+ console.error('Fetch error:', error)
103
+ return null
104
+ }
105
105
  }
106
106
 
107
-
108
107
  /**
109
108
  * Fetches the completion status for multiple songs for the current user.
110
109
  *
@@ -116,26 +115,26 @@ export async function fetchCompletedState(content_id) {
116
115
  * .catch(error => console.error(error));
117
116
  */
118
117
  export async function fetchAllCompletedStates(contentIds) {
119
- const url = `/content/user_progress/${globalConfig.railcontentConfig.userId}?${contentIds.map(id => `content_ids[]=${id}`).join('&amp;')}`;
120
-
121
- const headers = {
122
- 'Content-Type': 'application/json',
123
- 'Accept': 'application/json',
124
- 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
125
- };
126
-
127
- try {
128
- const response = await fetchAbsolute(url, {headers});
129
- const result = await response.json();
130
- if (result) {
131
- return result;
132
- } else {
133
- console.log('result not json');
134
- }
135
- } catch (error) {
136
- console.error('Fetch error:', error);
137
- return null;
118
+ const url = `/content/user_progress/${globalConfig.railcontentConfig.userId}?${contentIds.map((id) => `content_ids[]=${id}`).join('&amp;')}`
119
+
120
+ const headers = {
121
+ 'Content-Type': 'application/json',
122
+ Accept: 'application/json',
123
+ 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token,
124
+ }
125
+
126
+ try {
127
+ const response = await fetchAbsolute(url, { headers })
128
+ const result = await response.json()
129
+ if (result) {
130
+ return result
131
+ } else {
132
+ console.log('result not json')
138
133
  }
134
+ } catch (error) {
135
+ console.error('Fetch error:', error)
136
+ return null
137
+ }
139
138
  }
140
139
 
141
140
  /**
@@ -149,27 +148,27 @@ export async function fetchAllCompletedStates(contentIds) {
149
148
  * .catch(error => console.error(error));
150
149
  */
151
150
  export async function fetchSongsInProgress(brand) {
152
- const url = `/content/in_progress/${globalConfig.railcontentConfig.userId}?content_type=song&amp;brand=${brand}`;
153
-
154
- const headers = {
155
- 'Content-Type': 'application/json',
156
- 'Accept': 'application/json',
157
- 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
158
- };
159
-
160
- try {
161
- const response = await fetchAbsolute(url, {headers});
162
- const result = await response.json();
163
- if (result) {
164
- //console.log('fetchSongsInProgress', result);
165
- return result;
166
- } else {
167
- console.log('result not json');
168
- }
169
- } catch (error) {
170
- console.error('Fetch error:', error);
171
- return null;
151
+ const url = `/content/in_progress/${globalConfig.railcontentConfig.userId}?content_type=song&amp;brand=${brand}`
152
+
153
+ const headers = {
154
+ 'Content-Type': 'application/json',
155
+ Accept: 'application/json',
156
+ 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token,
157
+ }
158
+
159
+ try {
160
+ const response = await fetchAbsolute(url, { headers })
161
+ const result = await response.json()
162
+ if (result) {
163
+ //console.log('fetchSongsInProgress', result);
164
+ return result
165
+ } else {
166
+ console.log('result not json')
172
167
  }
168
+ } catch (error) {
169
+ console.error('Fetch error:', error)
170
+ return null
171
+ }
173
172
  }
174
173
 
175
174
  /**
@@ -185,34 +184,34 @@ export async function fetchSongsInProgress(brand) {
185
184
  * .then(songs => console.log(songs))
186
185
  * .catch(error => console.error(error));
187
186
  */
188
- export async function fetchContentInProgress(type = "all", brand, {page, limit} = {}) {
189
- let url;
190
- const limitString = limit ? `&amp;limit=${limit}` : '';
191
- const pageString = page ? `&amp;page=${page}` : '';
192
-
193
- if (type === "all") {
194
- url = `/content/in_progress/${globalConfig.railcontentConfig.userId}?brand=${brand}${limitString}${pageString}`;
187
+ export async function fetchContentInProgress(type = 'all', brand, { page, limit } = {}) {
188
+ let url
189
+ const limitString = limit ? `&amp;limit=${limit}` : ''
190
+ const pageString = page ? `&amp;page=${page}` : ''
191
+
192
+ if (type === 'all') {
193
+ url = `/content/in_progress/${globalConfig.railcontentConfig.userId}?brand=${brand}${limitString}${pageString}`
194
+ } else {
195
+ url = `/content/in_progress/${globalConfig.railcontentConfig.userId}?content_type=${type}&amp;brand=${brand}${limitString}${pageString}`
196
+ }
197
+ const headers = {
198
+ 'Content-Type': 'application/json',
199
+ Accept: 'application/json',
200
+ 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token,
201
+ }
202
+ try {
203
+ const response = await fetchAbsolute(url, { headers })
204
+ const result = await response.json()
205
+ if (result) {
206
+ //console.log('contentInProgress', result);
207
+ return result
195
208
  } else {
196
- url = `/content/in_progress/${globalConfig.railcontentConfig.userId}?content_type=${type}&amp;brand=${brand}${limitString}${pageString}`;
197
- }
198
- const headers = {
199
- 'Content-Type': 'application/json',
200
- 'Accept': 'application/json',
201
- 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
202
- };
203
- try {
204
- const response = await fetchAbsolute(url, {headers});
205
- const result = await response.json();
206
- if (result) {
207
- //console.log('contentInProgress', result);
208
- return result;
209
- } else {
210
- console.log('result not json');
211
- }
212
- } catch (error) {
213
- console.error('Fetch error:', error);
214
- return null;
209
+ console.log('result not json')
215
210
  }
211
+ } catch (error) {
212
+ console.error('Fetch error:', error)
213
+ return null
214
+ }
216
215
  }
217
216
 
218
217
  /**
@@ -228,37 +227,36 @@ export async function fetchContentInProgress(type = "all", brand, {page, limit}
228
227
  * .then(songs => console.log(songs))
229
228
  * .catch(error => console.error(error));
230
229
  */
231
- export async function fetchCompletedContent(type = "all", brand, {page, limit} = {}) {
232
- let url;
233
- const limitString = limit ? `&amp;limit=${limit}` : '';
234
- const pageString = page ? `&amp;page=${page}` : '';
235
-
236
- if (type === "all") {
237
- url = `/content/completed/${globalConfig.railcontentConfig.userId}?brand=${brand}${limitString}${pageString}`;
230
+ export async function fetchCompletedContent(type = 'all', brand, { page, limit } = {}) {
231
+ let url
232
+ const limitString = limit ? `&amp;limit=${limit}` : ''
233
+ const pageString = page ? `&amp;page=${page}` : ''
234
+
235
+ if (type === 'all') {
236
+ url = `/content/completed/${globalConfig.railcontentConfig.userId}?brand=${brand}${limitString}${pageString}`
237
+ } else {
238
+ url = `/content/completed/${globalConfig.railcontentConfig.userId}?content_type=${type}&amp;brand=${brand}${limitString}${pageString}`
239
+ }
240
+ const headers = {
241
+ 'Content-Type': 'application/json',
242
+ Accept: 'application/json',
243
+ 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token,
244
+ }
245
+ try {
246
+ const response = await fetchAbsolute(url, { headers })
247
+ const result = await response.json()
248
+ if (result) {
249
+ //console.log('completed content', result);
250
+ return result
238
251
  } else {
239
- url = `/content/completed/${globalConfig.railcontentConfig.userId}?content_type=${type}&amp;brand=${brand}${limitString}${pageString}`;
240
- }
241
- const headers = {
242
- 'Content-Type': 'application/json',
243
- 'Accept': 'application/json',
244
- 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
245
- };
246
- try {
247
- const response = await fetchAbsolute(url, {headers});
248
- const result = await response.json();
249
- if (result) {
250
- //console.log('completed content', result);
251
- return result;
252
- } else {
253
- console.log('result not json');
254
- }
255
- } catch (error) {
256
- console.error('Fetch error:', error);
257
- return null;
252
+ console.log('result not json')
258
253
  }
254
+ } catch (error) {
255
+ console.error('Fetch error:', error)
256
+ return null
257
+ }
259
258
  }
260
259
 
261
-
262
260
  /**
263
261
  * Fetches user context data for a specific piece of content.
264
262
  *
@@ -270,26 +268,26 @@ export async function fetchCompletedContent(type = "all", brand, {page, limit} =
270
268
  * .catch(error => console.error(error));
271
269
  */
272
270
  export async function fetchContentPageUserData(contentId) {
273
- let url = `/content/${contentId}/user_data/${globalConfig.railcontentConfig.userId}`;
274
- const headers = {
275
- 'Content-Type': 'application/json',
276
- 'Accept': 'application/json',
277
- 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
278
- };
279
-
280
- try {
281
- const response = await fetchAbsolute(url, {headers});
282
- const result = await response.json();
283
- if (result) {
284
- console.log('fetchContentPageUserData', result);
285
- return result;
286
- } else {
287
- console.log('result not json');
288
- }
289
- } catch (error) {
290
- console.error('Fetch error:', error);
291
- return null;
271
+ let url = `/content/${contentId}/user_data/${globalConfig.railcontentConfig.userId}`
272
+ const headers = {
273
+ 'Content-Type': 'application/json',
274
+ Accept: 'application/json',
275
+ 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token,
276
+ }
277
+
278
+ try {
279
+ const response = await fetchAbsolute(url, { headers })
280
+ const result = await response.json()
281
+ if (result) {
282
+ console.log('fetchContentPageUserData', result)
283
+ return result
284
+ } else {
285
+ console.log('result not json')
292
286
  }
287
+ } catch (error) {
288
+ console.error('Fetch error:', error)
289
+ return null
290
+ }
293
291
  }
294
292
 
295
293
  /**
@@ -299,123 +297,130 @@ export async function fetchContentPageUserData(contentId) {
299
297
  * @returns {Promise&lt;Object|null>} - Returns and Object with the id and type of the next piece of content if found, otherwise null.
300
298
  */
301
299
  export async function fetchNextContentDataForParent(contentId) {
302
- let url = `/content/${contentId}/next/${globalConfig.railcontentConfig.userId}`;
303
- const headers = {
304
- 'Content-Type': 'application/json',
305
- 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token
306
- };
307
-
308
- try {
309
- const response = await fetchAbsolute(url, {headers});
310
- const result = await response.json();
311
- if (result) {
312
- // console.log('fetchNextContentDataForParent', result);
313
- return result.next;
314
- } else {
315
- console.log('fetchNextContentDataForParent result not json');
316
- return null;
317
- }
318
- } catch (error) {
319
- console.error('Fetch error:', error);
320
- return null;
300
+ let url = `/content/${contentId}/next/${globalConfig.railcontentConfig.userId}`
301
+ const headers = {
302
+ 'Content-Type': 'application/json',
303
+ 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token,
304
+ }
305
+
306
+ try {
307
+ const response = await fetchAbsolute(url, { headers })
308
+ const result = await response.json()
309
+ if (result) {
310
+ // console.log('fetchNextContentDataForParent', result);
311
+ return result.next
312
+ } else {
313
+ console.log('fetchNextContentDataForParent result not json')
314
+ return null
321
315
  }
316
+ } catch (error) {
317
+ console.error('Fetch error:', error)
318
+ return null
319
+ }
322
320
  }
323
321
 
324
-
325
322
  export async function fetchUserPermissionsData() {
326
- let url = `/content/user/permissions`;
327
- // in the case of an unauthorized user, we return empty permissions
328
- return await fetchHandler(url, 'get') ?? [];
323
+ let url = `/content/user/permissions`
324
+ // in the case of an unauthorized user, we return empty permissions
325
+ return (await fetchHandler(url, 'get')) ?? []
329
326
  }
330
327
 
331
- async function fetchDataHandler(url, dataVersion, method = "get") {
332
- return fetchHandler(url, method, dataVersion);
328
+ async function fetchDataHandler(url, dataVersion, method = 'get') {
329
+ return fetchHandler(url, method, dataVersion)
333
330
  }
334
331
 
335
332
  async function postDataHandler(url, data) {
336
- return fetchHandler(url, 'post', null, data);
333
+ return fetchHandler(url, 'post', null, data)
337
334
  }
338
335
 
339
336
  async function patchDataHandler(url, data) {
340
- return fetchHandler(url, 'patch', null, data);}
341
-
342
- export async function fetchHandler(url, method = "get", dataVersion = null, body = null) {
343
- let headers = {
344
- 'Content-Type': 'application/json',
345
- 'Accept': 'application/json',
346
- 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token,
347
- };
348
-
349
- if (!globalConfig.isMA) {
350
- const params = new URLSearchParams(window.location.search);
351
- if (params.get('testNow')) {
352
- headers['testNow'] = params.get('testNow');
353
- }
354
- if (params.get('timezone')) {
355
- headers['M-Client-Timezone'] = params.get('timezone');
356
- }
357
- }
358
-
359
- if (globalConfig.localTimezoneString) {
360
- headers['M-Client-Timezone'] = globalConfig.localTimezoneString;
361
- }
337
+ return fetchHandler(url, 'patch', null, data)
338
+ }
362
339
 
363
- if (globalConfig.railcontentConfig.authToken) {
364
- headers['Authorization'] = `Bearer ${globalConfig.railcontentConfig.authToken}`;
340
+ export async function fetchHandler(url, method = 'get', dataVersion = null, body = null) {
341
+ let headers = {
342
+ 'Content-Type': 'application/json',
343
+ Accept: 'application/json',
344
+ 'X-CSRF-TOKEN': globalConfig.railcontentConfig.token,
345
+ }
346
+
347
+ if (!globalConfig.isMA) {
348
+ const params = new URLSearchParams(window.location.search)
349
+ if (params.get('testNow')) {
350
+ headers['testNow'] = params.get('testNow')
365
351
  }
366
-
367
- if (dataVersion) headers['Data-Version'] = dataVersion;
368
- const options = {
369
- method,
370
- headers,
371
- };
372
- if (body) {
373
- options.body = JSON.stringify(body);
352
+ if (params.get('timezone')) {
353
+ headers['M-Client-Timezone'] = params.get('timezone')
374
354
  }
375
- try {
376
- const response = await fetchAbsolute(url, options);
377
- if (response.ok) {
378
- return await response.json();
379
- } else {
380
- console.error(`Fetch error: ${method} ${url} ${response.status} ${response.statusText}`);
381
- console.log(response);
382
- }
383
- } catch (error) {
384
- console.error('Fetch error:', error);
355
+ }
356
+
357
+ if (globalConfig.localTimezoneString) {
358
+ headers['M-Client-Timezone'] = globalConfig.localTimezoneString
359
+ }
360
+
361
+ if (globalConfig.railcontentConfig.authToken) {
362
+ headers['Authorization'] = `Bearer ${globalConfig.railcontentConfig.authToken}`
363
+ }
364
+
365
+ if (dataVersion) headers['Data-Version'] = dataVersion
366
+ const options = {
367
+ method,
368
+ headers,
369
+ }
370
+ if (body) {
371
+ options.body = JSON.stringify(body)
372
+ }
373
+ try {
374
+ const response = await fetchAbsolute(url, options)
375
+ if (response.ok) {
376
+ return await response.json()
377
+ } else {
378
+ console.error(`Fetch error: ${method} ${url} ${response.status} ${response.statusText}`)
379
+ console.log(response)
385
380
  }
386
- return null;
381
+ } catch (error) {
382
+ console.error('Fetch error:', error)
383
+ }
384
+ return null
387
385
  }
388
386
 
389
387
  export async function fetchUserLikes(currentVersion) {
390
- let url = `/content/user/likes/all`;
391
- return fetchDataHandler(url, currentVersion);
388
+ let url = `/content/user/likes/all`
389
+ return fetchDataHandler(url, currentVersion)
392
390
  }
393
391
 
394
392
  export async function postContentLiked(contentId) {
395
- let url = `/content/user/likes/like/${contentId}`;
396
- return await postDataHandler(url);
393
+ let url = `/content/user/likes/like/${contentId}`
394
+ return await postDataHandler(url)
397
395
  }
398
396
 
399
397
  export async function postContentUnliked(contentId) {
400
- let url = `/content/user/likes/unlike/${contentId}`;
401
- return await postDataHandler(url);
398
+ let url = `/content/user/likes/unlike/${contentId}`
399
+ return await postDataHandler(url)
402
400
  }
403
401
 
404
402
  export async function fetchContentProgress(currentVersion) {
405
- let url = `/content/user/progress/all`;
406
- return fetchDataHandler(url, currentVersion);
403
+ let url = `/content/user/progress/all`
404
+ return fetchDataHandler(url, currentVersion)
407
405
  }
408
406
 
409
- export async function postRecordWatchSession(contentId, mediaTypeId, mediaLengthSeconds, currentSeconds, secondsPlayed, sessionId) {
410
- let url = `/railtracker/v2/media-playback-session`;
411
- return postDataHandler(url, {
412
- "content_id": contentId,
413
- "media_type_id": mediaTypeId,
414
- "media_length_seconds": mediaLengthSeconds,
415
- "current_second": currentSeconds,
416
- "seconds_played": secondsPlayed,
417
- "session_id": sessionId
418
- });
407
+ export async function postRecordWatchSession(
408
+ contentId,
409
+ mediaTypeId,
410
+ mediaLengthSeconds,
411
+ currentSeconds,
412
+ secondsPlayed,
413
+ sessionId
414
+ ) {
415
+ let url = `/railtracker/v2/media-playback-session`
416
+ return postDataHandler(url, {
417
+ content_id: contentId,
418
+ media_type_id: mediaTypeId,
419
+ media_length_seconds: mediaLengthSeconds,
420
+ current_second: currentSeconds,
421
+ seconds_played: secondsPlayed,
422
+ session_id: sessionId,
423
+ })
419
424
  }
420
425
 
421
426
  /**
@@ -425,8 +430,8 @@ export async function postRecordWatchSession(contentId, mediaTypeId, mediaLength
425
430
  * @returns {Promise&lt;any|null>}
426
431
  */
427
432
  export async function fetchChallengeMetadata(contentId) {
428
- let url = `/challenges/${contentId}`;
429
- return await fetchHandler(url, 'get');
433
+ let url = `/challenges/${contentId}`
434
+ return await fetchHandler(url, 'get')
430
435
  }
431
436
 
432
437
  /**
@@ -436,11 +441,10 @@ export async function fetchChallengeMetadata(contentId) {
436
441
  * @returns {Promise&lt;any|null>}
437
442
  */
438
443
  export async function fetchChallengeLessonData(contentId) {
439
- let url = `/challenges/lessons/${contentId}`;
440
- return await fetchHandler(url, 'get');
444
+ let url = `/challenges/lessons/${contentId}`
445
+ return await fetchHandler(url, 'get')
441
446
  }
442
447
 
443
-
444
448
  /**
445
449
  * Fetch all owned brand challenges for user
446
450
  * @param {string|null} brand - brand
@@ -449,10 +453,10 @@ export async function fetchChallengeLessonData(contentId) {
449
453
  * @returns {Promise&lt;any|null>}
450
454
  */
451
455
  export async function fetchOwnedChallenges(brand = null, page, limit) {
452
- let brandParam = brand ? `&amp;brand=${brand}` : '';
453
- let pageAndLimit = `?page=${page}&amp;limit=${limit}`;
454
- let url = `/challenges/tab_owned/get${pageAndLimit}${brandParam}`;
455
- return await fetchHandler(url, 'get');
456
+ let brandParam = brand ? `&amp;brand=${brand}` : ''
457
+ let pageAndLimit = `?page=${page}&amp;limit=${limit}`
458
+ let url = `/challenges/tab_owned/get${pageAndLimit}${brandParam}`
459
+ return await fetchHandler(url, 'get')
456
460
  }
457
461
 
458
462
  /**
@@ -463,13 +467,12 @@ export async function fetchOwnedChallenges(brand = null, page, limit) {
463
467
  * @returns {Promise&lt;any|null>}
464
468
  */
465
469
  export async function fetchCompletedChallenges(brand = null, page, limit) {
466
- let brandParam = brand ? `&amp;brand=${brand}` : '';
467
- let pageAndLimit = `?page=${page}&amp;limit=${limit}`;
468
- let url = `/challenges/tab_completed/get${pageAndLimit}${brandParam}`;
469
- return await fetchHandler(url, 'get');
470
+ let brandParam = brand ? `&amp;brand=${brand}` : ''
471
+ let pageAndLimit = `?page=${page}&amp;limit=${limit}`
472
+ let url = `/challenges/tab_completed/get${pageAndLimit}${brandParam}`
473
+ return await fetchHandler(url, 'get')
470
474
  }
471
475
 
472
-
473
476
  /**
474
477
  * Fetch challenge, lesson, and user metadata for a given challenge
475
478
  *
@@ -477,8 +480,8 @@ export async function fetchCompletedChallenges(brand = null, page, limit) {
477
480
  * @returns {Promise&lt;any|null>}
478
481
  */
479
482
  export async function fetchUserChallengeProgress(contentId) {
480
- let url = `/challenges/user_data/${contentId}`;
481
- return await fetchHandler(url, 'get');
483
+ let url = `/challenges/user_data/${contentId}`
484
+ return await fetchHandler(url, 'get')
482
485
  }
483
486
 
484
487
  /**
@@ -488,8 +491,8 @@ export async function fetchUserChallengeProgress(contentId) {
488
491
  * @returns {Promise&lt;any|null>} - streamed PDF
489
492
  */
490
493
  export async function fetchUserAward(contentId) {
491
- let url = `/challenges/download_award/${contentId}`;
492
- return await fetchHandler(url, 'get');
494
+ let url = `/challenges/download_award/${contentId}`
495
+ return await fetchHandler(url, 'get')
493
496
  }
494
497
 
495
498
  /**
@@ -500,35 +503,34 @@ export async function fetchUserAward(contentId) {
500
503
  * @returns {Promise&lt;any|null>}
501
504
  */
502
505
  export async function fetchChallengeIndexMetadata(contentIds) {
503
- if (!challengeIndexMetaDataPromise) {
504
- challengeIndexMetaDataPromise = getChallengeIndexMetadataPromise();
505
- }
506
- let results = await challengeIndexMetaDataPromise;
507
- if(Array.isArray(contentIds)){
508
- results = results.filter(function(challenge){
509
- return contentIds.includes(challenge.content_id);
510
- });
511
- }
512
- return results;
506
+ if (!challengeIndexMetaDataPromise) {
507
+ challengeIndexMetaDataPromise = getChallengeIndexMetadataPromise()
508
+ }
509
+ let results = await challengeIndexMetaDataPromise
510
+ if (Array.isArray(contentIds)) {
511
+ results = results.filter(function (challenge) {
512
+ return contentIds.includes(challenge.content_id)
513
+ })
514
+ }
515
+ return results
513
516
  }
514
517
 
515
518
  async function getChallengeIndexMetadataPromise() {
516
- let url = `/challenges/user_progress_for_index_page/get`;
517
- const result = await fetchHandler(url, 'get');
518
- challengeIndexMetaDataPromise = null;
519
- return result;
519
+ let url = `/challenges/user_progress_for_index_page/get`
520
+ const result = await fetchHandler(url, 'get')
521
+ challengeIndexMetaDataPromise = null
522
+ return result
520
523
  }
521
524
 
522
-
523
525
  /**
524
526
  * Get active brand challenges for the authorized user
525
527
  *
526
528
  * @returns {Promise&lt;any|null>}
527
529
  */
528
530
  export async function fetchChallengeUserActiveChallenges(brand = null) {
529
- let brandParam = brand ? `?brand=${brand}` : '';
530
- let url = `/challenges/user_active_challenges/get${brandParam}`;
531
- return await fetchHandler(url, 'get');
531
+ let brandParam = brand ? `?brand=${brand}` : ''
532
+ let url = `/challenges/user_active_challenges/get${brandParam}`
533
+ return await fetchHandler(url, 'get')
532
534
  }
533
535
 
534
536
  /**
@@ -537,9 +539,9 @@ export async function fetchChallengeUserActiveChallenges(brand = null) {
537
539
  * @returns {Promise&lt;any|null>}
538
540
  */
539
541
  export async function fetchCarouselCardData(brand = null) {
540
- const brandParam = brand ? `?brand=${brand}` : '';
541
- let url = `/api/v1/content/carousel${brandParam}`;
542
- return await fetchHandler(url, 'get');
542
+ const brandParam = brand ? `?brand=${brand}` : ''
543
+ let url = `/api/v2/content/carousel${brandParam}`
544
+ return await fetchHandler(url, 'get')
543
545
  }
544
546
 
545
547
  /**
@@ -549,9 +551,9 @@ export async function fetchCarouselCardData(brand = null) {
549
551
  * @returns {Promise&lt;any|null>}
550
552
  */
551
553
  export async function fetchUserBadges(brand = null) {
552
- let brandParam = brand ? `?brand=${brand}` : '';
553
- let url = `/challenges/user_badges/get${brandParam}`;
554
- return await fetchHandler(url, 'get');
554
+ let brandParam = brand ? `?brand=${brand}` : ''
555
+ let url = `/challenges/user_badges/get${brandParam}`
556
+ return await fetchHandler(url, 'get')
555
557
  }
556
558
 
557
559
  /**
@@ -563,8 +565,8 @@ export async function fetchUserBadges(brand = null) {
563
565
  * @returns {Promise&lt;any|null>}
564
566
  */
565
567
  export async function postChallengesSetStartDate(contentId, startDate) {
566
- let url = `/challenges/set_start_date/${contentId}?start_date=${startDate}`;
567
- return await fetchHandler(url, 'post');
568
+ let url = `/challenges/set_start_date/${contentId}?start_date=${startDate}`
569
+ return await fetchHandler(url, 'post')
568
570
  }
569
571
 
570
572
  /**
@@ -575,8 +577,8 @@ export async function postChallengesSetStartDate(contentId, startDate) {
575
577
  * @returns {Promise&lt;any|null>}
576
578
  */
577
579
  export async function postChallengesUnlock(contentId) {
578
- let url = `/challenges/unlock/${contentId}`;
579
- return await fetchHandler(url, 'post');
580
+ let url = `/challenges/unlock/${contentId}`
581
+ return await fetchHandler(url, 'post')
580
582
  }
581
583
 
582
584
  /**
@@ -587,8 +589,8 @@ export async function postChallengesUnlock(contentId) {
587
589
  * @returns {Promise&lt;any|null>}
588
590
  */
589
591
  export async function postChallengesEnroll(contentId) {
590
- let url = `/challenges/enroll/${contentId}`;
591
- return await fetchHandler(url, 'post');
592
+ let url = `/challenges/enroll/${contentId}`
593
+ return await fetchHandler(url, 'post')
592
594
  }
593
595
 
594
596
  /**
@@ -599,8 +601,8 @@ export async function postChallengesEnroll(contentId) {
599
601
  * @returns {Promise&lt;any|null>}
600
602
  */
601
603
  export async function postChallengesLeave(contentId) {
602
- let url = `/challenges/leave/${contentId}`;
603
- return await fetchHandler(url, 'post');
604
+ let url = `/challenges/leave/${contentId}`
605
+ return await fetchHandler(url, 'post')
604
606
  }
605
607
 
606
608
  /**
@@ -610,8 +612,8 @@ export async function postChallengesLeave(contentId) {
610
612
  * @returns {Promise&lt;any|null>}
611
613
  */
612
614
  export async function postChallengesEnrollmentNotification(contentId) {
613
- let url = `/challenges/notifications/enrollment_open/${contentId}`;
614
- return await fetchHandler(url, 'post');
615
+ let url = `/challenges/notifications/enrollment_open/${contentId}`
616
+ return await fetchHandler(url, 'post')
615
617
  }
616
618
 
617
619
  /**
@@ -621,8 +623,8 @@ export async function postChallengesEnrollmentNotification(contentId) {
621
623
  * @returns {Promise&lt;any|null>}
622
624
  */
623
625
  export async function postChallengesCommunityNotification(contentId) {
624
- let url = `/challenges/notifications/community_reminders/${contentId}`;
625
- return await fetchHandler(url, 'post');
626
+ let url = `/challenges/notifications/community_reminders/${contentId}`
627
+ return await fetchHandler(url, 'post')
626
628
  }
627
629
 
628
630
  /**
@@ -632,8 +634,8 @@ export async function postChallengesCommunityNotification(contentId) {
632
634
  * @returns {Promise&lt;any|null>}
633
635
  */
634
636
  export async function postChallengesSoloNotification(contentId) {
635
- let url = `/challenges/notifications/solo_reminders/${contentId}`;
636
- return await fetchHandler(url, 'post');
637
+ let url = `/challenges/notifications/solo_reminders/${contentId}`
638
+ return await fetchHandler(url, 'post')
637
639
  }
638
640
 
639
641
  /**
@@ -643,9 +645,9 @@ export async function postChallengesSoloNotification(contentId) {
643
645
  * @returns {Promise&lt;any|null>} - Modal data to display
644
646
  */
645
647
  export async function postChallengesCompleteLesson(contentId) {
646
- let url = `/challenges/complete_lesson/${contentId}`;
647
- await contentStatusCompleted(contentId);
648
- return await fetchHandler(url, 'post');
648
+ let url = `/challenges/complete_lesson/${contentId}`
649
+ await contentStatusCompleted(contentId)
650
+ return await fetchHandler(url, 'post')
649
651
  }
650
652
 
651
653
  /**
@@ -655,8 +657,8 @@ export async function postChallengesCompleteLesson(contentId) {
655
657
  * @returns {Promise&lt;any|null>}
656
658
  */
657
659
  export async function postChallengesHideCompletedBanner(contentId) {
658
- let url = `/challenges/hide_completed_banner/${contentId}`;
659
- return await fetchHandler(url, 'post');
660
+ let url = `/challenges/hide_completed_banner/${contentId}`
661
+ return await fetchHandler(url, 'post')
660
662
  }
661
663
 
662
664
  /**
@@ -678,18 +680,20 @@ export async function postChallengesHideCompletedBanner(contentId) {
678
680
  * .then(playlists => console.log(playlists))
679
681
  * .catch(error => console.error(error));
680
682
  */
681
- export async function fetchUserPlaylists(brand, {page, limit, sort, searchTerm, content_id, categories} = {}) {
682
- let url;
683
- const limitString = limit ? `&amp;limit=${limit}` : '';
684
- const pageString = page ? `&amp;page=${page}` : '';
685
- const sortString = sort ? `&amp;sort=${sort}` : '';
686
- const searchFilter = searchTerm ? `&amp;term=${searchTerm}` : '';
687
- const content = content_id ? `&amp;content_id=${content_id}` : '';
688
- const categoryString = categories &amp;&amp; categories.length
689
- ? categories.map(cat => `categories[]=${cat}`).join('&amp;')
690
- : '';
691
- url = `/playlists/all?brand=${brand}${limitString}${pageString}${sortString}${searchFilter}${content}${categoryString ? `&amp;${categoryString}` : ''}`;
692
- return await fetchHandler(url);
683
+ export async function fetchUserPlaylists(
684
+ brand,
685
+ { page, limit, sort, searchTerm, content_id, categories } = {}
686
+ ) {
687
+ let url
688
+ const limitString = limit ? `&amp;limit=${limit}` : ''
689
+ const pageString = page ? `&amp;page=${page}` : ''
690
+ const sortString = sort ? `&amp;sort=${sort}` : ''
691
+ const searchFilter = searchTerm ? `&amp;term=${searchTerm}` : ''
692
+ const content = content_id ? `&amp;content_id=${content_id}` : ''
693
+ const categoryString =
694
+ categories &amp;&amp; categories.length ? categories.map((cat) => `categories[]=${cat}`).join('&amp;') : ''
695
+ url = `/playlists/all?brand=${brand}${limitString}${pageString}${sortString}${searchFilter}${content}${categoryString ? `&amp;${categoryString}` : ''}`
696
+ return await fetchHandler(url)
693
697
  }
694
698
 
695
699
  /**
@@ -721,8 +725,8 @@ export async function fetchUserPlaylists(brand, {page, limit, sort, searchTerm,
721
725
  * .catch(error => console.error('Error duplicating playlist:', error));
722
726
  */
723
727
  export async function duplicatePlaylist(playlistId, playlistData) {
724
- let url = `/playlists/duplicate/${playlistId}`;
725
- return await fetchHandler(url, "post", null, playlistData);
728
+ let url = `/playlists/duplicate/${playlistId}`
729
+ return await fetchHandler(url, 'post', null, playlistData)
726
730
  }
727
731
 
728
732
  /**
@@ -749,8 +753,8 @@ export async function duplicatePlaylist(playlistId, playlistData) {
749
753
  * .catch(error => console.error('Error deleting playlist:', error));
750
754
  */
751
755
  export async function deletePlaylist(playlistId) {
752
- let url = `/playlists/playlist/${playlistId}`;
753
- return await fetchHandler(url, "delete");
756
+ let url = `/playlists/playlist/${playlistId}`
757
+ return await fetchHandler(url, 'delete')
754
758
  }
755
759
 
756
760
  /**
@@ -784,8 +788,8 @@ export async function deletePlaylist(playlistId) {
784
788
  * .catch(error => console.error('Error updating playlist:', error));
785
789
  */
786
790
  export async function updatePlaylist(playlistId, updatedData) {
787
- const url = `/playlists/playlist/${playlistId}`;
788
- return await fetchHandler(url, "PUT", null, updatedData);
791
+ const url = `/playlists/playlist/${playlistId}`
792
+ return await fetchHandler(url, 'PUT', null, updatedData)
789
793
  }
790
794
 
791
795
  /**
@@ -814,8 +818,8 @@ export async function updatePlaylist(playlistId, updatedData) {
814
818
  * .catch(error => console.error('Error creating playlist:', error));
815
819
  */
816
820
  export async function createPlaylist(playlistData) {
817
- const url = `/playlists/playlist`;
818
- return await fetchHandler(url, "POST", null, playlistData);
821
+ const url = `/playlists/playlist`
822
+ return await fetchHandler(url, 'POST', null, playlistData)
819
823
  }
820
824
 
821
825
  /**
@@ -847,9 +851,9 @@ export async function createPlaylist(playlistData) {
847
851
  * .catch(error => console.error('Error liking playlist:', error));
848
852
  */
849
853
  export async function likePlaylist(playlistId) {
850
- const url = `/playlists/like`;
851
- const payload = {playlist_id: playlistId};
852
- return await fetchHandler(url, "PUT", null, payload);
854
+ const url = `/playlists/like`
855
+ const payload = { playlist_id: playlistId }
856
+ return await fetchHandler(url, 'PUT', null, payload)
853
857
  }
854
858
 
855
859
  /**
@@ -874,9 +878,9 @@ export async function likePlaylist(playlistId) {
874
878
  * .catch(error => console.error('Error removing playlist like:', error));
875
879
  */
876
880
  export async function deletePlaylistLike(playlistId) {
877
- const url = `/playlists/like`;
878
- const payload = {playlist_id: playlistId};
879
- return await fetchHandler(url, "DELETE", null, payload);
881
+ const url = `/playlists/like`
882
+ const payload = { playlist_id: playlistId }
883
+ return await fetchHandler(url, 'DELETE', null, payload)
880
884
  }
881
885
 
882
886
  /**
@@ -896,8 +900,8 @@ export async function deletePlaylistLike(playlistId) {
896
900
  * .catch(error => console.error('Error fetching playlist:', error));
897
901
  */
898
902
  export async function fetchPlaylist(playlistId) {
899
- const url = `/playlists/playlist/${playlistId}`;
900
- return await fetchHandler(url, "GET");
903
+ const url = `/playlists/playlist/${playlistId}`
904
+ return await fetchHandler(url, 'GET')
901
905
  }
902
906
 
903
907
  /**
@@ -915,10 +919,10 @@ export async function fetchPlaylist(playlistId) {
915
919
  * .then(items => console.log(items))
916
920
  * .catch(error => console.error('Error fetching playlist items:', error));
917
921
  */
918
- export async function fetchPlaylistItems(playlistId, {sort} = {}) {
919
- const sortString = sort ? `&amp;sort=${sort}` : '';
920
- const url = `/playlists/playlist-lessons?playlist_id=${playlistId}${sortString}`;
921
- return await fetchHandler(url, "GET");
922
+ export async function fetchPlaylistItems(playlistId, { sort } = {}) {
923
+ const sortString = sort ? `&amp;sort=${sort}` : ''
924
+ const url = `/playlists/playlist-lessons?playlist_id=${playlistId}${sortString}`
925
+ return await fetchHandler(url, 'GET')
922
926
  }
923
927
 
924
928
  /**
@@ -957,8 +961,8 @@ export async function fetchPlaylistItems(playlistId, {sort} = {}) {
957
961
  * });
958
962
  */
959
963
  export async function updatePlaylistItem(updatedData) {
960
- const url = `/playlists/item`;
961
- return await fetchHandler(url, "POST", null, updatedData);
964
+ const url = `/playlists/item`
965
+ return await fetchHandler(url, 'POST', null, updatedData)
962
966
  }
963
967
 
964
968
  /**
@@ -992,8 +996,8 @@ export async function updatePlaylistItem(updatedData) {
992
996
  * });
993
997
  */
994
998
  export async function deletePlaylistItem(payload) {
995
- const url = `/playlists/item`;
996
- return await fetchHandler(url, "DELETE", null, payload);
999
+ const url = `/playlists/item`
1000
+ return await fetchHandler(url, 'DELETE', null, payload)
997
1001
  }
998
1002
 
999
1003
  /**
@@ -1024,19 +1028,19 @@ export async function deletePlaylistItem(payload) {
1024
1028
  * });
1025
1029
  */
1026
1030
  export async function fetchPlaylistItem(payload) {
1027
- const playlistItemId = payload.user_playlist_item_id;
1028
- const url = `/playlists/item/${playlistItemId}`;
1029
- return await fetchHandler(url);
1031
+ const playlistItemId = payload.user_playlist_item_id
1032
+ const url = `/playlists/item/${playlistItemId}`
1033
+ return await fetchHandler(url)
1030
1034
  }
1031
1035
 
1032
1036
  export async function postContentCompleted(contentId) {
1033
- let url = `/content/user/progress/complete`;
1034
- return postDataHandler(url, {"contentId": contentId});
1037
+ let url = `/content/user/progress/complete`
1038
+ return postDataHandler(url, { contentId: contentId })
1035
1039
  }
1036
1040
 
1037
1041
  export async function postContentReset(contentId) {
1038
- let url = `/content/user/progress/reset`;
1039
- return postDataHandler(url, {"contentId": contentId});
1042
+ let url = `/content/user/progress/reset`
1043
+ return postDataHandler(url, { contentId: contentId })
1040
1044
  }
1041
1045
 
1042
1046
  /**
@@ -1080,8 +1084,8 @@ export async function postContentReset(contentId) {
1080
1084
  * });
1081
1085
  */
1082
1086
  export async function addItemToPlaylist(payload) {
1083
- const url = `/playlists/add-item`;
1084
- return await fetchHandler(url, "POST", null, payload);
1087
+ const url = `/playlists/add-item`
1088
+ return await fetchHandler(url, 'POST', null, payload)
1085
1089
  }
1086
1090
 
1087
1091
  /**
@@ -1110,8 +1114,8 @@ export async function addItemToPlaylist(payload) {
1110
1114
  * });
1111
1115
  */
1112
1116
  export async function countAssignmentsAndLessons(contentId) {
1113
- const url = `/playlists/count-lessons-and-assignments/${contentId}`;
1114
- return await fetchHandler(url);
1117
+ const url = `/playlists/count-lessons-and-assignments/${contentId}`
1118
+ return await fetchHandler(url)
1115
1119
  }
1116
1120
 
1117
1121
  /**
@@ -1142,8 +1146,8 @@ export async function countAssignmentsAndLessons(contentId) {
1142
1146
  * });
1143
1147
  */
1144
1148
  export async function pinPlaylist(playlistId) {
1145
- const url = `/playlists/pin/${playlistId}`;
1146
- return await fetchHandler(url, "PUT");
1149
+ const url = `/playlists/pin/${playlistId}`
1150
+ return await fetchHandler(url, 'PUT')
1147
1151
  }
1148
1152
 
1149
1153
  /**
@@ -1174,8 +1178,8 @@ export async function pinPlaylist(playlistId) {
1174
1178
  * });
1175
1179
  */
1176
1180
  export async function unpinPlaylist(playlistId) {
1177
- const url = `/playlists/unpin/${playlistId}`;
1178
- return await fetchHandler(url, "PUT");
1181
+ const url = `/playlists/unpin/${playlistId}`
1182
+ return await fetchHandler(url, 'PUT')
1179
1183
  }
1180
1184
 
1181
1185
  /**
@@ -1206,26 +1210,26 @@ export async function unpinPlaylist(playlistId) {
1206
1210
  * });
1207
1211
  */
1208
1212
  export async function fetchPinnedPlaylists(brand) {
1209
- const url = `/playlists/my-pinned-playlists?brand=${brand}`;
1210
- return await fetchHandler(url, "GET");
1213
+ const url = `/playlists/my-pinned-playlists?brand=${brand}`
1214
+ return await fetchHandler(url, 'GET')
1211
1215
  }
1212
1216
 
1213
1217
  /**
1214
1218
  * Report playlist endpoint
1215
- *
1219
+ *
1216
1220
  * @param playlistId
1217
1221
  * @param issue
1218
1222
  * @returns {Promise&lt;any|null>}
1219
1223
  */
1220
- export async function reportPlaylist(playlistId, {issue} = {}) {
1221
- const issueString = issue ? `?issue=${issue}` : '';
1222
- const url = `/playlists/report/${playlistId}${issueString}`;
1223
- return await fetchHandler(url, "PUT");
1224
+ export async function reportPlaylist(playlistId, { issue } = {}) {
1225
+ const issueString = issue ? `?issue=${issue}` : ''
1226
+ const url = `/playlists/report/${playlistId}${issueString}`
1227
+ return await fetchHandler(url, 'PUT')
1224
1228
  }
1225
1229
 
1226
1230
  export async function playback(playlistId) {
1227
- const url = `/playlists/play/${playlistId}`;
1228
- return await fetchHandler(url, "GET");
1231
+ const url = `/playlists/play/${playlistId}`
1232
+ return await fetchHandler(url, 'GET')
1229
1233
  }
1230
1234
 
1231
1235
  /**
@@ -1236,22 +1240,22 @@ export async function playback(playlistId) {
1236
1240
  * @returns {Promise&lt;any|null>}
1237
1241
  */
1238
1242
  export async function setStudentViewForUser(userId, enable) {
1239
- let url = `/user-management-system/user/update/${userId}`;
1240
- let data = {'use_student_view' : enable ? 1 : 0};
1241
- return await patchDataHandler(url, data);
1243
+ let url = `/user-management-system/user/update/${userId}`
1244
+ let data = { use_student_view: enable ? 1 : 0 }
1245
+ return await patchDataHandler(url, data)
1242
1246
  }
1243
1247
 
1244
1248
  function fetchAbsolute(url, params) {
1245
- if (globalConfig.railcontentConfig.authToken) {
1246
- params.headers['Authorization'] = `Bearer ${globalConfig.railcontentConfig.authToken}`;
1247
- }
1249
+ if (globalConfig.railcontentConfig.authToken) {
1250
+ params.headers['Authorization'] = `Bearer ${globalConfig.railcontentConfig.authToken}`
1251
+ }
1248
1252
 
1249
- if (globalConfig.railcontentConfig.baseUrl) {
1250
- if (url.startsWith('/')) {
1251
- return fetch(globalConfig.railcontentConfig.baseUrl + url, params)
1252
- }
1253
+ if (globalConfig.railcontentConfig.baseUrl) {
1254
+ if (url.startsWith('/')) {
1255
+ return fetch(globalConfig.railcontentConfig.baseUrl + url, params)
1253
1256
  }
1254
- return fetch(url, params);
1257
+ }
1258
+ return fetch(url, params)
1255
1259
  }
1256
1260
  </code></pre>
1257
1261
  </article>
@@ -1267,7 +1271,7 @@ function fetchAbsolute(url, params) {
1267
1271
  <br class="clear">
1268
1272
 
1269
1273
  <footer>
1270
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Mon Jan 20 2025 08:04:00 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1274
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Fri Feb 21 2025 20:42:51 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1271
1275
  </footer>
1272
1276
 
1273
1277
  <script>prettyPrint();</script>