import {z} from 'zod' export type ReportType = 'STATEMENT' | 'INVESTMENT' | 'ACCOUNTING' | 'FX_RATES' | 'PAYMENT_STATUS' | 'BENCHMARK_RATES' | 'INSTRUMENT_PRODUCTS' | 'ACCOUNTS' | 'OTHER'; export type StatementType = 'BOOKED' | 'PENDING'; export type GetApiConnectivityV2betaConnectionsCidReportsArgs = {cid: string, limit?: number | undefined, token?: string | undefined, from?: string | undefined, to?: string | undefined, type?: ReportType | undefined, statementType?: StatementType | undefined}; export type GetApiConnectivityV2betaConnectionsCidReportsOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; export const organizationID = z.string(); export const resourceID = z.string().min(32).max(64); export const reportType = z.enum(["STATEMENT", "INVESTMENT", "ACCOUNTING", "FX_RATES", "PAYMENT_STATUS", "BENCHMARK_RATES", "INSTRUMENT_PRODUCTS", "ACCOUNTS", "OTHER"]); export const statementType = z.enum(["BOOKED", "PENDING"]); export const connectionReportDetails = z.object({type: reportType, statementType: statementType}); export const contentType = z.enum(["application/vnd.iso20022.pain.001.001.03+xml", "application/vnd.iso20022.pain.001.001.03.ch.02+xml", "application/vnd.iso20022.pain.001.001.09+xml", "application/vnd.iso20022.pain.001.001.09.ch.03+xml", "application/vnd.iso20022.pain.002.001.03+xml", "application/vnd.iso20022.pain.002.001.10+xml", "application/vnd.iso20022.pain.008.001.02+xml", "application/vnd.iso20022.pain.008.001.02.ch.03+xml", "application/vnd.iso20022.pain.008.001.03+xml", "application/vnd.iso20022.pain.008.001.08+xml", "application/vnd.iso20022.camt.052.001.02+xml", "application/vnd.iso20022.camt.052.001.03+xml", "application/vnd.iso20022.camt.052.001.04+xml", "application/vnd.iso20022.camt.052.001.08+xml", "application/vnd.iso20022.camt.053.001.02+xml", "application/vnd.iso20022.camt.053.001.03+xml", "application/vnd.iso20022.camt.053.001.04+xml", "application/vnd.iso20022.camt.053.001.08+xml", "application/vnd.iso20022.camt.053.001.10+xml", "application/vnd.iso20022.camt.053.001.11+xml", "application/vnd.iso20022.camt.053.001.12+xml", "application/vnd.iso20022.camt.054.001.02+xml", "application/vnd.iso20022.pacs.002.001.10+xml", "application/vnd.iso20022.pacs.008.001.02+xml", "application/vnd.iso20022.pacs.008.001.08+xml", "application/vnd.swift.mt.101", "application/vnd.swift.mt.103", "application/vnd.swift.mt.900", "application/vnd.swift.mt.940", "application/vnd.swift.mt.942", "application/vnd.bai.bai2", "application/vnd.bgc.autogiro.payee", "application/vnd.bgc.autogiro.payments.rejected", "application/vnd.bgc.autogiro.payments.spec", "application/vnd.bgc.autogiro.mandate", "application/vnd.bgc.payins.bgmax", "application/vnd.nacha.ach", "application/vnd.atlar.testbank.mandate+json", "application/vnd.atlar.testbank.transaction+json", "application/vnd.atlar.connectivity.proprietary", "application/vnd.atlar.connectivity.proprietary+json", "application/vnd.atlar.connectivity.proprietary+xml", "application/vnd.atlar.connectivity.proprietary+csv", "application/vnd.atlar.connectivity.v2.investment-statement+json", "application/vnd.atlar.connectivity.v2.accounting-statement+json", "application/vnd.atlar.connectivity.v2.fx-rate-statement+json", "application/vnd.atlar.connectivity.v2.benchmark-rate-statement+json", "application/vnd.atlar.connectivity.v2.instrument-product-statement+json", "application/vnd.atlar.connectivity.v2.statement+json", "application/vnd.atlar.connectivity.v2.statement+csv", "application/vnd.deutsche.wealth-online+csv", "application/vnd.m2.m006.m001+xml", "application/vnd.m2.m006.m005+xml", "application/vnd.ebics.htd.v30+xml", "application/vnd.ebics.hac.v25+xml", "application/vnd.ebics.hac.v30+xml", "application/vnd.jpm.daily-feed+zip", "application/vnd.jpm.morgan-money.balance-report+csv", "application/vnd.jpm.morgan-money.transaction-report+csv", "application/vnd.jpm.soci.holdings+csv", "application/vnd.jpm.soci.transactions+csv", "application/vnd.jpm.soci.cash-balance+csv", "application/vnd.nordea.investments.abasec.pos+csv", "application/vnd.nordea.investments.abasec.tra+csv", "application/vnd.blackrock.cachematrix.balance+csv", "application/vnd.blackrock.cachematrix.transactions+csv", "application/vnd.adyen.balance-platform.statement-report+csv", "application/vnd.ms-excel", "application/x-ofx", "application/json", "application/zip", "application/pdf", "text/plain", "text/csv", "application/vnd.edi.820", "application/vnd.edi.824", "application/vnd.edi.997"]); export const contentMetadata = z.object({contentType: contentType, size: z.number().int(), checksum: z.string(), name: z.string()}); export const metadata = z.record(z.string(), z.string()).nullable(); export const resourceVersion = z.number().int().gte(1); export const eTag = z.string(); export const createdTimestamp = z.string(); export const updatedTimestamp = z.string(); export const connectionReport = z.object({organizationId: organizationID, connectionId: resourceID, id: resourceID, details: connectionReportDetails, content: contentMetadata, converted: z.boolean(), thirdPartyCodes: z.array(z.string()).optional(), metadata: metadata.optional(), version: resourceVersion, etag: eTag, created: createdTimestamp, updated: updatedTimestamp}); export const getApiConnectivityV2betaConnectionsCidReportsResponse = z.object({items: z.array(connectionReport), nextToken: z.string(), token: z.string(), limit: z.number().int()}); 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 }; /** * List connection reports * * GET /connectivity/v2beta/connections/{cid}/reports */ export const getApiConnectivityV2betaConnectionsCidReports = async (args: GetApiConnectivityV2betaConnectionsCidReportsArgs, options?: GetApiConnectivityV2betaConnectionsCidReportsOptions) => { const {baseUrl = "https://api.atlar.com", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.limit != null) query.append("limit", String(args.limit)) if (args.token != null) query.append("token", String(args.token)) if (args.from != null) query.append("from", String(args.from)) if (args.to != null) query.append("to", String(args.to)) if (args.type != null) query.append("type", String(args.type)) if (args.statementType != null) query.append("statementType", String(args.statementType)) if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/connectivity/v2beta/connections/${encodeURIComponent(String(args.cid))}/reports${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(getApiConnectivityV2betaConnectionsCidReportsResponse, await res.json()) };