import {z} from 'zod' export type GetApiEmployeeVerificationRequestsIdArgs = {id: string}; export type GetApiEmployeeVerificationRequestsIdOptions = {baseUrl?: string | undefined, APIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; export const taskState = z.enum(["PENDING", "EXECUTING", "COMPLETED", "FAILED", "CANCELLED"]); export const employeeVerificationContact = z.object({email: z.string().nullable().optional(), phone: z.string().nullable().optional()}); export const socialSite = z.enum(["linked_in:personal", "linked_in:company", "twitter", "instagram", "facebook", "youtube", "tiktok", "pinterest", "x"]); export const employeeVerificationSocial = z.object({platform: socialSite, url: z.string()}); export const employeeVerificationMiscLink = z.object({label: z.string(), url: z.string()}); export const employeeVerificationSource = z.object({url: z.string(), description: z.string()}); export const v1EmployeeVerificationRequestResponse = z.object({id: z.string(), created_at: z.string(), updated_at: z.string().nullable().optional(), state: taskState, person_name: z.string(), business_name: z.string(), business_address: z.string().nullable().optional(), alternative_names: z.array(z.string()).nullable().optional(), verified: z.boolean().nullable().optional(), role_title: z.string().nullable().optional(), department: z.string().nullable().optional(), evidence_summary: z.string().nullable().optional(), contact: employeeVerificationContact.nullable().optional(), socials: z.array(employeeVerificationSocial).nullable().optional(), miscellaneous_links: z.array(employeeVerificationMiscLink).nullable().optional(), sources: z.array(employeeVerificationSource).nullable().optional()}); 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 }; /** * Get Employee Verification Request By Id * * GET /employee_verification_requests/{id} */ export const getApiEmployeeVerificationRequestsId = async (args: GetApiEmployeeVerificationRequestsIdArgs, options?: GetApiEmployeeVerificationRequestsIdOptions) => { const {baseUrl = "https://api.baselayer.com", fetch: fetchFn = fetch, APIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (APIKeyHeader !== undefined) headers.set("X-API-Key", APIKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/employee_verification_requests/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(v1EmployeeVerificationRequestResponse, await res.json()) };