export type PatchApiDocumentTenantLocatorDocumentsLocatorArgs = {tenantLocator: string, locator: unknown, metadata?: string | undefined, category?: string | undefined, body: BodyInit}; export type PatchApiDocumentTenantLocatorDocumentsLocatorOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * PATCH /document/{tenantLocator}/documents/{locator} */ export const patchApiDocumentTenantLocatorDocumentsLocator = async (args: PatchApiDocumentTenantLocatorDocumentsLocatorArgs, options: PatchApiDocumentTenantLocatorDocumentsLocatorOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.metadata != null) query.append("metadata", String(args.metadata)) if (args.category != null) query.append("category", String(args.category)) const url = `${baseUrl.replace(/\/+$/, '')}/document/${encodeURIComponent(String(args.tenantLocator))}/documents/${encodeURIComponent(String(args.locator))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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() };