import {z} from 'zod' export type SyncFinancialConnectionsDataRequest = Record; export type CreateApiV1FinancialConnectionsSyncArgs = {'Fuse-Verification': string, 'Fuse-Client-Id': string, 'Fuse-Api-Key': string, 'Plaid-Client-Id'?: string | undefined, 'Plaid-Secret'?: string | undefined, 'Teller-Application-Id'?: string | undefined, 'Teller-Certificate'?: string | undefined, 'Teller-Private-Key'?: string | undefined, 'Teller-Token-Signing-Key'?: string | undefined, 'Teller-Signing-Secret'?: string | undefined, 'Mx-Client-Id'?: string | undefined, 'Mx-Api-Key'?: string | undefined, 'Snaptrade-Client-Id'?: string | undefined, 'Snaptrade-Consumer-Key'?: string | undefined, 'Flinks-Ca-Customer-Id'?: string | undefined, 'Flinks-Us-Customer-Id'?: string | undefined, 'Flinks-Us-Instance-Id'?: string | undefined, 'Flinks-Ca-Instance-Id'?: string | undefined, 'Mono-Public-Key'?: string | undefined, 'Mono-Secret-Key'?: string | undefined, 'Mono-Webhook-Secret'?: string | undefined, 'TrueLayer-Client-Id'?: string | undefined, 'TrueLayer-Client-Secret'?: string | undefined, 'Finverse-Client-Id'?: string | undefined, 'Finverse-Client-Secret'?: string | undefined, 'Belvo-Secret-Id'?: string | undefined, 'Belvo-Secret-Password'?: string | undefined, 'Finicity-Partner-Secret'?: string | undefined, 'Finicity-Partner-Id'?: string | undefined, 'Finicity-App-Key'?: string | undefined, 'Basiq-Api-Key'?: string | undefined, 'Akoya-Client-Id'?: string | undefined, 'Akoya-Client-Secret'?: string | undefined, 'SaltEdge-App-Id'?: string | undefined, 'SaltEdge-App-Secret'?: string | undefined, body: SyncFinancialConnectionsDataRequest}; export type CreateApiV1FinancialConnectionsSyncOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const syncFinancialConnectionsDataResponse = z.object({message: z.string().optional(), request_id: 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 }; /** * Sync financial connections data * * POST /v1/financial_connections/sync */ export const createApiV1FinancialConnectionsSync = async (args: CreateApiV1FinancialConnectionsSyncArgs, options?: CreateApiV1FinancialConnectionsSyncOptions) => { const {baseUrl = "https://sandbox-api.letsfuse.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['Fuse-Verification'] != null) headers.set("Fuse-Verification", String(args['Fuse-Verification'])) if (args['Fuse-Client-Id'] != null) headers.set("Fuse-Client-Id", String(args['Fuse-Client-Id'])) if (args['Fuse-Api-Key'] != null) headers.set("Fuse-Api-Key", String(args['Fuse-Api-Key'])) if (args['Plaid-Client-Id'] != null) headers.set("Plaid-Client-Id", String(args['Plaid-Client-Id'])) if (args['Plaid-Secret'] != null) headers.set("Plaid-Secret", String(args['Plaid-Secret'])) if (args['Teller-Application-Id'] != null) headers.set("Teller-Application-Id", String(args['Teller-Application-Id'])) if (args['Teller-Certificate'] != null) headers.set("Teller-Certificate", String(args['Teller-Certificate'])) if (args['Teller-Private-Key'] != null) headers.set("Teller-Private-Key", String(args['Teller-Private-Key'])) if (args['Teller-Token-Signing-Key'] != null) headers.set("Teller-Token-Signing-Key", String(args['Teller-Token-Signing-Key'])) if (args['Teller-Signing-Secret'] != null) headers.set("Teller-Signing-Secret", String(args['Teller-Signing-Secret'])) if (args['Mx-Client-Id'] != null) headers.set("Mx-Client-Id", String(args['Mx-Client-Id'])) if (args['Mx-Api-Key'] != null) headers.set("Mx-Api-Key", String(args['Mx-Api-Key'])) if (args['Snaptrade-Client-Id'] != null) headers.set("Snaptrade-Client-Id", String(args['Snaptrade-Client-Id'])) if (args['Snaptrade-Consumer-Key'] != null) headers.set("Snaptrade-Consumer-Key", String(args['Snaptrade-Consumer-Key'])) if (args['Flinks-Ca-Customer-Id'] != null) headers.set("Flinks-Ca-Customer-Id", String(args['Flinks-Ca-Customer-Id'])) if (args['Flinks-Us-Customer-Id'] != null) headers.set("Flinks-Us-Customer-Id", String(args['Flinks-Us-Customer-Id'])) if (args['Flinks-Us-Instance-Id'] != null) headers.set("Flinks-Us-Instance-Id", String(args['Flinks-Us-Instance-Id'])) if (args['Flinks-Ca-Instance-Id'] != null) headers.set("Flinks-Ca-Instance-Id", String(args['Flinks-Ca-Instance-Id'])) if (args['Mono-Public-Key'] != null) headers.set("Mono-Public-Key", String(args['Mono-Public-Key'])) if (args['Mono-Secret-Key'] != null) headers.set("Mono-Secret-Key", String(args['Mono-Secret-Key'])) if (args['Mono-Webhook-Secret'] != null) headers.set("Mono-Webhook-Secret", String(args['Mono-Webhook-Secret'])) if (args['TrueLayer-Client-Id'] != null) headers.set("TrueLayer-Client-Id", String(args['TrueLayer-Client-Id'])) if (args['TrueLayer-Client-Secret'] != null) headers.set("TrueLayer-Client-Secret", String(args['TrueLayer-Client-Secret'])) if (args['Finverse-Client-Id'] != null) headers.set("Finverse-Client-Id", String(args['Finverse-Client-Id'])) if (args['Finverse-Client-Secret'] != null) headers.set("Finverse-Client-Secret", String(args['Finverse-Client-Secret'])) if (args['Belvo-Secret-Id'] != null) headers.set("Belvo-Secret-Id", String(args['Belvo-Secret-Id'])) if (args['Belvo-Secret-Password'] != null) headers.set("Belvo-Secret-Password", String(args['Belvo-Secret-Password'])) if (args['Finicity-Partner-Secret'] != null) headers.set("Finicity-Partner-Secret", String(args['Finicity-Partner-Secret'])) if (args['Finicity-Partner-Id'] != null) headers.set("Finicity-Partner-Id", String(args['Finicity-Partner-Id'])) if (args['Finicity-App-Key'] != null) headers.set("Finicity-App-Key", String(args['Finicity-App-Key'])) if (args['Basiq-Api-Key'] != null) headers.set("Basiq-Api-Key", String(args['Basiq-Api-Key'])) if (args['Akoya-Client-Id'] != null) headers.set("Akoya-Client-Id", String(args['Akoya-Client-Id'])) if (args['Akoya-Client-Secret'] != null) headers.set("Akoya-Client-Secret", String(args['Akoya-Client-Secret'])) if (args['SaltEdge-App-Id'] != null) headers.set("SaltEdge-App-Id", String(args['SaltEdge-App-Id'])) if (args['SaltEdge-App-Secret'] != null) headers.set("SaltEdge-App-Secret", String(args['SaltEdge-App-Secret'])) const url = `${baseUrl.replace(/\/+$/, '')}/v1/financial_connections/sync${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 validateResponse(syncFinancialConnectionsDataResponse, await res.json()) };