export type AttachmentTypeInputDto = {id: string} | {name: 'UNASSIGNED' | 'CV'} | 'UNASSIGNED' | 'CV'; export type AssignAttachmentDto = {id: string, type: AttachmentTypeInputDto, name?: string | undefined}; export type AssignAttachmentsDto = {attachments: Array, candidateIds?: Array | undefined, companyIds?: Array | undefined, vacancyIds?: Array | undefined, candidateId?: string | undefined, companyId?: string | undefined, vacancyId?: string | undefined}; export type CreateApiAttachmentsTemporaryAssignArgs = {body: AssignAttachmentsDto}; export type CreateApiAttachmentsTemporaryAssignOptions = {baseUrl: string, xApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Assign temporary attachments to records * * POST /attachments/temporary/assign */ export const createApiAttachmentsTemporaryAssign = async (args: CreateApiAttachmentsTemporaryAssignArgs, options: CreateApiAttachmentsTemporaryAssignOptions) => { const {baseUrl, fetch: fetchFn = fetch, xApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (xApiKey !== undefined) headers.set("x-api-key", xApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/attachments/temporary/assign${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 };