export type AttachADocumentRequest = {data: {certification_statement_type: 'CERTIFIED' | 'CERTIFIED_BY_ANOTHER' | 'NOT_CERTIFIED', document_id: string}}; export type CreateApiV1ApplicationsApplicationRequestIdAttachmentsArgs = {application_request_id: string, body: AttachADocumentRequest}; export type CreateApiV1ApplicationsApplicationRequestIdAttachmentsOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Attach a document to an existing application * * POST /v1/applications/{application_request_id}/attachments */ export const createApiV1ApplicationsApplicationRequestIdAttachments = async (args: CreateApiV1ApplicationsApplicationRequestIdAttachmentsArgs, options?: CreateApiV1ApplicationsApplicationRequestIdAttachmentsOptions) => { const {baseUrl = "https://businessgateway.landregistry.gov.uk/bg2/api", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/applications/${encodeURIComponent(String(args.application_request_id))}/attachments${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 undefined };