import {z} from 'zod' export type DeleteApiBusinessBusinessIdUboUboIdArgs = {business_id: string, ubo_id: string}; export type DeleteApiBusinessBusinessIdUboUboIdOptions = {baseUrl?: string | undefined, sec0?: string | undefined, fetch?: typeof fetch | undefined}; export const deleteApiBusinessBusinessIdUboUboIdResponse = z.object({data: z.object({id: z.string().optional(), person_id: z.string().optional(), business_id: z.string().optional(), share: z.number().optional(), created_at: z.string().optional(), updated_at: z.string().optional(), person: z.object({id: z.string().optional(), name_first: z.string().optional(), name_last: z.string().optional(), name_other: z.string().optional(), email: z.string().optional(), phone: z.string().optional(), dob: z.string().optional(), id_level: z.string().optional(), id_type: z.string().optional(), id_number: z.string().optional(), id_country: z.string().optional(), bank_id_number: z.string().optional(), bank_id_type: z.string().optional(), address: z.object({line1: z.string().optional(), line2: z.string().optional(), city: z.string().optional(), state: z.string().optional(), country: z.string().optional(), postal_code: z.string().optional()}).optional(), background_information: z.object({employment_status: z.string().optional(), expected_monthly_inflow: z.number().int().optional(), occupation: z.string().optional(), primary_purpose: z.string().optional(), source_of_funds: z.string().optional()}).optional(), status: z.string().optional(), kyc_status: z.string().optional(), kyc_level: z.string().optional(), is_deleted: z.boolean().optional(), created_at: z.string().optional(), updated_at: z.string().optional()}).optional()}).optional(), message: z.string().optional(), meta: z.unknown(), status: z.string().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 }; /** * Delete UBO * * DELETE /business/{business_id}/ubo/{ubo_id} */ export const deleteApiBusinessBusinessIdUboUboId = async (args: DeleteApiBusinessBusinessIdUboUboIdArgs, options?: DeleteApiBusinessBusinessIdUboUboIdOptions) => { const {baseUrl = "https://api.useoval.com", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (sec0 !== undefined) headers.set("Authorization", sec0) const url = `${baseUrl.replace(/\/+$/, '')}/business/${encodeURIComponent(String(args.business_id))}/ubo/${encodeURIComponent(String(args.ubo_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(deleteApiBusinessBusinessIdUboUboIdResponse, await res.json()) };