-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
44 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
// @ts-check | ||
import type { ContentLibrary } from './types'; | ||
import { camelCaseObject, getConfig } from '@edx/frontend-platform'; | ||
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; | ||
|
||
const getApiBaseUrl = (): string => getConfig().STUDIO_BASE_URL; | ||
const getContentLibraryApiUrl = (libraryId: string) => `${getApiBaseUrl()}/api/libraries/v2/${libraryId}/`; | ||
const getApiBaseUrl = () => getConfig().STUDIO_BASE_URL; | ||
/** | ||
* Get the URL for the content library API. | ||
* @param {string} libraryId - The ID of the library to fetch. | ||
*/ | ||
const getContentLibraryApiUrl = (libraryId) => `${getApiBaseUrl()}/api/libraries/v2/${libraryId}/`; | ||
|
||
export async function getContentLibrary(libraryId: string): Promise<ContentLibrary> { | ||
/** | ||
* Fetch a content library by its ID. | ||
* @param {string} [libraryId] - The ID of the library to fetch. | ||
* @returns {Promise<import("./types.mjs").ContentLibrary>} | ||
*/ | ||
/* eslint-disable import/prefer-default-export */ | ||
export async function getContentLibrary(libraryId) { | ||
const { data } = await getAuthenticatedHttpClient().get(getContentLibraryApiUrl(libraryId)); | ||
return camelCaseObject(data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @typedef {Object} ContentLibrary | ||
* @property {string} id | ||
* @property {string} type | ||
* @property {string} org | ||
* @property {string} slug | ||
* @property {string} title | ||
* @property {string} description | ||
* @property {number} numBlocks | ||
* @property {number} version | ||
* @property {Date | null} lastPublished | ||
* @property {boolean} allowLti | ||
* @property {boolean} allowPublicLearning | ||
* @property {boolean} allowPublicRead | ||
* @property {boolean} hasUnpublishedChanges | ||
* @property {boolean} hasUnpublishedDeletes | ||
* @property {string} license | ||
*/ |