import {z} from 'zod' export type GetApiApplicationsApplicationIdDocumentsArgs = {applicationId: string}; export type GetApiApplicationsApplicationIdDocumentsOptions = {baseUrl?: string | undefined, CommonAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiApplicationsApplicationIdDocumentsResponse = z.array(z.object({id: z.string().max(36), applicationId: z.string().max(36), purpose: z.enum(["PROOF_OF_FORMATION", "PROOF_OF_OWNERSHIP_STRUCTURE", "PROOF_OF_OWNERSHIP", "PROOF_OF_CONTROL_PERSONS", "PROOF_OF_REGISTRATION", "PROOF_OF_FINANCES", "PROOF_OF_FUNDS", "PROOF_OF_IDENTITY", "PROOF_OF_ADDRESS", "PROOF_OF_LIVENESS", "GAMING_QUESTIONNAIRE", "CFD_QUESTIONNAIRE", "MSB_QUESTIONNAIRE", "CRYPTO_QUESTIONNAIRE", "INVESTMENT_FUND_QUESTIONNAIRE", "BANK_STATEMENTS_SIX_MONTHS", "AML_POLICY", "AML_MANUAL", "TRANSACTION_MONITORING_PROCEDURE", "CUSTOMER_ACCEPTANCE_PROCEDURE", "ANTI_BRIBERY_AND_CORRUPTION_POLICY", "SAFEGUARDING_POLICY", "COMPLAINTS_POLICY", "SANCTIONS_POLICY", "ANTI_SLAVERY_POLICY", "CUSTOMER_ONBOARDING_PROCEDURES", "ENTERPRISE_RISK_ASSESSMENT", "EMPLOYMENT_HISTORY", "SUPPLIER_INVOICES", "CUSTOMER_INVOICES", "CONTRACTS_WITH_CUSTOMERS", "CONTRACTS_WITH_SUPPLIERS", "INVESTMENT_AGREEMENT", "INVESTOR_PROSPECTUS_PPM", "AML_COMFORT_LETTER", "PROOF_OF_REGISTERED_ADDRESS", "FRAUD_POLICY", "STAFF_AML_TRAINING_POLICY", "SUSPICIOUS_ACTIVITY_REPORTING_POLICY", "CLIENT_RISK_ASSESSMENT_TEMPLATES_METHODOLOGY", "OTHER_CONTRACTS_AGREEMENTS", "PROOF_OF_RESIDENCY", "BANK_STATEMENTS_THREE_MONTHS", "OTHER"]), createdAt: z.string(), updatedAt: z.string()})); 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 }; /** * Retrieve a list of documents for an onboarding application * * GET /applications/{applicationId}/documents */ export const getApiApplicationsApplicationIdDocuments = async (args: GetApiApplicationsApplicationIdDocumentsArgs, options?: GetApiApplicationsApplicationIdDocumentsOptions) => { const {baseUrl = "https://api.equalsmoney.com/v2", fetch: fetchFn = fetch, CommonAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (CommonAuth !== undefined) headers.set("Authorization", CommonAuth) const url = `${baseUrl.replace(/\/+$/, '')}/applications/${encodeURIComponent(String(args.applicationId))}/documents${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(getApiApplicationsApplicationIdDocumentsResponse, await res.json()) };