export type UpdateApiUploadADocumentArgs = {'X-Amz-Checksum-Sha256'?: string | undefined, 'Content-Length'?: number | undefined, body: BodyInit}; export type UpdateApiUploadADocumentOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upload a document - Upload the document contents. **Note**: This URL, including hostname and path parameters is returned from the create URL endpoint and **should be used unmodified**. The path and hostname given in the API specification here are examples only. * * PUT Upload a document */ export const updateApiUploadADocument = async (args: UpdateApiUploadADocumentArgs, options?: UpdateApiUploadADocumentOptions) => { const {baseUrl = "https://businessgateway.landregistry.gov.uk/bg2/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/octet-stream") if (args['X-Amz-Checksum-Sha256'] != null) headers.set("X-Amz-Checksum-Sha256", String(args['X-Amz-Checksum-Sha256'])) if (args['Content-Length'] != null) headers.set("Content-Length", String(args['Content-Length'])) const url = `${baseUrl.replace(/\/+$/, '')}Upload a document${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 undefined };