import {z} from 'zod' export type PatchApiApiV1ProjectsIdArgs = {id: string, body: {opportunityId?: string | undefined, companyContactIds?: Array | undefined, jobRole?: string | undefined, ownerEmail?: string | undefined, jobDescription?: (string | null) | undefined, notes?: (string | null) | undefined, func?: (string | null) | undefined, seniority?: ('partner' | 'board' | 'founder' | 'cxo' | 'vp' | 'director' | 'manager' | 'senior' | 'middle' | 'junior' | 'training' | 'unpaid' | 'null' | null) | undefined, contractType?: ('full_time' | 'part_time' | 'contract' | 'non_exec' | 'null' | null) | undefined, workMode?: ('office' | 'hybrid' | 'remote' | 'null' | null) | undefined, salary?: ({value: string, currency: 'USD' | 'EUR' | 'JPY' | 'GBP' | 'AUD' | 'CAD' | 'CHF' | 'CNY' | 'HKD' | 'NZD' | 'SEK' | 'NOK' | 'MXN' | 'SGD' | 'RUB' | 'ZAR' | 'TRY' | 'BRL' | 'INR' | 'KRW' | 'DKK' | 'PLN' | 'ILS' | 'HUF' | 'CZK' | 'RON' | 'THB' | 'MYR' | 'IDR' | 'VND' | 'PHP' | 'SAR' | 'AED' | 'QAR' | 'KWD' | 'JOD' | 'CLP' | 'COP' | 'PEN' | 'ARS' | 'UYU' | 'CRC' | 'PKR' | 'BDT' | 'LKR' | 'EGP' | 'NGN' | 'TWD' | 'KES' | 'GHS' | 'UGX' | 'TZS' | 'MAD' | 'BWP' | 'BGN' | 'UAH' | 'KZT' | 'GEL' | 'ISK' | 'BHD' | 'OMR'} | null) | undefined, expectedFee?: ({value: string, currency: 'USD' | 'EUR' | 'JPY' | 'GBP' | 'AUD' | 'CAD' | 'CHF' | 'CNY' | 'HKD' | 'NZD' | 'SEK' | 'NOK' | 'MXN' | 'SGD' | 'RUB' | 'ZAR' | 'TRY' | 'BRL' | 'INR' | 'KRW' | 'DKK' | 'PLN' | 'ILS' | 'HUF' | 'CZK' | 'RON' | 'THB' | 'MYR' | 'IDR' | 'VND' | 'PHP' | 'SAR' | 'AED' | 'QAR' | 'KWD' | 'JOD' | 'CLP' | 'COP' | 'PEN' | 'ARS' | 'UYU' | 'CRC' | 'PKR' | 'BDT' | 'LKR' | 'EGP' | 'NGN' | 'TWD' | 'KES' | 'GHS' | 'UGX' | 'TZS' | 'MAD' | 'BWP' | 'BGN' | 'UAH' | 'KZT' | 'GEL' | 'ISK' | 'BHD' | 'OMR'} | null) | undefined, hireTarget?: (number | null) | undefined, visaSupport?: (boolean | null) | undefined, public?: boolean | undefined, location?: ({name?: (string | null) | undefined, locality?: (string | null) | undefined, region?: (string | null) | undefined, metro?: (string | null) | undefined, country?: (string | null) | undefined, streetAddress?: (string | null) | undefined, addressLine2?: (string | null) | undefined, postalCode?: (string | null) | undefined, raw?: (string | null) | undefined, latitude?: (number | null) | undefined, longitude?: (number | null) | undefined} | null) | undefined, startedAt?: (string | null) | undefined}}; export type PatchApiApiV1ProjectsIdOptions = {baseUrl: string, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const patchApiApiV1ProjectsIdResponse = z.object({status: z.literal("ok"), data: z.object({id: z.string(), jobRole: z.string(), jobNumber: z.string().nullable(), state: z.string(), opportunityId: z.string().nullable(), companyContactIds: z.array(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 }; /** * Update a project * * PATCH /api/v1/projects/{id} */ export const patchApiApiV1ProjectsId = async (args: PatchApiApiV1ProjectsIdArgs, options: PatchApiApiV1ProjectsIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/projects/${encodeURIComponent(String(args.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(patchApiApiV1ProjectsIdResponse, await res.json()) };