export type CreateApiPublicV1BatchesIdPrimaryTestResultPdfArgs = {id: string, body: {format: 'binary' | 'url' | 'email', email_addresses?: Array | undefined}}; export type CreateApiPublicV1BatchesIdPrimaryTestResultPdfOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Generate a batch's Certificate of Analysis (COA) PDF * * POST /public/v1/batches/{id}/primary-test-result/pdf */ export const createApiPublicV1BatchesIdPrimaryTestResultPdf = async (args: CreateApiPublicV1BatchesIdPrimaryTestResultPdfArgs, options?: CreateApiPublicV1BatchesIdPrimaryTestResultPdfOptions) => { const {baseUrl = "https://app.distru.com", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/pdf,application/json") if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/public/v1/batches/${encodeURIComponent(String(args.id))}/primary-test-result/pdf${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() };