export type CurpDataRequest = {curp?: string | undefined, name?: string | undefined, firstLastName?: string | undefined, secondLastName?: string | undefined, gender?: ('H' | 'M' | 'X') | undefined, birthDate?: unknown | undefined, state?: string | undefined, externalId?: string | undefined}; export type CreateApiOmniAddCurpV2Args = {interviewId?: string | undefined, 'api-version': string, body: CurpDataRequest}; export type CreateApiOmniAddCurpV2Options = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, IncodeHardwareIdAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add curp v2 * * POST /omni/add/curp/v2 */ export const createApiOmniAddCurpV2 = async (args: CreateApiOmniAddCurpV2Args, options?: CreateApiOmniAddCurpV2Options) => { const {baseUrl = "https://demo-api.incodesmile.com", fetch: fetchFn = fetch, ApiKeyAuth, IncodeHardwareIdAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.interviewId != null) query.append("interviewId", String(args.interviewId)) if (args['api-version'] != null) headers.set("api-version", String(args['api-version'])) if (ApiKeyAuth !== undefined) headers.set("x-api-key", ApiKeyAuth) if (IncodeHardwareIdAuth !== undefined) headers.set("X-Incode-Hardware-Id", IncodeHardwareIdAuth) const url = `${baseUrl.replace(/\/+$/, '')}/omni/add/curp/v2${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 (await res.json()) as unknown };