/* * 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 { RetirementDistributionTaxWithholdingCreate, RetirementDistributionTaxWithholdingCreate$inboundSchema, RetirementDistributionTaxWithholdingCreate$Outbound, RetirementDistributionTaxWithholdingCreate$outboundSchema, } from "./retirementdistributiontaxwithholdingcreate.js"; /** * The type of retirement distribution. */ export enum RetirementDistributionCreateType { TypeUnspecified = "TYPE_UNSPECIFIED", Normal = "NORMAL", Disability = "DISABILITY", Sosepp = "SOSEPP", Premature = "PREMATURE", Death = "DEATH", ExcessContributionRemovalBeforeTaxDeadline = "EXCESS_CONTRIBUTION_REMOVAL_BEFORE_TAX_DEADLINE", ExcessContributionRemovalAfterTaxDeadline = "EXCESS_CONTRIBUTION_REMOVAL_AFTER_TAX_DEADLINE", RolloverToQualifiedPlan = "ROLLOVER_TO_QUALIFIED_PLAN", RolloverToIra = "ROLLOVER_TO_IRA", DistributionTransfer = "DISTRIBUTION_TRANSFER", RecharacterizationPriorYear = "RECHARACTERIZATION_PRIOR_YEAR", RecharacterizationCurrentYear = "RECHARACTERIZATION_CURRENT_YEAR", DistributionConversion = "DISTRIBUTION_CONVERSION", ManagementFee = "MANAGEMENT_FEE", PlanLoan401K = "PLAN_LOAN_401K", PrematureSimpleIraLessThan2Years = "PREMATURE_SIMPLE_IRA_LESS_THAN_2_YEARS", NormalRothIraGreaterThan5Years = "NORMAL_ROTH_IRA_GREATER_THAN_5_YEARS", NetIncomeAttributable = "NET_INCOME_ATTRIBUTABLE", Revocation = "REVOCATION", NonReportable = "NON_REPORTABLE", QualifiedCharitableDistribution = "QUALIFIED_CHARITABLE_DISTRIBUTION", } /** * The type of retirement distribution. */ export type RetirementDistributionCreateTypeOpen = OpenEnum< typeof RetirementDistributionCreateType >; /** * A distribution from a retirement account. */ export type RetirementDistributionCreate = { /** * A representation of a tax withholding. */ federalTaxWithholding?: | RetirementDistributionTaxWithholdingCreate | undefined; /** * The institution receiving retirement funds when performing a transfer to an identical retirement account type at a different financial institution. This is required for check and wire withdrawals because we can't always identify the institution using the transfer instructions. For cash journals this value will default to "Apex Clearing", regardless of what is passed in here */ receivingInstitution?: string | undefined; /** * A representation of a tax withholding. */ stateTaxWithholding?: RetirementDistributionTaxWithholdingCreate | undefined; /** * Whether or not this distribution has a state withholding waiver. */ stateWithholdingWaiver?: boolean | undefined; /** * The type of retirement distribution. */ type: RetirementDistributionCreateTypeOpen; }; /** @internal */ export const RetirementDistributionCreateType$inboundSchema: z.ZodType< RetirementDistributionCreateTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(RetirementDistributionCreateType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const RetirementDistributionCreateType$outboundSchema: z.ZodType< RetirementDistributionCreateTypeOpen, z.ZodTypeDef, RetirementDistributionCreateTypeOpen > = z.union([ z.nativeEnum(RetirementDistributionCreateType), 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 RetirementDistributionCreateType$ { /** @deprecated use `RetirementDistributionCreateType$inboundSchema` instead. */ export const inboundSchema = RetirementDistributionCreateType$inboundSchema; /** @deprecated use `RetirementDistributionCreateType$outboundSchema` instead. */ export const outboundSchema = RetirementDistributionCreateType$outboundSchema; } /** @internal */ export const RetirementDistributionCreate$inboundSchema: z.ZodType< RetirementDistributionCreate, z.ZodTypeDef, unknown > = z.object({ federal_tax_withholding: RetirementDistributionTaxWithholdingCreate$inboundSchema.optional(), receiving_institution: z.string().optional(), state_tax_withholding: RetirementDistributionTaxWithholdingCreate$inboundSchema.optional(), state_withholding_waiver: z.boolean().optional(), type: RetirementDistributionCreateType$inboundSchema, }).transform((v) => { return remap$(v, { "federal_tax_withholding": "federalTaxWithholding", "receiving_institution": "receivingInstitution", "state_tax_withholding": "stateTaxWithholding", "state_withholding_waiver": "stateWithholdingWaiver", }); }); /** @internal */ export type RetirementDistributionCreate$Outbound = { federal_tax_withholding?: | RetirementDistributionTaxWithholdingCreate$Outbound | undefined; receiving_institution?: string | undefined; state_tax_withholding?: | RetirementDistributionTaxWithholdingCreate$Outbound | undefined; state_withholding_waiver?: boolean | undefined; type: string; }; /** @internal */ export const RetirementDistributionCreate$outboundSchema: z.ZodType< RetirementDistributionCreate$Outbound, z.ZodTypeDef, RetirementDistributionCreate > = z.object({ federalTaxWithholding: RetirementDistributionTaxWithholdingCreate$outboundSchema.optional(), receivingInstitution: z.string().optional(), stateTaxWithholding: RetirementDistributionTaxWithholdingCreate$outboundSchema .optional(), stateWithholdingWaiver: z.boolean().optional(), type: RetirementDistributionCreateType$outboundSchema, }).transform((v) => { return remap$(v, { federalTaxWithholding: "federal_tax_withholding", receivingInstitution: "receiving_institution", stateTaxWithholding: "state_tax_withholding", stateWithholdingWaiver: "state_withholding_waiver", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace RetirementDistributionCreate$ { /** @deprecated use `RetirementDistributionCreate$inboundSchema` instead. */ export const inboundSchema = RetirementDistributionCreate$inboundSchema; /** @deprecated use `RetirementDistributionCreate$outboundSchema` instead. */ export const outboundSchema = RetirementDistributionCreate$outboundSchema; /** @deprecated use `RetirementDistributionCreate$Outbound` instead. */ export type Outbound = RetirementDistributionCreate$Outbound; } export function retirementDistributionCreateToJSON( retirementDistributionCreate: RetirementDistributionCreate, ): string { return JSON.stringify( RetirementDistributionCreate$outboundSchema.parse( retirementDistributionCreate, ), ); } export function retirementDistributionCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => RetirementDistributionCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RetirementDistributionCreate' from JSON`, ); }