export type Template = {config?: string | undefined, cssCode?: string | undefined, dateActivated?: string | undefined, dateCreated?: string | undefined, dateModified?: string | undefined, description?: string | undefined, htmlCode?: string | undefined, id?: number | undefined, isCustomTemplate?: boolean | undefined, name?: string | undefined, siteId: number, status?: ('DRAFT' | 'ACTIVE' | 'PAUSED') | undefined, tags?: Array | undefined, templateCssCode?: string | undefined, templateHtmlCode?: string | undefined, templateJavaScriptCode?: string | undefined, themeId?: number | undefined, type?: ('TEMPLATE' | 'EDITOR' | 'PBX') | undefined, url?: string | undefined, useCustomData?: boolean | undefined, widgetEditorTemplate?: string | undefined}; export type UpdateApiTemplatesTemplateIdArgs = {templateId: number, body: Template}; export type UpdateApiTemplatesTemplateIdOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update template * * PUT /templates/{templateId} */ export const updateApiTemplatesTemplateId = async (args: UpdateApiTemplatesTemplateIdArgs, options?: UpdateApiTemplatesTemplateIdOptions) => { const {baseUrl = "https://api.kameleoon.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/templates/${encodeURIComponent(String(args.templateId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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() };