export type CreateApiJobsArgs = {check_duplicate: boolean, body: {title: string, location: {city?: string | undefined, state?: string | undefined, postal_code?: string | undefined}, country_code?: string | undefined, company_id: number, department_id?: number | undefined, recruiter_id?: number | undefined, owner_id?: number | undefined, category_name?: string | undefined, is_hot?: boolean | undefined, start_date?: string | undefined, salary?: string | undefined, max_rate?: string | undefined, duration?: string | undefined, type?: string | undefined, openings?: number | undefined, external_id?: string | undefined, description?: string | undefined, notes?: string | undefined, contact_id?: number | undefined, workflow_id?: number | undefined, custom_fields?: Array | undefined, user_groups?: Array | undefined}}; export type CreateApiJobsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a job * * POST /jobs */ export const createApiJobs = async (args: CreateApiJobsArgs, options?: CreateApiJobsOptions) => { 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(/\/+$/, '')}/jobs${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 };