export type UpdateEmailTemplateDto = {templateName?: string | undefined, subject?: string | undefined, body?: string | undefined, upsellProducts?: (Array | null) | undefined, sortOrder?: number | undefined}; export type UpdateApiEmailTemplatesIdArgs = {id: number, body: UpdateEmailTemplateDto}; export type UpdateApiEmailTemplatesIdOptions = {baseUrl?: string | undefined, accessToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update email template * * PUT /email-templates/{id} */ export const updateApiEmailTemplatesId = async (args: UpdateApiEmailTemplatesIdArgs, options?: UpdateApiEmailTemplatesIdOptions) => { const {baseUrl = "https://api.findmydocument.net", fetch: fetchFn = fetch, accessToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (accessToken !== undefined) headers.set('authorization', `Bearer ${accessToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/email-templates/${encodeURIComponent(String(args.id))}${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 undefined };