/* * 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"; /** * The amount of the wire deposit being issued to the investor in USD */ export type WireDepositAmount = { /** * The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details */ value?: string | undefined; }; /** * The type of retirement contribution. */ export enum WireDepositType { TypeUnspecified = "TYPE_UNSPECIFIED", Regular = "REGULAR", Employee = "EMPLOYEE", Employer = "EMPLOYER", Recharacterization = "RECHARACTERIZATION", Rollover60Day = "ROLLOVER_60_DAY", RolloverDirect = "ROLLOVER_DIRECT", Transfer = "TRANSFER", TrusteeFee = "TRUSTEE_FEE", Conversion = "CONVERSION", Repayment = "REPAYMENT", ContributionNonReportable = "CONTRIBUTION_NON_REPORTABLE", } /** * The type of retirement contribution. */ export type WireDepositTypeOpen = OpenEnum; /** * The retirement contribution details */ export type WireDepositRetirementContribution = { /** * Tax year for which the contribution is applied. Current year is always valid; prior year is only valid before tax deadline. Must be in "YYYY" format. */ taxYear?: number | undefined; /** * The type of retirement contribution. */ type?: WireDepositTypeOpen | undefined; }; /** * The high level state of a transfer, one of: * * @remarks * - `PROCESSING` - The transfer is being processed and will be posted if successful. * - `PENDING_REVIEW` - The transfer is pending review and will continue processing if approved. * - `POSTED` - The transfer has been posted to the ledger and will be completed at the end of the processing window if not canceled first. * - `COMPLETED` - The transfer has been batched and completed. * - `REJECTED` - The transfer was rejected. * - `CANCELED` - The transfer was canceled. * - `RETURNED` - The transfer was returned. * - `POSTPONED` - The transfer is postponed and will resume processing during the next processing window. */ export enum WireDepositStateState { StateUnspecified = "STATE_UNSPECIFIED", Processing = "PROCESSING", PendingReview = "PENDING_REVIEW", Posted = "POSTED", Completed = "COMPLETED", Rejected = "REJECTED", Canceled = "CANCELED", Returned = "RETURNED", Postponed = "POSTPONED", } /** * The high level state of a transfer, one of: * * @remarks * - `PROCESSING` - The transfer is being processed and will be posted if successful. * - `PENDING_REVIEW` - The transfer is pending review and will continue processing if approved. * - `POSTED` - The transfer has been posted to the ledger and will be completed at the end of the processing window if not canceled first. * - `COMPLETED` - The transfer has been batched and completed. * - `REJECTED` - The transfer was rejected. * - `CANCELED` - The transfer was canceled. * - `RETURNED` - The transfer was returned. * - `POSTPONED` - The transfer is postponed and will resume processing during the next processing window. */ export type WireDepositStateStateOpen = OpenEnum; /** * The current state of the wire deposit */ export type WireDepositState = { /** * The user or service that triggered the state update. */ actor?: string | undefined; /** * Additional description of the transfer state. */ message?: string | undefined; /** * Additional metadata relating to the transfer state. Included data depends on the state, e.g.: * * @remarks * - Rejection reasons are included when the `state` is `REJECTED` * - Reason and comment are included when `state` is `CANCELED` */ metadata?: { [k: string]: any } | null | undefined; /** * The high level state of a transfer, one of: * * @remarks * - `PROCESSING` - The transfer is being processed and will be posted if successful. * - `PENDING_REVIEW` - The transfer is pending review and will continue processing if approved. * - `POSTED` - The transfer has been posted to the ledger and will be completed at the end of the processing window if not canceled first. * - `COMPLETED` - The transfer has been batched and completed. * - `REJECTED` - The transfer was rejected. * - `CANCELED` - The transfer was canceled. * - `RETURNED` - The transfer was returned. * - `POSTPONED` - The transfer is postponed and will resume processing during the next processing window. */ state?: WireDepositStateStateOpen | undefined; /** * The time of the state update. */ updateTime?: Date | null | undefined; }; /** * A deposit transfer using the wire mechanism */ export type WireDeposit = { /** * The amount of the wire deposit being issued to the investor in USD */ amount?: WireDepositAmount | null | undefined; /** * External reference identifier supplied by the bank */ bankReferenceId?: string | undefined; /** * The FedWire reference number for the deposit */ fedReferenceNumber?: string | undefined; /** * Full name of the wire deposit which contains account_id and deposit transaction id */ name?: string | undefined; /** * The retirement contribution details */ retirementContribution?: WireDepositRetirementContribution | null | undefined; /** * Whether this wire deposit is a return of a wire withdrawal */ returnedWireWithdrawal?: boolean | undefined; /** * The current state of the wire deposit */ state?: WireDepositState | null | undefined; /** * The wire instructions received by Apex's bank for the wire deposit */ wireInstructions?: Array | undefined; }; /** @internal */ export const WireDepositAmount$inboundSchema: z.ZodType< WireDepositAmount, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type WireDepositAmount$Outbound = { value?: string | undefined; }; /** @internal */ export const WireDepositAmount$outboundSchema: z.ZodType< WireDepositAmount$Outbound, z.ZodTypeDef, WireDepositAmount > = z.object({ value: z.string().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace WireDepositAmount$ { /** @deprecated use `WireDepositAmount$inboundSchema` instead. */ export const inboundSchema = WireDepositAmount$inboundSchema; /** @deprecated use `WireDepositAmount$outboundSchema` instead. */ export const outboundSchema = WireDepositAmount$outboundSchema; /** @deprecated use `WireDepositAmount$Outbound` instead. */ export type Outbound = WireDepositAmount$Outbound; } export function wireDepositAmountToJSON( wireDepositAmount: WireDepositAmount, ): string { return JSON.stringify( WireDepositAmount$outboundSchema.parse(wireDepositAmount), ); } export function wireDepositAmountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WireDepositAmount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WireDepositAmount' from JSON`, ); } /** @internal */ export const WireDepositType$inboundSchema: z.ZodType< WireDepositTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(WireDepositType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const WireDepositType$outboundSchema: z.ZodType< WireDepositTypeOpen, z.ZodTypeDef, WireDepositTypeOpen > = z.union([ z.nativeEnum(WireDepositType), 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 WireDepositType$ { /** @deprecated use `WireDepositType$inboundSchema` instead. */ export const inboundSchema = WireDepositType$inboundSchema; /** @deprecated use `WireDepositType$outboundSchema` instead. */ export const outboundSchema = WireDepositType$outboundSchema; } /** @internal */ export const WireDepositRetirementContribution$inboundSchema: z.ZodType< WireDepositRetirementContribution, z.ZodTypeDef, unknown > = z.object({ tax_year: z.number().int().optional(), type: WireDepositType$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "tax_year": "taxYear", }); }); /** @internal */ export type WireDepositRetirementContribution$Outbound = { tax_year?: number | undefined; type?: string | undefined; }; /** @internal */ export const WireDepositRetirementContribution$outboundSchema: z.ZodType< WireDepositRetirementContribution$Outbound, z.ZodTypeDef, WireDepositRetirementContribution > = z.object({ taxYear: z.number().int().optional(), type: WireDepositType$outboundSchema.optional(), }).transform((v) => { return remap$(v, { taxYear: "tax_year", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace WireDepositRetirementContribution$ { /** @deprecated use `WireDepositRetirementContribution$inboundSchema` instead. */ export const inboundSchema = WireDepositRetirementContribution$inboundSchema; /** @deprecated use `WireDepositRetirementContribution$outboundSchema` instead. */ export const outboundSchema = WireDepositRetirementContribution$outboundSchema; /** @deprecated use `WireDepositRetirementContribution$Outbound` instead. */ export type Outbound = WireDepositRetirementContribution$Outbound; } export function wireDepositRetirementContributionToJSON( wireDepositRetirementContribution: WireDepositRetirementContribution, ): string { return JSON.stringify( WireDepositRetirementContribution$outboundSchema.parse( wireDepositRetirementContribution, ), ); } export function wireDepositRetirementContributionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WireDepositRetirementContribution$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WireDepositRetirementContribution' from JSON`, ); } /** @internal */ export const WireDepositStateState$inboundSchema: z.ZodType< WireDepositStateStateOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(WireDepositStateState), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const WireDepositStateState$outboundSchema: z.ZodType< WireDepositStateStateOpen, z.ZodTypeDef, WireDepositStateStateOpen > = z.union([ z.nativeEnum(WireDepositStateState), 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 WireDepositStateState$ { /** @deprecated use `WireDepositStateState$inboundSchema` instead. */ export const inboundSchema = WireDepositStateState$inboundSchema; /** @deprecated use `WireDepositStateState$outboundSchema` instead. */ export const outboundSchema = WireDepositStateState$outboundSchema; } /** @internal */ export const WireDepositState$inboundSchema: z.ZodType< WireDepositState, z.ZodTypeDef, unknown > = z.object({ actor: z.string().optional(), message: z.string().optional(), metadata: z.nullable(z.record(z.any())).optional(), state: WireDepositStateState$inboundSchema.optional(), update_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }).transform((v) => { return remap$(v, { "update_time": "updateTime", }); }); /** @internal */ export type WireDepositState$Outbound = { actor?: string | undefined; message?: string | undefined; metadata?: { [k: string]: any } | null | undefined; state?: string | undefined; update_time?: string | null | undefined; }; /** @internal */ export const WireDepositState$outboundSchema: z.ZodType< WireDepositState$Outbound, z.ZodTypeDef, WireDepositState > = z.object({ actor: z.string().optional(), message: z.string().optional(), metadata: z.nullable(z.record(z.any())).optional(), state: WireDepositStateState$outboundSchema.optional(), updateTime: z.nullable(z.date().transform(v => v.toISOString())).optional(), }).transform((v) => { return remap$(v, { updateTime: "update_time", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace WireDepositState$ { /** @deprecated use `WireDepositState$inboundSchema` instead. */ export const inboundSchema = WireDepositState$inboundSchema; /** @deprecated use `WireDepositState$outboundSchema` instead. */ export const outboundSchema = WireDepositState$outboundSchema; /** @deprecated use `WireDepositState$Outbound` instead. */ export type Outbound = WireDepositState$Outbound; } export function wireDepositStateToJSON( wireDepositState: WireDepositState, ): string { return JSON.stringify( WireDepositState$outboundSchema.parse(wireDepositState), ); } export function wireDepositStateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WireDepositState$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WireDepositState' from JSON`, ); } /** @internal */ export const WireDeposit$inboundSchema: z.ZodType< WireDeposit, z.ZodTypeDef, unknown > = z.object({ amount: z.nullable(z.lazy(() => WireDepositAmount$inboundSchema)).optional(), bank_reference_id: z.string().optional(), fed_reference_number: z.string().optional(), name: z.string().optional(), retirement_contribution: z.nullable( z.lazy(() => WireDepositRetirementContribution$inboundSchema), ).optional(), returned_wire_withdrawal: z.boolean().optional(), state: z.nullable(z.lazy(() => WireDepositState$inboundSchema)).optional(), wire_instructions: z.array(z.string()).optional(), }).transform((v) => { return remap$(v, { "bank_reference_id": "bankReferenceId", "fed_reference_number": "fedReferenceNumber", "retirement_contribution": "retirementContribution", "returned_wire_withdrawal": "returnedWireWithdrawal", "wire_instructions": "wireInstructions", }); }); /** @internal */ export type WireDeposit$Outbound = { amount?: WireDepositAmount$Outbound | null | undefined; bank_reference_id?: string | undefined; fed_reference_number?: string | undefined; name?: string | undefined; retirement_contribution?: | WireDepositRetirementContribution$Outbound | null | undefined; returned_wire_withdrawal?: boolean | undefined; state?: WireDepositState$Outbound | null | undefined; wire_instructions?: Array | undefined; }; /** @internal */ export const WireDeposit$outboundSchema: z.ZodType< WireDeposit$Outbound, z.ZodTypeDef, WireDeposit > = z.object({ amount: z.nullable(z.lazy(() => WireDepositAmount$outboundSchema)).optional(), bankReferenceId: z.string().optional(), fedReferenceNumber: z.string().optional(), name: z.string().optional(), retirementContribution: z.nullable( z.lazy(() => WireDepositRetirementContribution$outboundSchema), ).optional(), returnedWireWithdrawal: z.boolean().optional(), state: z.nullable(z.lazy(() => WireDepositState$outboundSchema)).optional(), wireInstructions: z.array(z.string()).optional(), }).transform((v) => { return remap$(v, { bankReferenceId: "bank_reference_id", fedReferenceNumber: "fed_reference_number", retirementContribution: "retirement_contribution", returnedWireWithdrawal: "returned_wire_withdrawal", wireInstructions: "wire_instructions", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace WireDeposit$ { /** @deprecated use `WireDeposit$inboundSchema` instead. */ export const inboundSchema = WireDeposit$inboundSchema; /** @deprecated use `WireDeposit$outboundSchema` instead. */ export const outboundSchema = WireDeposit$outboundSchema; /** @deprecated use `WireDeposit$Outbound` instead. */ export type Outbound = WireDeposit$Outbound; } export function wireDepositToJSON(wireDeposit: WireDeposit): string { return JSON.stringify(WireDeposit$outboundSchema.parse(wireDeposit)); } export function wireDepositFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WireDeposit$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WireDeposit' from JSON`, ); }