export type LessonCreateType = 1 | 4 | 5; export type NewLesson = {name?: (string | null) | undefined, categoryID?: (number | null) | undefined, instituteID?: number | undefined, lessonType?: LessonCreateType | undefined, assetIDs?: (Array | null) | undefined, mvbWizardType?: number | undefined}; export type CreateApiLessonCreateNewLessonArgs = {'X-Version'?: string | undefined, body: NewLesson}; export type CreateApiLessonCreateNewLessonOptions = {baseUrl: string, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create New Lesson API for LessonTypes: 1=3D | 2=360 | 5=MultiAssetLesson * * POST /Lesson/CreateNewLesson */ export const createApiLessonCreateNewLesson = async (args: CreateApiLessonCreateNewLessonArgs, options: CreateApiLessonCreateNewLessonOptions) => { const {baseUrl, fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['X-Version'] != null) headers.set("X-Version", String(args['X-Version'])) if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/Lesson/CreateNewLesson${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };