export type CreateApiApiAiCourseCreateArgs = {token: string, body: {title?: string | undefined, description?: string | undefined, category_id?: number | undefined}}; export type CreateApiApiAiCourseCreateOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Create course using AI * * POST /api/ai-Course-Create */ export const createApiApiAiCourseCreate = async (args: CreateApiApiAiCourseCreateArgs, options: CreateApiApiAiCourseCreateOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.token != null) query.append("token", String(args.token)) const url = `${baseUrl.replace(/\/+$/, '')}/api/ai-Course-Create${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 };