/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { catchUnrecognizedEnum, OpenEnum, Unrecognized, } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AcatsAsset, AcatsAsset$inboundSchema, AcatsAsset$Outbound, AcatsAsset$outboundSchema, } from "./acatsasset.js"; /** * The external account information */ export type ExternalAccount = { /** * The account identifier The account number for external communications */ accountNumber?: string | undefined; /** * Account owner title */ accountTitle?: string | undefined; /** * The NSCC brokerage / clearing house identifier */ participantNumber?: string | undefined; }; /** * The delivering party information */ export type Deliverer = { /** * The internal apex account id */ apexAccountId?: string | undefined; /** * The external account information */ externalAccount?: ExternalAccount | null | undefined; }; /** * The direction of the transfer */ export enum AcatsTransferDirection { DirectionUnspecified = "DIRECTION_UNSPECIFIED", Outgoing = "OUTGOING", Incoming = "INCOMING", } /** * The direction of the transfer */ export type AcatsTransferDirectionOpen = OpenEnum< typeof AcatsTransferDirection >; /** * The NSCC transfer status */ export enum NsccStatus { NsccStatusUnspecified = "NSCC_STATUS_UNSPECIFIED", Request = "REQUEST", RequestAdjust = "REQUEST_ADJUST", RequestAdjustPast = "REQUEST_ADJUST_PAST", RequestPast = "REQUEST_PAST", RequestReject = "REQUEST_REJECT", Review = "REVIEW", ReviewAdjustDeliverer = "REVIEW_ADJUST_DELIVERER", ReviewError = "REVIEW_ERROR", ReviewAccelerate = "REVIEW_ACCELERATE", ReviewAdjustReceiverAccelerate = "REVIEW_ADJUST_RECEIVER_ACCELERATE", SettlePrep = "SETTLE_PREP", SettleClose = "SETTLE_CLOSE", ClosePurge = "CLOSE_PURGE", PartialRequest = "PARTIAL_REQUEST", MemoPurgePartialTransferRequestReceiver = "MEMO_PURGE_PARTIAL_TRANSFER_REQUEST_RECEIVER", Reject = "REJECT", SystemPurge = "SYSTEM_PURGE", } /** * The NSCC transfer status */ export type NsccStatusOpen = OpenEnum; /** * The external account information */ export type AcatsTransferExternalAccount = { /** * The account identifier The account number for external communications */ accountNumber?: string | undefined; /** * Account owner title */ accountTitle?: string | undefined; /** * The NSCC brokerage / clearing house identifier */ participantNumber?: string | undefined; }; /** * The receiving party information */ export type Receiver = { /** * The internal apex account id */ apexAccountId?: string | undefined; /** * The external account information */ externalAccount?: AcatsTransferExternalAccount | null | undefined; }; /** * The reject code */ export enum RejectCode { RejectCodeUnspecified = "REJECT_CODE_UNSPECIFIED", RejectCodeSsnTaxIdMismatch = "REJECT_CODE_SSN_TAX_ID_MISMATCH", RejectCodeAccountTitleMismatch = "REJECT_CODE_ACCOUNT_TITLE_MISMATCH", RejectCodeDocumentationNeeded = "REJECT_CODE_DOCUMENTATION_NEEDED", RejectCodeAccountFlat = "REJECT_CODE_ACCOUNT_FLAT", RejectCodeInvalidAccountNumber = "REJECT_CODE_INVALID_ACCOUNT_NUMBER", RejectCodeDuplicate = "REJECT_CODE_DUPLICATE", RejectCodeAccountInDistributionOrTransfer = "REJECT_CODE_ACCOUNT_IN_DISTRIBUTION_OR_TRANSFER", RejectCodeClientRescinded = "REJECT_CODE_CLIENT_RESCINDED", RejectCodeMissingAuthorizationSignature = "REJECT_CODE_MISSING_AUTHORIZATION_SIGNATURE", RejectCodeAccountViolatesCreditPolicyOfReceivingFirm = "REJECT_CODE_ACCOUNT_VIOLATES_CREDIT_POLICY_OF_RECEIVING_FIRM", RejectCodeUnrecognizedForResidualCreditBalance = "REJECT_CODE_UNRECOGNIZED_FOR_RESIDUAL_CREDIT_BALANCE", RejectCodePartialTransferDeliverer = "REJECT_CODE_PARTIAL_TRANSFER_DELIVERER", RejectCodeFailReversal = "REJECT_CODE_FAIL_REVERSAL", RejectCodeReclaim = "REJECT_CODE_RECLAIM", RejectCodeMutualFundCleanup = "REJECT_CODE_MUTUAL_FUND_CLEANUP", } /** * The reject code */ export type RejectCodeOpen = OpenEnum; /** * The transfer state */ export enum AcatsTransferState { StateUnspecified = "STATE_UNSPECIFIED", Received = "RECEIVED", Submitted = "SUBMITTED", Rejected = "REJECTED", PendingContraResponse = "PENDING_CONTRA_RESPONSE", Error = "ERROR", Accepted = "ACCEPTED", PendingReview = "PENDING_REVIEW", PendingRejection = "PENDING_REJECTION", PendingSettlement = "PENDING_SETTLEMENT", PendingBookkeeping = "PENDING_BOOKKEEPING", Completed = "COMPLETED", Purged = "PURGED", } /** * The transfer state */ export type AcatsTransferStateOpen = OpenEnum; /** * The type of transfer */ export enum TransferType { TransferTypeUnspecified = "TRANSFER_TYPE_UNSPECIFIED", FailReversalBrokerToBrokerOnly = "FAIL_REVERSAL_BROKER_TO_BROKER_ONLY", FullTransfer = "FULL_TRANSFER", MutualFundCleanup = "MUTUAL_FUND_CLEANUP", PartialTransferDeliverer = "PARTIAL_TRANSFER_DELIVERER", PartialTransferReceiver = "PARTIAL_TRANSFER_RECEIVER", PositionTransferFundFirmToMutualFundCompanyOnly = "POSITION_TRANSFER_FUND_FIRM_TO_MUTUAL_FUND_COMPANY_ONLY", Reclaim = "RECLAIM", ResidualCredit = "RESIDUAL_CREDIT", } /** * The type of transfer */ export type TransferTypeOpen = OpenEnum; /** * An account transfer which contains the receiving and delivering party information, assets being transferred, NSCC status information, etc. */ export type AcatsTransfer = { /** * The NSCC transfer identifier */ acatControlNumber?: string | undefined; /** * The assets being transferred (Cash, Equities, etc.) */ assets?: Array | undefined; /** * User supplied comment */ comment?: string | undefined; /** * The transfer creation timestamp */ createTime?: Date | null | undefined; /** * The delivering party information */ deliverer?: Deliverer | null | undefined; /** * The direction of the transfer */ direction?: AcatsTransferDirectionOpen | undefined; /** * The service generated name of the transfer. Format: correspondents/{correspondent_id}/accounts/{account_id}/transfers/{transfer_id} */ name?: string | undefined; /** * The NSCC transfer status */ nsccStatus?: NsccStatusOpen | undefined; /** * An associated NSCC transfer identifier, if applicable */ originalControlNumber?: string | undefined; /** * The receiving party information */ receiver?: Receiver | null | undefined; /** * The reject code */ rejectCode?: RejectCodeOpen | undefined; /** * The transfer state */ state?: AcatsTransferStateOpen | undefined; /** * A reason for the state if applicable */ stateReason?: string | undefined; /** * The type of transfer */ transferType?: TransferTypeOpen | undefined; }; /** @internal */ export const ExternalAccount$inboundSchema: z.ZodType< ExternalAccount, z.ZodTypeDef, unknown > = z.object({ account_number: z.string().optional(), account_title: z.string().optional(), participant_number: z.string().optional(), }).transform((v) => { return remap$(v, { "account_number": "accountNumber", "account_title": "accountTitle", "participant_number": "participantNumber", }); }); /** @internal */ export type ExternalAccount$Outbound = { account_number?: string | undefined; account_title?: string | undefined; participant_number?: string | undefined; }; /** @internal */ export const ExternalAccount$outboundSchema: z.ZodType< ExternalAccount$Outbound, z.ZodTypeDef, ExternalAccount > = z.object({ accountNumber: z.string().optional(), accountTitle: z.string().optional(), participantNumber: z.string().optional(), }).transform((v) => { return remap$(v, { accountNumber: "account_number", accountTitle: "account_title", participantNumber: "participant_number", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ExternalAccount$ { /** @deprecated use `ExternalAccount$inboundSchema` instead. */ export const inboundSchema = ExternalAccount$inboundSchema; /** @deprecated use `ExternalAccount$outboundSchema` instead. */ export const outboundSchema = ExternalAccount$outboundSchema; /** @deprecated use `ExternalAccount$Outbound` instead. */ export type Outbound = ExternalAccount$Outbound; } export function externalAccountToJSON( externalAccount: ExternalAccount, ): string { return JSON.stringify(ExternalAccount$outboundSchema.parse(externalAccount)); } export function externalAccountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ExternalAccount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ExternalAccount' from JSON`, ); } /** @internal */ export const Deliverer$inboundSchema: z.ZodType< Deliverer, z.ZodTypeDef, unknown > = z.object({ apex_account_id: z.string().optional(), external_account: z.nullable(z.lazy(() => ExternalAccount$inboundSchema)) .optional(), }).transform((v) => { return remap$(v, { "apex_account_id": "apexAccountId", "external_account": "externalAccount", }); }); /** @internal */ export type Deliverer$Outbound = { apex_account_id?: string | undefined; external_account?: ExternalAccount$Outbound | null | undefined; }; /** @internal */ export const Deliverer$outboundSchema: z.ZodType< Deliverer$Outbound, z.ZodTypeDef, Deliverer > = z.object({ apexAccountId: z.string().optional(), externalAccount: z.nullable(z.lazy(() => ExternalAccount$outboundSchema)) .optional(), }).transform((v) => { return remap$(v, { apexAccountId: "apex_account_id", externalAccount: "external_account", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Deliverer$ { /** @deprecated use `Deliverer$inboundSchema` instead. */ export const inboundSchema = Deliverer$inboundSchema; /** @deprecated use `Deliverer$outboundSchema` instead. */ export const outboundSchema = Deliverer$outboundSchema; /** @deprecated use `Deliverer$Outbound` instead. */ export type Outbound = Deliverer$Outbound; } export function delivererToJSON(deliverer: Deliverer): string { return JSON.stringify(Deliverer$outboundSchema.parse(deliverer)); } export function delivererFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Deliverer$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Deliverer' from JSON`, ); } /** @internal */ export const AcatsTransferDirection$inboundSchema: z.ZodType< AcatsTransferDirectionOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(AcatsTransferDirection), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const AcatsTransferDirection$outboundSchema: z.ZodType< AcatsTransferDirectionOpen, z.ZodTypeDef, AcatsTransferDirectionOpen > = z.union([ z.nativeEnum(AcatsTransferDirection), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace AcatsTransferDirection$ { /** @deprecated use `AcatsTransferDirection$inboundSchema` instead. */ export const inboundSchema = AcatsTransferDirection$inboundSchema; /** @deprecated use `AcatsTransferDirection$outboundSchema` instead. */ export const outboundSchema = AcatsTransferDirection$outboundSchema; } /** @internal */ export const NsccStatus$inboundSchema: z.ZodType< NsccStatusOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(NsccStatus), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const NsccStatus$outboundSchema: z.ZodType< NsccStatusOpen, z.ZodTypeDef, NsccStatusOpen > = z.union([ z.nativeEnum(NsccStatus), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace NsccStatus$ { /** @deprecated use `NsccStatus$inboundSchema` instead. */ export const inboundSchema = NsccStatus$inboundSchema; /** @deprecated use `NsccStatus$outboundSchema` instead. */ export const outboundSchema = NsccStatus$outboundSchema; } /** @internal */ export const AcatsTransferExternalAccount$inboundSchema: z.ZodType< AcatsTransferExternalAccount, z.ZodTypeDef, unknown > = z.object({ account_number: z.string().optional(), account_title: z.string().optional(), participant_number: z.string().optional(), }).transform((v) => { return remap$(v, { "account_number": "accountNumber", "account_title": "accountTitle", "participant_number": "participantNumber", }); }); /** @internal */ export type AcatsTransferExternalAccount$Outbound = { account_number?: string | undefined; account_title?: string | undefined; participant_number?: string | undefined; }; /** @internal */ export const AcatsTransferExternalAccount$outboundSchema: z.ZodType< AcatsTransferExternalAccount$Outbound, z.ZodTypeDef, AcatsTransferExternalAccount > = z.object({ accountNumber: z.string().optional(), accountTitle: z.string().optional(), participantNumber: z.string().optional(), }).transform((v) => { return remap$(v, { accountNumber: "account_number", accountTitle: "account_title", participantNumber: "participant_number", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace AcatsTransferExternalAccount$ { /** @deprecated use `AcatsTransferExternalAccount$inboundSchema` instead. */ export const inboundSchema = AcatsTransferExternalAccount$inboundSchema; /** @deprecated use `AcatsTransferExternalAccount$outboundSchema` instead. */ export const outboundSchema = AcatsTransferExternalAccount$outboundSchema; /** @deprecated use `AcatsTransferExternalAccount$Outbound` instead. */ export type Outbound = AcatsTransferExternalAccount$Outbound; } export function acatsTransferExternalAccountToJSON( acatsTransferExternalAccount: AcatsTransferExternalAccount, ): string { return JSON.stringify( AcatsTransferExternalAccount$outboundSchema.parse( acatsTransferExternalAccount, ), ); } export function acatsTransferExternalAccountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AcatsTransferExternalAccount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AcatsTransferExternalAccount' from JSON`, ); } /** @internal */ export const Receiver$inboundSchema: z.ZodType< Receiver, z.ZodTypeDef, unknown > = z.object({ apex_account_id: z.string().optional(), external_account: z.nullable( z.lazy(() => AcatsTransferExternalAccount$inboundSchema), ).optional(), }).transform((v) => { return remap$(v, { "apex_account_id": "apexAccountId", "external_account": "externalAccount", }); }); /** @internal */ export type Receiver$Outbound = { apex_account_id?: string | undefined; external_account?: AcatsTransferExternalAccount$Outbound | null | undefined; }; /** @internal */ export const Receiver$outboundSchema: z.ZodType< Receiver$Outbound, z.ZodTypeDef, Receiver > = z.object({ apexAccountId: z.string().optional(), externalAccount: z.nullable( z.lazy(() => AcatsTransferExternalAccount$outboundSchema), ).optional(), }).transform((v) => { return remap$(v, { apexAccountId: "apex_account_id", externalAccount: "external_account", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Receiver$ { /** @deprecated use `Receiver$inboundSchema` instead. */ export const inboundSchema = Receiver$inboundSchema; /** @deprecated use `Receiver$outboundSchema` instead. */ export const outboundSchema = Receiver$outboundSchema; /** @deprecated use `Receiver$Outbound` instead. */ export type Outbound = Receiver$Outbound; } export function receiverToJSON(receiver: Receiver): string { return JSON.stringify(Receiver$outboundSchema.parse(receiver)); } export function receiverFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Receiver$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Receiver' from JSON`, ); } /** @internal */ export const RejectCode$inboundSchema: z.ZodType< RejectCodeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(RejectCode), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const RejectCode$outboundSchema: z.ZodType< RejectCodeOpen, z.ZodTypeDef, RejectCodeOpen > = z.union([ z.nativeEnum(RejectCode), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace RejectCode$ { /** @deprecated use `RejectCode$inboundSchema` instead. */ export const inboundSchema = RejectCode$inboundSchema; /** @deprecated use `RejectCode$outboundSchema` instead. */ export const outboundSchema = RejectCode$outboundSchema; } /** @internal */ export const AcatsTransferState$inboundSchema: z.ZodType< AcatsTransferStateOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(AcatsTransferState), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const AcatsTransferState$outboundSchema: z.ZodType< AcatsTransferStateOpen, z.ZodTypeDef, AcatsTransferStateOpen > = z.union([ z.nativeEnum(AcatsTransferState), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace AcatsTransferState$ { /** @deprecated use `AcatsTransferState$inboundSchema` instead. */ export const inboundSchema = AcatsTransferState$inboundSchema; /** @deprecated use `AcatsTransferState$outboundSchema` instead. */ export const outboundSchema = AcatsTransferState$outboundSchema; } /** @internal */ export const TransferType$inboundSchema: z.ZodType< TransferTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(TransferType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const TransferType$outboundSchema: z.ZodType< TransferTypeOpen, z.ZodTypeDef, TransferTypeOpen > = z.union([ z.nativeEnum(TransferType), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TransferType$ { /** @deprecated use `TransferType$inboundSchema` instead. */ export const inboundSchema = TransferType$inboundSchema; /** @deprecated use `TransferType$outboundSchema` instead. */ export const outboundSchema = TransferType$outboundSchema; } /** @internal */ export const AcatsTransfer$inboundSchema: z.ZodType< AcatsTransfer, z.ZodTypeDef, unknown > = z.object({ acat_control_number: z.string().optional(), assets: z.array(AcatsAsset$inboundSchema).optional(), comment: z.string().optional(), create_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), deliverer: z.nullable(z.lazy(() => Deliverer$inboundSchema)).optional(), direction: AcatsTransferDirection$inboundSchema.optional(), name: z.string().optional(), nscc_status: NsccStatus$inboundSchema.optional(), original_control_number: z.string().optional(), receiver: z.nullable(z.lazy(() => Receiver$inboundSchema)).optional(), reject_code: RejectCode$inboundSchema.optional(), state: AcatsTransferState$inboundSchema.optional(), state_reason: z.string().optional(), transfer_type: TransferType$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "acat_control_number": "acatControlNumber", "create_time": "createTime", "nscc_status": "nsccStatus", "original_control_number": "originalControlNumber", "reject_code": "rejectCode", "state_reason": "stateReason", "transfer_type": "transferType", }); }); /** @internal */ export type AcatsTransfer$Outbound = { acat_control_number?: string | undefined; assets?: Array | undefined; comment?: string | undefined; create_time?: string | null | undefined; deliverer?: Deliverer$Outbound | null | undefined; direction?: string | undefined; name?: string | undefined; nscc_status?: string | undefined; original_control_number?: string | undefined; receiver?: Receiver$Outbound | null | undefined; reject_code?: string | undefined; state?: string | undefined; state_reason?: string | undefined; transfer_type?: string | undefined; }; /** @internal */ export const AcatsTransfer$outboundSchema: z.ZodType< AcatsTransfer$Outbound, z.ZodTypeDef, AcatsTransfer > = z.object({ acatControlNumber: z.string().optional(), assets: z.array(AcatsAsset$outboundSchema).optional(), comment: z.string().optional(), createTime: z.nullable(z.date().transform(v => v.toISOString())).optional(), deliverer: z.nullable(z.lazy(() => Deliverer$outboundSchema)).optional(), direction: AcatsTransferDirection$outboundSchema.optional(), name: z.string().optional(), nsccStatus: NsccStatus$outboundSchema.optional(), originalControlNumber: z.string().optional(), receiver: z.nullable(z.lazy(() => Receiver$outboundSchema)).optional(), rejectCode: RejectCode$outboundSchema.optional(), state: AcatsTransferState$outboundSchema.optional(), stateReason: z.string().optional(), transferType: TransferType$outboundSchema.optional(), }).transform((v) => { return remap$(v, { acatControlNumber: "acat_control_number", createTime: "create_time", nsccStatus: "nscc_status", originalControlNumber: "original_control_number", rejectCode: "reject_code", stateReason: "state_reason", transferType: "transfer_type", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace AcatsTransfer$ { /** @deprecated use `AcatsTransfer$inboundSchema` instead. */ export const inboundSchema = AcatsTransfer$inboundSchema; /** @deprecated use `AcatsTransfer$outboundSchema` instead. */ export const outboundSchema = AcatsTransfer$outboundSchema; /** @deprecated use `AcatsTransfer$Outbound` instead. */ export type Outbound = AcatsTransfer$Outbound; } export function acatsTransferToJSON(acatsTransfer: AcatsTransfer): string { return JSON.stringify(AcatsTransfer$outboundSchema.parse(acatsTransfer)); } export function acatsTransferFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AcatsTransfer$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AcatsTransfer' from JSON`, ); }