export type CreateApiAppsPdfV1PreviewArgs = {body: {logo_url?: string | undefined, logo_height?: number | undefined, locale?: string | undefined, date_format?: string | undefined, hide_promo?: boolean | undefined, layout?: ('A4' | 'Letter' | 'DIN5008') | undefined, data?: Record | undefined}}; export type CreateApiAppsPdfV1PreviewOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Generate a PDF preview of the provided GOBL document. * * POST /apps/pdf/v1/preview */ export const createApiAppsPdfV1Preview = async (args: CreateApiAppsPdfV1PreviewArgs, options?: CreateApiAppsPdfV1PreviewOptions) => { const {baseUrl = "https://api.invopop.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/pdf") const url = `${baseUrl.replace(/\/+$/, '')}/apps/pdf/v1/preview${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() };