export type CandidatePortalOpenApplicationDto = {firstName: string, lastName: string, cvAttachmentId: string, email: {email: string, purpose: 'personal' | 'work' | null, isPrimary?: boolean | undefined}, phoneNumber: {phoneNumber: string, purpose: 'personal' | 'work' | null, isPrimary?: boolean | undefined}, socialMedia?: ({url: string, type: 'LINKEDIN' | 'TWITTER' | 'FACEBOOK' | 'INSTAGRAM', isPrimary?: boolean | undefined}) | undefined}; export type CreateApiCandidatePortalOpenApplicationArgs = {body: CandidatePortalOpenApplicationDto}; export type CreateApiCandidatePortalOpenApplicationOptions = {baseUrl: string, xApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create candidate * * POST /candidate-portal/open-application */ export const createApiCandidatePortalOpenApplication = async (args: CreateApiCandidatePortalOpenApplicationArgs, options: CreateApiCandidatePortalOpenApplicationOptions) => { 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(/\/+$/, '')}/candidate-portal/open-application${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 };