import {z} from 'zod' export type CreateApiV2NgIdentitiesAmlPep1Args = {body: {entityName: string, type?: string | undefined, country?: Array | undefined, gender?: string | undefined}}; export type CreateApiV2NgIdentitiesAmlPep1Options = {baseUrl?: string | undefined, sec0?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiV2NgIdentitiesAmlPep1Response = z.object({id: z.number().int(), summary: z.object({aml_pep_check: z.string().optional(), drivers_license_check: z.object({status: z.string().optional(), fieldMatches: z.object({firstname: z.boolean().optional(), lastname: z.boolean().optional()}).optional()}).optional()}).optional(), status: z.object({state: z.string().optional(), status: z.string().optional()}).optional(), aml_pep: z.object({CaseAssociation: z.array(z.object({Name: z.string().optional(), Score: z.string().optional(), Status: z.string().optional(), Uid: z.string().optional(), Type: z.string().optional(), EntityId: z.string().optional()})).optional(), Case_Outcome: z.object({Name: z.string().optional(), CaseId: z.string().optional(), CompositeApplicationStatus: z.string().optional(), Score: z.string().optional(), Status: z.string().optional(), Uid: z.string().optional(), EntityName: z.string().optional(), EntityId: z.string().optional()}).optional(), entitychecks: z.array(z.object({HitsFound: z.object({AmlCheck: z.number().optional(), "Angola Watchlists": z.number().optional(), "Bangladesh Watchlists": z.number().optional(), "International Watchlist": z.number().optional(), "Kenya Watchlists": z.number().optional(), "Namibia Watchlists": z.number().optional(), "Nigeria Watchlists": z.number().optional(), PepCheck: z.number().optional(), SanctionCheck: z.number().optional(), "South Africa Watchlists": z.number().optional(), "State Owned Enterprises": z.number().optional(), "Zimbabwe Watchlists": z.number().optional()}).optional(), entityName: z.string().optional(), entityType: z.string().optional(), totalResponseCount: z.number().optional(), hits: z.object({"Nigeria Watchlists": z.array(z.object({AlertId: z.string().optional(), Authority: z.string().optional(), "Full Name": z.string().optional(), Gender: z.string().optional(), HitId: z.string().optional(), InputClientID: z.string().optional(), InputConcatAddress: z.array(z.number()).optional(), InputCountry: z.array(z.number()).optional(), InputEntityName: z.string().optional(), InputGender: z.string().optional(), InputType: z.string().optional(), "List Name": z.string().optional(), ListUid: z.string().optional(), "Match Score": z.string().optional(), "Nature of Offence": z.string().optional(), ReviewerId: z.number().optional(), ReviewerId2: z.number().optional(), ReviewerId3: z.number().optional(), ReviewerIdP: z.number().optional(), RunId: z.number().optional(), Sources: z.string().optional(), composite_score: z.string().optional(), details: z.string().optional(), full_name_db: z.string().optional(), mappingId: z.number().optional(), match_details: z.string().optional(), match_score: z.number().optional(), match_status: z.string().optional(), timestamp: z.string().optional()})).optional(), SanctionCheck: z.array(z.object({})).optional()}).optional()})).optional(), pdfUrl: z.string().optional(), source: z.string().optional(), request: z.object({idNumber: z.string().optional(), entityName: z.string().optional(), type: z.string().optional(), country: z.array(z.string()).optional(), gender: z.string().optional()}).optional()}).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 }; /** * Copy of Copy of LASRRA ID Number * * POST /v2/ng/identities/aml-pep-1 */ export const createApiV2NgIdentitiesAmlPep1 = async (args: CreateApiV2NgIdentitiesAmlPep1Args, options?: CreateApiV2NgIdentitiesAmlPep1Options) => { const {baseUrl = "https://api.qoreid.com", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (sec0 !== undefined) headers.set('authorization', `Bearer ${sec0}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/ng/identities/aml-pep-1${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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(createApiV2NgIdentitiesAmlPep1Response, await res.json()) };