export type CreateApiCandidatesArgs = {check_duplicate: boolean, body: {first_name: string, middle_name?: string | undefined, last_name: string, title?: string | undefined, emails?: Array | undefined, phones?: Array | undefined, address?: ({street?: string | undefined, city?: string | undefined, state?: string | undefined, postal_code?: string | undefined}) | undefined, country_code?: string | undefined, social_media_urls?: Array | undefined, website?: string | undefined, best_time_to_call?: string | undefined, current_employer?: string | undefined, date_available?: string | undefined, current_pay?: string | undefined, desired_pay?: string | undefined, is_willing_to_relocate?: boolean | undefined, key_skills?: string | undefined, notes?: string | undefined, source?: string | undefined, owner_id?: number | undefined, is_active?: boolean | undefined, is_hot?: boolean | undefined, password?: string | undefined, custom_fields?: Array | undefined, work_history?: Array | undefined}}; export type CreateApiCandidatesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a candidate * * POST /candidates */ export const createApiCandidates = async (args: CreateApiCandidatesArgs, options?: CreateApiCandidatesOptions) => { const {baseUrl = "https://api.catsone.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.check_duplicate != null) query.append("check_duplicate", String(args.check_duplicate)) const url = `${baseUrl.replace(/\/+$/, '')}/candidates${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 };