import {z} from 'zod' export type GetApiV1BackgroundVerificationFirCheckTransactionIdArgs = {transaction_id: string, normalise?: boolean | undefined, name_match_type?: string | undefined, father_match_type?: string | undefined, type?: string | undefined, case_category?: string | undefined, case_status?: string | undefined, state_match?: string | undefined, dist_match?: string | undefined, jurisdiction_type?: string | undefined, algo_risk?: string | undefined}; export type GetApiV1BackgroundVerificationFirCheckTransactionIdOptions = {baseUrl: string, Oauth2ClientCredentials?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiV1BackgroundVerificationFirCheckTransactionIdResponse = z.unknown(); 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 Fir Check * * GET /v1/background-verification/fir-check/{transaction_id} */ export const getApiV1BackgroundVerificationFirCheckTransactionId = async (args: GetApiV1BackgroundVerificationFirCheckTransactionIdArgs, options: GetApiV1BackgroundVerificationFirCheckTransactionIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, Oauth2ClientCredentials} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.normalise != null) query.append("normalise", String(args.normalise)) if (args.name_match_type != null) query.append("name_match_type", String(args.name_match_type)) if (args.father_match_type != null) query.append("father_match_type", String(args.father_match_type)) if (args.type != null) query.append("type", String(args.type)) if (args.case_category != null) query.append("case_category", String(args.case_category)) if (args.case_status != null) query.append("case_status", String(args.case_status)) if (args.state_match != null) query.append("state_match", String(args.state_match)) if (args.dist_match != null) query.append("dist_match", String(args.dist_match)) if (args.jurisdiction_type != null) query.append("jurisdiction_type", String(args.jurisdiction_type)) if (args.algo_risk != null) query.append("algo_risk", String(args.algo_risk)) if (Oauth2ClientCredentials !== undefined) headers.set('authorization', `Bearer ${Oauth2ClientCredentials}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/background-verification/fir-check/${encodeURIComponent(String(args.transaction_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(getApiV1BackgroundVerificationFirCheckTransactionIdResponse, await res.json()) };