11import { camelCaseObject , getConfig } from '@edx/frontend-platform' ;
22import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth' ;
33import { XBlock } from '@src/data/types' ;
4- import { CourseOutline } from './types' ;
4+ import { CourseOutline , CourseDetails } from './types' ;
55
66const getApiBaseUrl = ( ) => getConfig ( ) . STUDIO_BASE_URL ;
77
88export const getCourseOutlineIndexApiUrl = (
99 courseId : string ,
1010) => `${ getApiBaseUrl ( ) } /api/contentstore/v1/course_index/${ courseId } ` ;
1111
12+ export const getCourseDetailsApiUrl = ( courseId ) => `${ getApiBaseUrl ( ) } /api/contentstore/v1/course_details/${ courseId } ` ;
13+
1214export const getCourseBestPracticesApiUrl = ( {
1315 courseId,
1416 excludeGraded,
@@ -46,7 +48,7 @@ export const createDiscussionsTopicsUrl = (courseId: string) => `${getApiBaseUrl
4648/**
4749 * Get course outline index.
4850 * @param {string } courseId
49- * @returns {Promise<courseOutline > }
51+ * @returns {Promise<CourseOutline > }
5052 */
5153export async function getCourseOutlineIndex ( courseId : string ) : Promise < CourseOutline > {
5254 const { data } = await getAuthenticatedHttpClient ( )
@@ -55,6 +57,18 @@ export async function getCourseOutlineIndex(courseId: string): Promise<CourseOut
5557 return camelCaseObject ( data ) ;
5658}
5759
60+ /**
61+ * Get course details.
62+ * @param {string } courseId
63+ * @returns {Promise<CourseDetails> }
64+ */
65+ export async function getCourseDetails ( courseId : string ) : Promise < CourseDetails > {
66+ const { data } = await getAuthenticatedHttpClient ( )
67+ . get ( getCourseDetailsApiUrl ( courseId ) ) ;
68+
69+ return camelCaseObject ( data ) ;
70+ }
71+
5872/**
5973 *
6074 * @param courseId
0 commit comments