/* * 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 { DepositScheduleDetailsCreate, DepositScheduleDetailsCreate$inboundSchema, DepositScheduleDetailsCreate$Outbound, DepositScheduleDetailsCreate$outboundSchema, } from "./depositscheduledetailscreate.js"; import { ScheduledRetirementContributionCreate, ScheduledRetirementContributionCreate$inboundSchema, ScheduledRetirementContributionCreate$Outbound, ScheduledRetirementContributionCreate$outboundSchema, } from "./scheduledretirementcontributioncreate.js"; /** * The type of retirement contribution. */ export enum AchDepositScheduleCreateType { 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 AchDepositScheduleCreateTypeOpen = OpenEnum< typeof AchDepositScheduleCreateType >; /** * Deprecated: see retirement_contribution_details The ira contribution info for an IRA account. * * @deprecated class: This will be removed in a future release, please migrate away from it as soon as possible. */ export type IraContribution = { /** * 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: AchDepositScheduleCreateTypeOpen; }; /** * A deposit transfer schedule using the ACH mechanism */ export type AchDepositScheduleCreate = { /** * The name of the bank relationship to be used in the ACH transaction */ bankRelationship: string; /** * Deprecated: see retirement_contribution_details The ira contribution info for an IRA account. * * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ iraContribution?: IraContribution | undefined; /** * The retirement contribution details for a scheduled deposit */ retirementContribution?: ScheduledRetirementContributionCreate | undefined; /** * Details of deposit schedule transfers */ scheduleDetails: DepositScheduleDetailsCreate; }; /** @internal */ export const AchDepositScheduleCreateType$inboundSchema: z.ZodType< AchDepositScheduleCreateTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(AchDepositScheduleCreateType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const AchDepositScheduleCreateType$outboundSchema: z.ZodType< AchDepositScheduleCreateTypeOpen, z.ZodTypeDef, AchDepositScheduleCreateTypeOpen > = z.union([ z.nativeEnum(AchDepositScheduleCreateType), 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 AchDepositScheduleCreateType$ { /** @deprecated use `AchDepositScheduleCreateType$inboundSchema` instead. */ export const inboundSchema = AchDepositScheduleCreateType$inboundSchema; /** @deprecated use `AchDepositScheduleCreateType$outboundSchema` instead. */ export const outboundSchema = AchDepositScheduleCreateType$outboundSchema; } /** @internal */ export const IraContribution$inboundSchema: z.ZodType< IraContribution, z.ZodTypeDef, unknown > = z.object({ tax_year: z.number().int(), type: AchDepositScheduleCreateType$inboundSchema, }).transform((v) => { return remap$(v, { "tax_year": "taxYear", }); }); /** @internal */ export type IraContribution$Outbound = { tax_year: number; type: string; }; /** @internal */ export const IraContribution$outboundSchema: z.ZodType< IraContribution$Outbound, z.ZodTypeDef, IraContribution > = z.object({ taxYear: z.number().int(), type: AchDepositScheduleCreateType$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 IraContribution$ { /** @deprecated use `IraContribution$inboundSchema` instead. */ export const inboundSchema = IraContribution$inboundSchema; /** @deprecated use `IraContribution$outboundSchema` instead. */ export const outboundSchema = IraContribution$outboundSchema; /** @deprecated use `IraContribution$Outbound` instead. */ export type Outbound = IraContribution$Outbound; } export function iraContributionToJSON( iraContribution: IraContribution, ): string { return JSON.stringify(IraContribution$outboundSchema.parse(iraContribution)); } export function iraContributionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => IraContribution$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'IraContribution' from JSON`, ); } /** @internal */ export const AchDepositScheduleCreate$inboundSchema: z.ZodType< AchDepositScheduleCreate, z.ZodTypeDef, unknown > = z.object({ bank_relationship: z.string(), ira_contribution: z.lazy(() => IraContribution$inboundSchema).optional(), retirement_contribution: ScheduledRetirementContributionCreate$inboundSchema .optional(), schedule_details: DepositScheduleDetailsCreate$inboundSchema, }).transform((v) => { return remap$(v, { "bank_relationship": "bankRelationship", "ira_contribution": "iraContribution", "retirement_contribution": "retirementContribution", "schedule_details": "scheduleDetails", }); }); /** @internal */ export type AchDepositScheduleCreate$Outbound = { bank_relationship: string; ira_contribution?: IraContribution$Outbound | undefined; retirement_contribution?: | ScheduledRetirementContributionCreate$Outbound | undefined; schedule_details: DepositScheduleDetailsCreate$Outbound; }; /** @internal */ export const AchDepositScheduleCreate$outboundSchema: z.ZodType< AchDepositScheduleCreate$Outbound, z.ZodTypeDef, AchDepositScheduleCreate > = z.object({ bankRelationship: z.string(), iraContribution: z.lazy(() => IraContribution$outboundSchema).optional(), retirementContribution: ScheduledRetirementContributionCreate$outboundSchema .optional(), scheduleDetails: DepositScheduleDetailsCreate$outboundSchema, }).transform((v) => { return remap$(v, { bankRelationship: "bank_relationship", iraContribution: "ira_contribution", retirementContribution: "retirement_contribution", scheduleDetails: "schedule_details", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace AchDepositScheduleCreate$ { /** @deprecated use `AchDepositScheduleCreate$inboundSchema` instead. */ export const inboundSchema = AchDepositScheduleCreate$inboundSchema; /** @deprecated use `AchDepositScheduleCreate$outboundSchema` instead. */ export const outboundSchema = AchDepositScheduleCreate$outboundSchema; /** @deprecated use `AchDepositScheduleCreate$Outbound` instead. */ export type Outbound = AchDepositScheduleCreate$Outbound; } export function achDepositScheduleCreateToJSON( achDepositScheduleCreate: AchDepositScheduleCreate, ): string { return JSON.stringify( AchDepositScheduleCreate$outboundSchema.parse(achDepositScheduleCreate), ); } export function achDepositScheduleCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AchDepositScheduleCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AchDepositScheduleCreate' from JSON`, ); }