/* * 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 type of retirement contribution. */ export enum RetirementContributionCreateType { 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 RetirementContributionCreateTypeOpen = OpenEnum< typeof RetirementContributionCreateType >; /** * A contribution to a retirement account. */ export type RetirementContributionCreate = { /** * 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; /** * The type of retirement contribution. */ type: RetirementContributionCreateTypeOpen; }; /** @internal */ export const RetirementContributionCreateType$inboundSchema: z.ZodType< RetirementContributionCreateTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(RetirementContributionCreateType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const RetirementContributionCreateType$outboundSchema: z.ZodType< RetirementContributionCreateTypeOpen, z.ZodTypeDef, RetirementContributionCreateTypeOpen > = z.union([ z.nativeEnum(RetirementContributionCreateType), 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 RetirementContributionCreateType$ { /** @deprecated use `RetirementContributionCreateType$inboundSchema` instead. */ export const inboundSchema = RetirementContributionCreateType$inboundSchema; /** @deprecated use `RetirementContributionCreateType$outboundSchema` instead. */ export const outboundSchema = RetirementContributionCreateType$outboundSchema; } /** @internal */ export const RetirementContributionCreate$inboundSchema: z.ZodType< RetirementContributionCreate, z.ZodTypeDef, unknown > = z.object({ tax_year: z.number().int(), type: RetirementContributionCreateType$inboundSchema, }).transform((v) => { return remap$(v, { "tax_year": "taxYear", }); }); /** @internal */ export type RetirementContributionCreate$Outbound = { tax_year: number; type: string; }; /** @internal */ export const RetirementContributionCreate$outboundSchema: z.ZodType< RetirementContributionCreate$Outbound, z.ZodTypeDef, RetirementContributionCreate > = z.object({ taxYear: z.number().int(), type: RetirementContributionCreateType$outboundSchema, }).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 RetirementContributionCreate$ { /** @deprecated use `RetirementContributionCreate$inboundSchema` instead. */ export const inboundSchema = RetirementContributionCreate$inboundSchema; /** @deprecated use `RetirementContributionCreate$outboundSchema` instead. */ export const outboundSchema = RetirementContributionCreate$outboundSchema; /** @deprecated use `RetirementContributionCreate$Outbound` instead. */ export type Outbound = RetirementContributionCreate$Outbound; } export function retirementContributionCreateToJSON( retirementContributionCreate: RetirementContributionCreate, ): string { return JSON.stringify( RetirementContributionCreate$outboundSchema.parse( retirementContributionCreate, ), ); } export function retirementContributionCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => RetirementContributionCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RetirementContributionCreate' from JSON`, ); }