export type CreateApiAppearanceThemesCodeSectionsArgs = {code: string, channel?: number | undefined, body: {name: string, type: 'image_carousel' | 'product_carousel' | 'category_carousel' | 'footer_links' | 'static_content' | 'services_content'}}; export type CreateApiAppearanceThemesCodeSectionsOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a section * * POST /appearance/themes/{code}/sections */ export const createApiAppearanceThemesCodeSections = async (args: CreateApiAppearanceThemesCodeSectionsArgs, options?: CreateApiAppearanceThemesCodeSectionsOptions) => { const {baseUrl = "http://localhost:8000/api/admin", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.channel != null) query.append("channel", String(args.channel)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/appearance/themes/${encodeURIComponent(String(args.code))}/sections${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 (await res.json()) as unknown };