import {z} from 'zod' export type PatchApiApiV1LinkedinJobsJobIdArgs = {job_id: string, body: {job_title?: ({id?: string | undefined, text?: string | undefined}) | undefined, company?: ({id?: string | undefined, text?: string | undefined}) | undefined, workplace?: ('ON_SITE' | 'HYBRID' | 'REMOTE') | undefined, location?: string | undefined, employment_status?: ('FULL_TIME' | 'PART_TIME' | 'CONTRACT' | 'TEMPORARY' | 'OTHER' | 'VOLUNTEER' | 'INTERNSHIP') | undefined, description?: string | undefined, auto_rejection_template?: string | undefined, screening_questions?: (Array<{question: string, position?: number | undefined, must_match?: boolean | undefined, answer_type: 'numeric', min_expectation?: number | undefined, max_expectation?: number | undefined} | {question: string, position?: number | undefined, must_match?: boolean | undefined, answer_type: 'multiple_choices', choices: Array, expected_choices: Array}>) | undefined, apply_method?: ({type: 'linkedin', notification_email: string} | {type: 'external', url: string}) | undefined, account_id: string, recruiter?: ({functions?: Array | undefined, industries?: Array | undefined, skills?: Array | undefined, seniority?: ('INTERNSHIP' | 'ENTRY_LEVEL' | 'ASSOCIATE' | 'MID_SENIOR_LEVEL' | 'DIRECTOR' | 'EXECUTIVE' | 'NOT_APPLICABLE') | undefined, include_poster_info?: boolean | undefined, tracking_pixel_url?: string | undefined, company_job_id?: string | undefined, apply_method?: ({type: 'linkedin', notification_email: string, resume_required: boolean} | {type: 'external', url: string}) | undefined, salary?: ({currency: string, min: number, max: number, pay_frequency: 'YEARLY' | 'MONTHLY' | 'HOURLY'}) | undefined, additional_compensation?: ({currency: string, min: number, max: number, pay_frequency: 'YEARLY' | 'MONTHLY' | 'HOURLY'}) | undefined, auto_archive_applicants?: ({screening_questions?: boolean | undefined, outside_of_country?: boolean | undefined}) | undefined, send_rejection_notification?: boolean | undefined, project_id: string}) | undefined}}; export type PatchApiApiV1LinkedinJobsJobIdOptions = {baseUrl?: string | undefined, AccessToken?: string | undefined, fetch?: typeof fetch | undefined}; export const patchApiApiV1LinkedinJobsJobIdResponse = z.object({object: z.literal("LinkedinJobPostingEdited"), job_id: z.string()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Edit a job posting * * PATCH /api/v1/linkedin/jobs/{job_id} */ export const patchApiApiV1LinkedinJobsJobId = async (args: PatchApiApiV1LinkedinJobsJobIdArgs, options?: PatchApiApiV1LinkedinJobsJobIdOptions) => { const {baseUrl = "https://api1.unipile.com:13111", fetch: fetchFn = fetch, AccessToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (AccessToken !== undefined) headers.set("X-API-KEY", AccessToken) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/linkedin/jobs/${encodeURIComponent(String(args.job_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 validateResponse(patchApiApiV1LinkedinJobsJobIdResponse, await res.json()) };