import {z} from 'zod' export type LocationCoords = {accuracy?: number | undefined, lat?: number | undefined, lon?: number | undefined}; export type LocationPosition = {formattedAddress?: string | undefined, locationCoords?: LocationCoords | undefined, skipped?: boolean | undefined}; export type AddressSource = 'manual' | 'autoComplete' | 'gps' | 'externalDb' | 'proofOfAddress' | 'proofOfIdentity'; export type Address = {buildingName?: string | undefined, buildingNumber?: string | undefined, country?: string | undefined, endDate?: string | undefined, flatNumber?: string | undefined, formattedAddress?: string | undefined, locationPosition?: LocationPosition | undefined, postCode?: string | undefined, providedLocationPosition?: LocationPosition | undefined, source?: AddressSource | undefined, startDate?: string | undefined, state?: string | undefined, stateCode?: string | undefined, stateEn?: string | undefined, street?: string | undefined, streetEn?: string | undefined, subStreet?: string | undefined, subStreetEn?: string | undefined, town?: string | undefined, townEn?: string | undefined}; export type ApplicantCompanyInfoCustomInfoItem = {key?: string | undefined, value?: string | undefined}; export type CompanyLegalForm = string; export type CompanyBeneficiaryType = 'shareholder' | 'representative' | 'director' | 'ubo' | 'companyOfficer' | 'secretary' | 'founder' | 'investor' | 'legalAdvisor' | 'authorizedSignatory' | 'trustee' | 'trustBeneficiary' | 'trustSettlor' | 'trustProtector' | 'managingPartner' | 'equityPartner' | 'fundInvestor' | 'fundManager' | 'investmentManager' | 'investmentAdviser' | 'fundAdministrator' | 'depositary' | 'custodian' | 'primeBroker' | 'accountUser' | 'payer'; export type ApplicantCompanyInfoPatchDto = {address?: Address | undefined, alternativeNames?: Array | undefined, applicantPosition?: string | undefined, companyName?: string | undefined, controlScheme?: string | undefined, country?: string | undefined, customInfo?: Array | undefined, email?: string | undefined, incorporatedOn?: string | undefined, legalAddress?: string | undefined, legalForm?: CompanyLegalForm | undefined, leiCode?: string | undefined, licenseNumber?: string | undefined, noDirectors?: boolean | undefined, noDocs?: boolean | undefined, noRepresentatives?: boolean | undefined, noShareholders?: boolean | undefined, noUBOs?: boolean | undefined, phone?: string | undefined, postalAddress?: string | undefined, registrationLocation?: string | undefined, registrationNumber?: string | undefined, skippedTypes?: Array | undefined, taxId?: string | undefined, type?: string | undefined, website?: string | undefined}; export type PatchApiResourcesApplicantsApplicantIdFixedInfoCompanyInfoArgs = {applicantId: string, unsetFields?: string | undefined, body: ApplicantCompanyInfoPatchDto}; export type PatchApiResourcesApplicantsApplicantIdFixedInfoCompanyInfoOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const okResult = z.object({ok: z.number().int().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 }; /** * PATCH /resources/applicants/{applicantId}/fixedInfo/companyInfo */ export const patchApiResourcesApplicantsApplicantIdFixedInfoCompanyInfo = async (args: PatchApiResourcesApplicantsApplicantIdFixedInfoCompanyInfoArgs, options: PatchApiResourcesApplicantsApplicantIdFixedInfoCompanyInfoOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json;charset=UTF-8") headers.set('accept', "application/json;charset=UTF-8") if (args.unsetFields != null) query.append("unsetFields", String(args.unsetFields)) const url = `${baseUrl.replace(/\/+$/, '')}/resources/applicants/${encodeURIComponent(String(args.applicantId))}/fixedInfo/companyInfo${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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(okResult, await res.json()) };