export type CreateApiDocumentTenantLocatorDocumentsAttachArgs = {tenantLocator: string, referenceLocator: unknown, referenceType: 'quote' | 'policy' | 'invoice' | 'transaction' | 'segment' | 'term' | 'quoteGroup', name: string, staticName?: string | undefined, documentFormat: 'csv' | 'doc' | 'docx' | 'eml' | 'html' | 'jpeg' | 'jpg' | 'msg' | 'pdf' | 'text' | 'txt' | 'xls' | 'xlsx' | 'zip', metadata?: string | undefined, transactionLocator?: unknown | undefined, segmentLocator?: unknown | undefined, category?: string | undefined, copyOnIssuance?: boolean | undefined, body: BodyInit}; export type CreateApiDocumentTenantLocatorDocumentsAttachOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * POST /document/{tenantLocator}/documents/attach */ export const createApiDocumentTenantLocatorDocumentsAttach = async (args: CreateApiDocumentTenantLocatorDocumentsAttachArgs, options: CreateApiDocumentTenantLocatorDocumentsAttachOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.referenceLocator != null) query.append("referenceLocator", String(args.referenceLocator)) if (args.referenceType != null) query.append("referenceType", String(args.referenceType)) if (args.name != null) query.append("name", String(args.name)) if (args.staticName != null) query.append("staticName", String(args.staticName)) if (args.documentFormat != null) query.append("documentFormat", String(args.documentFormat)) if (args.metadata != null) query.append("metadata", String(args.metadata)) if (args.transactionLocator != null) query.append("transactionLocator", String(args.transactionLocator)) if (args.segmentLocator != null) query.append("segmentLocator", String(args.segmentLocator)) if (args.category != null) query.append("category", String(args.category)) if (args.copyOnIssuance != null) query.append("copyOnIssuance", String(args.copyOnIssuance)) const url = `${baseUrl.replace(/\/+$/, '')}/document/${encodeURIComponent(String(args.tenantLocator))}/documents/attach${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: 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() };