Members
(inner, constant) excludeFromGeneratedIndex :Array.<string>
- Description:
- Exported functions that are excluded from index generation.
- Source:
Exported functions that are excluded from index generation.
Type:
Methods
(static) addItemToPlaylist(payload) → {Promise.<(Object|null)>}
- Description:
- Adds an item to one or more playlists by making a POST request to the `/playlists/add-item` endpoint.
- Source:
Example
const payload = {
content_id: 123,
playlist_id: [1, 2, 3],
import_all_assignments: true
};
addItemToPlaylist(payload)
.then(response => {
if (response?.success) {
console.log("Item(s) added to playlist successfully");
}
if (response?.limit_excedeed) {
console.warn("Some playlists exceeded the item limit:", response.limit_excedeed);
}
})
.catch(error => {
console.error("Error adding item to playlist:", error);
});
Parameters:
Name |
Type |
Description |
payload |
Object
|
The request payload containing necessary parameters.
Properties
Name |
Type |
Attributes |
Default |
Description |
content_id |
number
|
|
|
The ID of the content to add to the playlist(s). |
playlist_id |
Array.<number>
|
|
|
An array of playlist IDs where the content should be added. |
import_full_soundslice_assignment |
boolean
|
<optional>
|
false
|
Flag to include full Soundslice assignments. |
import_instrumentless_soundslice_assignment |
boolean
|
<optional>
|
false
|
Flag to include instrumentless Soundslice assignments. |
import_high_routine |
boolean
|
<optional>
|
false
|
Flag to include high routine content. |
import_low_routine |
boolean
|
<optional>
|
false
|
Flag to include low routine content. |
import_all_assignments |
boolean
|
<optional>
|
false
|
Flag to include all Soundslice assignments if true. |
|
Throws:
-
- Throws an error if the request encounters issues during the operation.
-
-
Type
-
Error
Returns:
- A promise that resolves to an object with the response data, including:
- `success` (boolean): Indicates if the items were added successfully (`true` on success).
- `limit_excedeed` (Array): A list of playlists where the item limit was exceeded, if any.
- `successful` (Array): A list of successfully added items (empty if none).
Resolves to `null` if the request fails.
-
Type
-
Promise.<(Object|null)>
(static) countAssignmentsAndLessons(contentId) → {Promise.<(Object|null)>}
- Description:
- Retrieves the count of lessons and assignments associated with a specific content ID.
- Source:
Example
const contentId = 123;
countAssignmentsAndLessons(contentId)
.then(response => {
if (response) {
console.log("Lessons count:", response.lessons_count);
console.log("Soundslice assignments count:", response.soundslice_assignments_count);
} else {
console.log("Failed to retrieve counts.");
}
})
.catch(error => {
console.error("Error fetching assignments and lessons count:", error);
});
Parameters:
Name |
Type |
Description |
contentId |
number
|
The ID of the content for which to count lessons and assignments. |
Returns:
- A promise that resolves to an object containing the counts:
- `lessons_count` (number): The number of lessons associated with the content.
- `soundslice_assignments_count` (number): The number of Soundslice assignments associated with the content.
-
Type
-
Promise.<(Object|null)>
(static) createPlaylist(playlistData) → {Promise.<Object>}
- Description:
- Creates a new user playlist by sending a POST request with playlist data to the API.
This function calls the `/playlists/playlist` endpoint, where the server validates the incoming data and associates
the new playlist with the authenticated user. The `name` field is required, while other fields are optional.
- Source:
Example
createPlaylist({ name: "My Playlist", description: "A cool playlist", private: true })
.then(response => console.log(response.message))
.catch(error => console.error('Error creating playlist:', error));
Parameters:
Name |
Type |
Description |
playlistData |
Object
|
An object containing data to create the playlist. The fields include:
- `name` (string): The name of the new playlist (required, max 255 characters).
- `description` (string): A description of the playlist (optional, max 1000 characters).
- `category` (string): The category of the playlist.
- `thumbnail_url` (string): The URL of the playlist thumbnail (optional, must be a valid URL).
- `private` (boolean): Whether the playlist is private (optional, defaults to true).
- `brand` (string): Brand identifier for the playlist. |
Returns:
- A promise that resolves to the created playlist data if successful, or an error response if validation fails.
The server response includes:
- `message`: Success message indicating playlist creation (e.g., "Playlist created successfully").
- `playlist`: The data for the created playlist, including the `user_id` of the authenticated user.
-
Type
-
Promise.<Object>
(static) deletePlaylist(playlistId) → {Promise.<Object>}
- Description:
- Deletes a user’s playlist along with all associated items by sending a DELETE request to the API.
This function calls the `/playlists/playlist` endpoint, where the server verifies the user’s ownership of the specified playlist.
If the user is authorized, it deletes both the playlist and its associated items.
- Source:
Example
deletePlaylist(12345)
.then(response => {
if (response.success) {
console.log(response.message);
}
})
.catch(error => console.error('Error deleting playlist:', error));
Parameters:
Name |
Type |
Description |
playlistId |
string
|
number
|
The unique identifier of the playlist to be deleted. |
Returns:
- A promise that resolves to an object containing:
- `success` (boolean): Indicates if the deletion was successful (`true` for success).
- `message` (string): Success confirmation message (e.g., "Playlist and associated items deleted successfully").
If the user is unauthorized or the playlist does not exist, the promise rejects with an error.
-
Type
-
Promise.<Object>
(static) deletePlaylistItem(payload) → {Promise.<(Object|null)>}
- Description:
- Deletes a playlist item and repositions other items in the playlist if necessary.
- Source:
Example
const payload = {
user_playlist_item_id: 123
};
deletePlaylistItem(payload)
.then(response => {
if (response.success) {
console.log("Playlist item deleted successfully:", response.message);
} else {
console.error("Error:", response.error);
}
})
.catch(error => {
console.error("Error deleting playlist item:", error);
});
Parameters:
Name |
Type |
Description |
payload |
Object
|
The data required to delete the playlist item.
Properties
Name |
Type |
Description |
user_playlist_item_id |
number
|
The ID of the playlist item to delete. |
|
Throws:
-
- Throws an error if the request fails.
-
-
Type
-
Error
Returns:
- A promise that resolves to an object containing:
- `success` (boolean): Indicates if the deletion was successful (`true` for success).
- `message` (string): A success message if the item is deleted successfully.
- `error` (string): An error message if the deletion fails.
Resolves to `null` if the request fails.
-
Type
-
Promise.<(Object|null)>
(static) deletePlaylistLike(playlistId) → {Promise.<Object>}
- Description:
- Removes a "like" from a playlist for the authenticated user.
This function sends a DELETE request to the `/playlists/like` endpoint, where the server validates the `playlist_id`
and checks if a like by the authenticated user already exists for the specified playlist. If so, it deletes the like.
- Source:
Example
deletePlaylistLike(12345)
.then(response => {
if (response.success) {
console.log(response.message);
}
})
.catch(error => console.error('Error removing playlist like:', error));
Parameters:
Name |
Type |
Description |
playlistId |
string
|
number
|
The unique identifier of the playlist whose like is to be removed. |
Returns:
- A promise that resolves with the response from the API. The response contains:
- `success` (boolean): Indicates if the removal was successful (`true` for success).
- `message` (string): A success message if the playlist like is removed successfully or a notification if the playlist was not previously liked.
-
Type
-
Promise.<Object>
(static) duplicatePlaylist(playlistId, playlistDataopt) → {Promise.<Object>}
- Description:
- Duplicates an existing playlist by sending a POST request to the API.
This function calls the `/playlists/duplicate` endpoint, where the server replicates the specified playlist,
including its items. Optionally, new `name`, `description`, `category`, or `thumbnail_url` parameters can be provided
to customize the duplicated playlist. If a new name is not provided, the server appends " (Duplicate)" to the original name.
- Source:
Example
duplicatePlaylist(12345, { name: "My New Playlist" })
.then(duplicatedPlaylist => console.log(duplicatedPlaylist))
.catch(error => console.error('Error duplicating playlist:', error));
Parameters:
Name |
Type |
Attributes |
Description |
playlistId |
string
|
number
|
|
The unique identifier of the playlist to be duplicated. |
playlistData |
Object
|
<optional>
|
Optional data to customize the duplicated playlist.
Properties
Name |
Type |
Attributes |
Description |
name |
string
|
<optional>
|
New name for the duplicated playlist (default is original name + " (Duplicate)"). |
description |
string
|
<optional>
|
New description for the duplicated playlist (defaults to original description). |
category |
string
|
<optional>
|
New category for the duplicated playlist (defaults to original category). |
thumbnail_url |
string
|
<optional>
|
New URL for the duplicated playlist thumbnail (defaults to original thumbnail). |
|
Returns:
- A promise that resolves to the duplicated playlist data, or rejects with an error if the duplication fails.
The duplicated playlist contains:
- `name` (string): Name of the new playlist.
- `description` (string|null): Description of the duplicated playlist.
- `category` (string|null): Category of the duplicated playlist.
- `thumbnail_url` (string|null): URL of the playlist thumbnail.
- `items` (Array): A list of items (e.g., songs, tracks) copied from the original playlist.
-
Type
-
Promise.<Object>
(static) fetchAllCompletedStates(contentIds) → {Promise.<(Object|null)>}
- Description:
- Fetches the completion status for multiple songs for the current user.
- Source:
Example
fetchAllCompletedStates('user123', ['song456', 'song789'], 'csrf-token')
.then(statuses => console.log(statuses))
.catch(error => console.error(error));
Parameters:
Name |
Type |
Description |
contentIds |
Array.<string>
|
An array of content IDs to check. |
Returns:
- Returns an object containing completion statuses keyed by content ID, or null if an error occurs.
-
Type
-
Promise.<(Object|null)>
(static) fetchCarouselCardData() → {Promise.<(any|null)>}
- Description:
- Fetch All Carousel Card Data
- Source:
Returns:
-
Type
-
Promise.<(any|null)>
- Description:
- Get challenge duration, user progress, and status for the list of challenges
Intended to be used on the index page for challenges
- Source:
Parameters:
Name |
Type |
Description |
contentIds |
array
|
arary of railcontent ids of the challenges |
Returns:
-
Type
-
Promise.<(any|null)>
(static) fetchChallengeLessonData(contentId) → {Promise.<(any|null)>}
- Description:
- Fetch lesson, user, and challenge data for a given lesson
- Source:
Parameters:
Name |
Type |
Description |
contentId |
|
railcontent id of the lesson |
Returns:
-
Type
-
Promise.<(any|null)>
- Description:
- Fetch enrolled user data for a given challenge. Intended to be used in the enrolled modal
- Source:
Parameters:
Name |
Type |
Description |
contentId |
|
railcontent id of the challenge |
Returns:
-
Type
-
Promise.<(any|null)>
(static) fetchChallengeUserActiveChallenges() → {Promise.<(any|null)>}
- Description:
- Get active brand challenges for the authorized user
- Source:
Returns:
-
Type
-
Promise.<(any|null)>
- Source:
Parameters:
Name |
Type |
Description |
commentId |
|
|
page |
|
|
limit |
|
|
Returns:
-
Type
-
Promise.<(*|null)>
- Source:
Parameters:
Name |
Type |
Description |
railcontentId |
|
|
page |
|
|
limit |
|
|
Returns:
-
Type
-
Promise.<(*|null)>
(static) fetchCompletedChallenges(brand, page, limit) → {Promise.<(any|null)>}
- Description:
- Fetch all completed brand challenges for user
- Source:
Parameters:
Name |
Type |
Description |
brand |
string
|
null
|
brand |
page |
int
|
page of data to pull |
limit |
int
|
number of elements to pull |
Returns:
-
Type
-
Promise.<(any|null)>
(static) fetchCompletedContent(type, brand) → {Promise.<(Object|null)>}
- Description:
- Fetches a list of content that has been completed for the current user.
- Source:
Example
fetchCompletedContent('song', 'drumeo')
.then(songs => console.log(songs))
.catch(error => console.error(error));
Parameters:
Name |
Type |
Attributes |
Default |
Description |
type |
string
|
|
|
The content type associated with the content. |
brand |
string
|
|
|
The brand associated with the content. |
params.limit |
number
|
<optional>
|
20
|
The limit of results per page. |
params.page |
number
|
<optional>
|
1
|
The page number for pagination. |
Returns:
- Returns an object containing in-progress content if found, otherwise null.
-
Type
-
Promise.<(Object|null)>
(static) fetchCompletedState(content_id) → {Promise.<(Object|null)>}
- Description:
- Fetches the completion status of a specific lesson for the current user.
- Source:
Example
fetchCurrentSongComplete('user123', 'lesson456', 'csrf-token')
.then(status => console.log(status))
.catch(error => console.error(error));
Parameters:
Name |
Type |
Description |
content_id |
string
|
The ID of the lesson content to check. |
Returns:
- Returns the completion status object if found, otherwise null.
-
Type
-
Promise.<(Object|null)>
(static) fetchContentInProgress(type, brand) → {Promise.<(Object|null)>}
- Description:
- Fetches a list of content that is currently in progress for the current user.
- Source:
Example
fetchContentInProgress('song', 'drumeo')
.then(songs => console.log(songs))
.catch(error => console.error(error));
Parameters:
Name |
Type |
Attributes |
Default |
Description |
type |
string
|
|
|
The content type associated with the content. |
brand |
string
|
|
|
The brand associated with the content. |
params.limit |
number
|
<optional>
|
20
|
The limit of results per page. |
params.page |
number
|
<optional>
|
1
|
The page number for pagination. |
Returns:
- Returns an object containing in-progress content if found, otherwise null.
-
Type
-
Promise.<(Object|null)>
(static) fetchContentPageUserData(contentId) → {Promise.<(Object|null)>}
- Description:
- Fetches user context data for a specific piece of content.
- Source:
Example
fetchContentPageUserData(406548)
.then(data => console.log(data))
.catch(error => console.error(error));
Parameters:
Name |
Type |
Description |
contentId |
int
|
The content id. |
Returns:
- Returns an object containing user context data if found, otherwise null.
-
Type
-
Promise.<(Object|null)>
(static) fetchNextContentDataForParent(contentId) → {Promise.<(Object|null)>}
- Description:
- Fetches the ID and Type of the piece of content that would be the next one for the user
- Source:
Parameters:
Name |
Type |
Description |
contentId |
int
|
The id of the parent (method, level, or course) piece of content. |
Returns:
- Returns and Object with the id and type of the next piece of content if found, otherwise null.
-
Type
-
Promise.<(Object|null)>
(static) fetchOwnedChallenges(brand, page, limit) → {Promise.<(any|null)>}
- Description:
- Fetch all owned brand challenges for user
- Source:
Parameters:
Name |
Type |
Description |
brand |
string
|
null
|
brand |
page |
int
|
page of data to pull |
limit |
int
|
number of elements to pull |
Returns:
-
Type
-
Promise.<(any|null)>
(static) fetchPinnedPlaylists(brand) → {Promise.<Object>}
- Description:
- Fetches the list of pinned playlists for the authenticated user.
- Source:
Example
const brand = "drumeo";
fetchPinnedPlaylists(brand)
.then(response => {
if (response.success) {
console.log("Pinned playlists:", response.data);
} else {
console.error("Error:", response.error);
}
})
.catch(error => {
console.error("Error fetching pinned playlists:", error);
});
Parameters:
Name |
Type |
Description |
brand |
string
|
The brand associated with the playlists to fetch. |
Throws:
-
- Throws an error if the request fails.
-
-
Type
-
Error
Returns:
- A promise that resolves to an object containing:
- `success` (boolean): Indicates if the fetching operation was successful (`true` for success).
- `data` (Array): An array of pinned playlists.
- `error` (string): An error message if the fetching operation fails.
Resolves to an error message if the request fails.
-
Type
-
Promise.<Object>
(static) fetchPlaylist(playlistId) → {Promise.<Object>}
- Description:
- Retrieves details of a specific playlist by its ID.
This function sends a GET request to the `/playlists/playlist` endpoint with a specified playlist ID.
The server validates the user's access to the playlist and returns playlist details if the user is authorized.
- Source:
Example
fetchPlaylist(12345)
.then(response => console.log(response.data))
.catch(error => console.error('Error fetching playlist:', error));
Parameters:
Name |
Type |
Description |
playlistId |
string
|
number
|
The unique identifier of the playlist to retrieve. |
Returns:
- A promise that resolves to the response from the API, containing:
- `data` (Object): The playlist details, or an error message if access is denied or the playlist is not found.
-
Type
-
Promise.<Object>
(static) fetchPlaylistItem(payload) → {Promise.<(Object|null)>}
- Description:
- Fetches detailed data for a specific playlist item, including associated Sanity and Assignment information if available.
- Source:
Example
const payload = { user_playlist_item_id: 123 };
fetchPlaylistItem(payload)
.then(response => {
if (response?.success) {
console.log("Fetched playlist item data:", response.data);
} else {
console.log("Failed to fetch playlist item data.");
}
})
.catch(error => {
console.error("Error fetching playlist item:", error);
});
Parameters:
Name |
Type |
Description |
payload |
Object
|
The request payload containing necessary parameters.
Properties
Name |
Type |
Description |
user_playlist_item_id |
number
|
The unique ID of the playlist item to fetch. |
|
Throws:
-
- Throws an error if the request encounters issues during retrieval.
-
-
Type
-
Error
Returns:
- A promise that resolves to an object with the fetched playlist item data, including:
- `success` (boolean): Indicates if the data retrieval was successful (`true` on success).
- `data` (Object): Contains the detailed playlist item data enriched with Sanity and Assignment details, if available.
Resolves to `null` if the request fails.
-
Type
-
Promise.<(Object|null)>
(static) fetchPlaylistItems(playlistId) → {Promise.<Array.<Object>>}
- Description:
- Retrieves items within a specified playlist by playlist ID.
This function sends a GET request to the `/playlists/playlist-lessons` endpoint to fetch items in the given playlist.
The server combines data from the playlist and additional metadata from Sanity to enhance item details.
- Source:
Example
fetchPlaylistItems(12345)
.then(items => console.log(items))
.catch(error => console.error('Error fetching playlist items:', error));
Parameters:
Name |
Type |
Description |
playlistId |
string
|
number
|
The unique identifier of the playlist whose items are to be fetched. |
Returns:
- A promise that resolves to an array of playlist items
-
Type
-
Promise.<Array.<Object>>
(static) fetchSongsInProgress(brand) → {Promise.<(Object|null)>}
- Description:
- Fetches a list of songs that are currently in progress for the current user.
- Source:
Example
fetchSongsInProgress('drumeo')
.then(songs => console.log(songs))
.catch(error => console.error(error));
Parameters:
Name |
Type |
Description |
brand |
string
|
The brand associated with the songs. |
Returns:
- Returns an object containing in-progress songs if found, otherwise null.
-
Type
-
Promise.<(Object|null)>
- Description:
- Fetch the top comment for a given content
- Source:
Parameters:
Name |
Type |
Description |
railcontentId |
int
|
The railcontent id to fetch. |
Returns:
- A promise that resolves to an comment object
-
Type
-
Promise.<(Object|null)>
(static) fetchUserAward(contentId) → {Promise.<(any|null)>}
- Description:
- Fetch the user's best award for this challenge
- Source:
Parameters:
Name |
Type |
Description |
contentId |
|
railcontent id of the challenge |
Returns:
- streamed PDF
-
Type
-
Promise.<(any|null)>
(static) fetchUserBadges(brand) → {Promise.<(any|null)>}
- Description:
- Fetch all completed badges for the user ordered by completion date descending
- Source:
Parameters:
Name |
Type |
Description |
brand |
string
|
null
|
- |
Returns:
-
Type
-
Promise.<(any|null)>
(static) fetchUserChallengeProgress(contentId) → {Promise.<(any|null)>}
- Description:
- Fetch challenge, lesson, and user metadata for a given challenge
- Source:
Parameters:
Name |
Type |
Description |
contentId |
|
railcontent id of the challenge |
Returns:
-
Type
-
Promise.<(any|null)>
(static) fetchUserPlaylists(brand) → {Promise.<(Object|null)>}
- Description:
- Fetches user playlists for a specific brand.
Allows optional pagination, sorting, and search parameters to control the result set.
- Source:
Example
fetchUserPlaylists('drumeo', { page: 1, sort: 'name', searchTerm: 'rock' })
.then(playlists => console.log(playlists))
.catch(error => console.error(error));
Parameters:
Name |
Type |
Attributes |
Default |
Description |
brand |
string
|
|
|
The brand identifier for which playlists are being fetched. |
params.limit |
number
|
<optional>
|
10
|
The maximum number of playlists to return per page (default is 10). |
params.page |
number
|
<optional>
|
1
|
The page number for pagination. |
params.sort |
string
|
<optional>
|
'-created_at'
|
The sorting order for the playlists (default is by created_at in descending order). |
params.searchTerm |
string
|
<optional>
|
|
A search term to filter playlists by name. |
params.content_id |
int
|
string
|
<optional>
|
|
If content_id exists, the endpoint checks in each playlist if we have the content in the items. |
Returns:
- A promise that resolves to the response from the API, containing the user playlists data.
-
Type
-
Promise.<(Object|null)>
(static) likePlaylist(playlistId) → {Promise.<Object>}
- Description:
- Sends a request to "like" a playlist on behalf of the authenticated user.
This function calls the `/playlists/playlist/like` endpoint, where the server validates the `playlist_id` and checks
if the authenticated user has already liked the playlist. If not, it creates a new "like" entry associated with the playlist.
- Source:
Example
likePlaylist(12345)
.then(response => {
if (response.success) {
console.log(response.message);
}
})
.catch(error => console.error('Error liking playlist:', error));
Parameters:
Name |
Type |
Description |
playlistId |
string
|
number
|
The unique identifier of the playlist to be liked. |
Returns:
- A promise that resolves with the response from the API. The response contains:
- `success` (boolean): Indicates if the like action was successful (`true` for success).
- `message` (string): A success message if the playlist is liked successfully, or a notification if it was already liked.
- `like` (Object|null): Details of the created "like" entry if the playlist is newly liked, or null if it was already liked.
The `like` object in the response includes:
- `playlist_id`: The ID of the liked playlist.
- `user_id`: The ID of the user who liked the playlist.
- `brand`: The brand associated with the like.
- `created_at`: Timestamp of when the like was created.
-
Type
-
Promise.<Object>
(static) pinPlaylist(playlistId) → {Promise.<Object>}
- Description:
- Pins a playlist to the user's playlist menu.
- Source:
Example
const playlistId = 123;
pinPlaylist(playlistId)
.then(response => {
if (response.success) {
console.log("Playlist pinned successfully:", response.message);
} else {
console.error("Error:", response.error);
}
})
.catch(error => {
console.error("Error pinning playlist:", error);
});
Parameters:
Name |
Type |
Description |
playlistId |
number
|
The ID of the playlist to pin. |
Throws:
-
- Throws an error if the request fails.
-
-
Type
-
Error
Returns:
- A promise that resolves to an object containing:
- `success` (boolean): Indicates if the pinning operation was successful (`true` for success).
- `message` (string): A success message if the playlist was pinned successfully.
- `error` (string): An error message if the pinning operation fails.
Resolves to an error message if the request fails.
-
Type
-
Promise.<Object>
- Description:
- Enable community notifications for the provided challenge
- Source:
Parameters:
Name |
Type |
Description |
contentId |
int
|
string
|
railcontent id of the challenge |
Returns:
-
Type
-
Promise.<(any|null)>
(static) postChallengesCompleteLesson(contentId) → {Promise.<(any|null)>}
- Description:
- Complete the challenge lesson and update challenge progress
- Source:
Parameters:
Name |
Type |
Description |
contentId |
int
|
string
|
railcontent id of the challenge |
Returns:
- Modal data to display
-
Type
-
Promise.<(any|null)>
(static) postChallengesEnroll(contentId) → {Promise.<(any|null)>}
- Description:
- Enroll the user in the given challenge on the challenge published_on date
Clears any current progress data for this challenge
- Source:
Parameters:
Name |
Type |
Description |
contentId |
int
|
string
|
railcontent id of the challenge |
Returns:
-
Type
-
Promise.<(any|null)>
(static) postChallengesEnrollmentNotification(contentId) → {Promise.<(any|null)>}
- Description:
- Enable enrollment notifications for the provided challenge
- Source:
Parameters:
Name |
Type |
Description |
contentId |
int
|
string
|
railcontent id of the challenge |
Returns:
-
Type
-
Promise.<(any|null)>
(static) postChallengesHideCompletedBanner(contentId) → {Promise.<(any|null)>}
- Description:
- Hide challenge completed award bannare
- Source:
Parameters:
Name |
Type |
Description |
contentId |
int
|
string
|
railcontent id of the challenge |
Returns:
-
Type
-
Promise.<(any|null)>
(static) postChallengesLeave(contentId) → {Promise.<(any|null)>}
- Description:
- Remove the user from the provided challenge
Clears any current progress data for this challenge
- Source:
Parameters:
Name |
Type |
Description |
contentId |
int
|
string
|
railcontent id of the challenge |
Returns:
-
Type
-
Promise.<(any|null)>
(static) postChallengesSetStartDate(contentId, startDate) → {Promise.<(any|null)>}
- Description:
- Enroll a user in a challenge and set the start date of the challenge to the provided day.
Clears any existing progress data for this challenge
- Source:
Parameters:
Name |
Type |
Description |
contentId |
int
|
string
|
railcontent id of the challenge |
startDate |
string
|
prefered format YYYYMMDD, but any Carbon parsable string will do. |
Returns:
-
Type
-
Promise.<(any|null)>
(static) postChallengesSoloNotification(contentId) → {Promise.<(any|null)>}
- Description:
- Enable solo notifications for the provided challenge
- Source:
Parameters:
Name |
Type |
Description |
contentId |
int
|
string
|
railcontent id of the challenge |
Returns:
-
Type
-
Promise.<(any|null)>
(static) postChallengesUnlock(contentId) → {Promise.<(any|null)>}
- Description:
- Enroll the user in the provided challenge and set to unlocked
Clears any current progress data for this challenge
- Source:
Parameters:
Name |
Type |
Description |
contentId |
int
|
string
|
railcontent id of the challenge |
Returns:
-
Type
-
Promise.<(any|null)>
(static) reportPlaylist(playlistId, issue) → {Promise.<(any|null)>}
- Description:
- Source:
Parameters:
Name |
Type |
Description |
playlistId |
|
|
issue |
|
|
Returns:
-
Type
-
Promise.<(any|null)>
(static) setStudentViewForUser(userId, enable) → {Promise.<(any|null)>}
- Description:
- Set a user's StudentView Flag
- Source:
Parameters:
Name |
Type |
Description |
userId |
int
|
string
|
id of the user (must be currently authenticated) |
enable |
bool
|
truthsy value to enable student view |
Returns:
-
Type
-
Promise.<(any|null)>
(static) unpinPlaylist(playlistId) → {Promise.<Object>}
- Description:
- Source:
Example
const playlistId = 123;
unpinPlaylist(playlistId)
.then(response => {
if (response.success) {
console.log("Playlist unpinned successfully:", response.message);
} else {
console.error("Error:", response.error);
}
})
.catch(error => {
console.error("Error unpinning playlist:", error);
});
Parameters:
Name |
Type |
Description |
playlistId |
number
|
The ID of the playlist to unpin. |
Throws:
-
- Throws an error if the request fails.
-
-
Type
-
Error
Returns:
- A promise that resolves to an object containing:
- `success` (boolean): Indicates if the unpinning operation was successful (`true` for success).
- `message` (string): A success message if the playlist was unpinned successfully.
- `error` (string): An error message if the unpinning operation fails.
Resolves to an error message if the request fails.
-
Type
-
Promise.<Object>
(static) updatePlaylist(playlistId, updatedData) → {Promise.<Object>}
- Description:
- Updates a user’s playlist by sending a PUT request with updated data to the API.
This function calls the `/playlists/playlist/{playlistId}` endpoint, where the server validates the incoming data
and verifies that the authenticated user is the playlist owner. If authorized, it updates the playlist details with the provided data.
- Source:
Example
updatePlaylist(12345, { name: "My New Playlist Name", description: "Updated description" })
.then(response => {
if (response.success) {
console.log(response.message);
}
})
.catch(error => console.error('Error updating playlist:', error));
Parameters:
Name |
Type |
Description |
playlistId |
string
|
number
|
The unique identifier of the playlist to be updated. |
updatedData |
Object
|
An object containing the playlist data to update. The possible fields include:
- `name` (string): The new name of the playlist (max 255 characters).
- `description` (string): A new description for the playlist (max 1000 characters).
- `category` (string): The updated category of the playlist (max 255 characters).
- `private` (boolean): Whether the playlist is private.
- `thumbnail_url` (string): The URL of the playlist thumbnail. |
Returns:
- A promise that resolves to an object containing:
- `success` (boolean): Indicates if the update was successful (`true` for success).
- `message` (string): Success confirmation message if the update is successful.
- Other fields containing the updated playlist data.
If the user is unauthorized or the data validation fails, the promise rejects with an error.
-
Type
-
Promise.<Object>
(static) updatePlaylistItem(updatedData) → {Promise.<(Object|null)>}
- Description:
- Updates a playlist item with the provided data.
- Source:
Example
const updatedData = {
user_playlist_item_id: 123,
start_second: 30,
end_second: 120,
playlist_item_name: "Updated Playlist Item Name",
position: 2
};
updatePlaylistItem(updatedData)
.then(response => {
if (response.success) {
console.log("Playlist item updated successfully:", response.data);
}
})
.catch(error => {
console.error("Error updating playlist item:", error);
});
Parameters:
Name |
Type |
Description |
updatedData |
Object
|
The data to update the playlist item with.
Properties
Name |
Type |
Attributes |
Description |
user_playlist_item_id |
number
|
|
The ID of the playlist item to update. |
start_second |
number
|
<optional>
|
(Optional) The start time in seconds for the item. |
end_second |
number
|
<optional>
|
(Optional) The end time in seconds for the item. |
playlist_item_name |
string
|
<optional>
|
(Optional) The new name for the playlist item. |
position |
number
|
<optional>
|
(Optional) The new position for the playlist item within the playlist. |
|
Throws:
-
- Throws an error if the request fails.
-
-
Type
-
Error
Returns:
- A promise that resolves to an object containing:
- `success` (boolean): Indicates if the update was successful (`true` for success).
- `data` (Object): The updated playlist item data.
Resolves to `null` if the request fails.
-
Type
-
Promise.<(Object|null)>