export type GetApiImagesTemplateFilenameArgs = {status?: number | undefined, frames?: number | undefined, scale?: number | undefined, center?: string | undefined, background?: string | undefined, color?: string | undefined, height?: number | undefined, width?: number | undefined, layout?: string | undefined, font?: string | undefined, style?: string | undefined, template_filename: string}; export type GetApiImagesTemplateFilenameOptions = {baseUrl: string, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Display a template background * * GET /images/{template_filename} */ export const getApiImagesTemplateFilename = async (args: GetApiImagesTemplateFilenameArgs, options: GetApiImagesTemplateFilenameOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/*") if (args.status != null) query.append("status", String(args.status)) if (args.frames != null) query.append("frames", String(args.frames)) if (args.scale != null) query.append("scale", String(args.scale)) if (args.center != null) query.append("center", String(args.center)) if (args.background != null) query.append("background", String(args.background)) if (args.color != null) query.append("color", String(args.color)) if (args.height != null) query.append("height", String(args.height)) if (args.width != null) query.append("width", String(args.width)) if (args.layout != null) query.append("layout", String(args.layout)) if (args.font != null) query.append("font", String(args.font)) if (args.style != null) query.append("style", String(args.style)) if (ApiKeyAuth !== undefined) headers.set("X-API-KEY", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/images/${encodeURIComponent(String(args.template_filename))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };