export type CreateApiZonesZoneNameArgs = {zone_name: string, body: {[key: string]: Record}}; export type CreateApiZonesZoneNameOptions = {baseUrl?: string | undefined, HEADER?: string | undefined, fetch?: typeof fetch | undefined}; /** * Render a named zone for web-page embedding * * POST /zones/{zone_name} * * Also accepts auth: QUERY, COOKIE */ export const createApiZonesZoneName = async (args: CreateApiZonesZoneNameArgs, options?: CreateApiZonesZoneNameOptions) => { const {baseUrl = "https://api.extole.io", fetch: fetchFn = fetch, HEADER} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (HEADER !== undefined) headers.set("Authorization", HEADER) const url = `${baseUrl.replace(/\/+$/, '')}/zones/${encodeURIComponent(String(args.zone_name))}${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 res.blob() };