export type GetApiV2PublicEstimatesEstimateIdPdfArgs = {estimate_id: string, external_id?: (string | null) | undefined, template_id?: (string | null) | undefined, template_select?: (string | null) | undefined, language?: (string | null) | undefined, workspace_id?: (string | null) | undefined, 'Accept-Language'?: (string | null) | undefined, 'X-Workspace-Code'?: string | undefined}; export type GetApiV2PublicEstimatesEstimateIdPdfOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download Public Estimate Pdf * * GET /v2/public/estimates/{estimate_id}/pdf */ export const getApiV2PublicEstimatesEstimateIdPdf = async (args: GetApiV2PublicEstimatesEstimateIdPdfArgs, options?: GetApiV2PublicEstimatesEstimateIdPdfOptions) => { const {baseUrl = "https://api.sanka.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (args.external_id != null) query.append("external_id", String(args.external_id)) if (args.template_id != null) query.append("template_id", String(args.template_id)) if (args.template_select != null) query.append("template_select", String(args.template_select)) if (args.language != null) query.append("language", String(args.language)) if (args.workspace_id != null) query.append("workspace_id", String(args.workspace_id)) if (args['Accept-Language'] != null) headers.set("Accept-Language", String(args['Accept-Language'])) if (args['X-Workspace-Code'] != null) headers.set("X-Workspace-Code", String(args['X-Workspace-Code'])) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/public/estimates/${encodeURIComponent(String(args.estimate_id))}/pdf${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() };