import {z} from 'zod' export type GetApiVerifyGetUserDocumentsUserProfileIdArgs = {user_profile_id: string}; export type GetApiVerifyGetUserDocumentsUserProfileIdOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const aiPriseRunStatusV2 = z.enum(["NOT_STARTED", "RUNNING", "PENDING", "FAILED", "COMPLETED", "SUBMITTED"]).nullable(); export const userVerificationSessions = z.object({verification_session_id: z.string().optional(), result: z.string().optional(), created_at: z.number().int().nullable().optional(), status: aiPriseRunStatusV2.optional()}); export const userMediaFile = z.object({file_uuid: z.string().optional(), file_name: z.string().optional(), file_type: z.string().nullable().optional(), file_format_type: z.string().nullable().optional(), file_s3_url: z.string().optional(), created_at: z.number().int().nullable().optional(), source: z.string().nullable().optional(), verification_sessions: z.array(userVerificationSessions).nullable().optional()}); export const userMediaFilesResponse = z.object({files: z.array(userMediaFile).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 User Documents * * GET /verify/get_user_documents/{user_profile_id} */ export const getApiVerifyGetUserDocumentsUserProfileId = async (args: GetApiVerifyGetUserDocumentsUserProfileIdArgs, options?: GetApiVerifyGetUserDocumentsUserProfileIdOptions) => { const {baseUrl = "https://api-sandbox.aiprise.com/api/v1", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (apiKey !== undefined) headers.set("X-API-KEY", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/verify/get_user_documents/${encodeURIComponent(String(args.user_profile_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(userMediaFilesResponse, await res.json()) };