/* * 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 to deposit in USD. */ export type Amount = { /** * 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 AchDepositType { 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 AchDepositTypeOpen = OpenEnum; /** * The retirement contribution details. */ export type RetirementContribution = { /** * 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?: AchDepositTypeOpen | 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 AchDepositStateState { 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 AchDepositStateStateOpen = OpenEnum; /** * The current state of the ACH deposit. */ export type AchDepositState = { /** * 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?: AchDepositStateStateOpen | undefined; /** * The time of the state update. */ updateTime?: Date | null | undefined; }; /** * A deposit transfer using the ACH mechanism. */ export type AchDeposit = { /** * The amount to deposit in USD. */ amount?: Amount | null | undefined; /** * The bank relationship to be used for the ACH deposit. */ bankRelationship?: string | undefined; /** * The external identifier supplied by the API caller. Each request must have a unique pairing of `client_transfer_id` and `account`. */ clientTransferId?: string | undefined; /** * The memo that will appear on the customer's bank statement. */ memo?: string | undefined; /** * The resource name of the ACH deposit. */ name?: string | undefined; /** * The retirement contribution details. */ retirementContribution?: RetirementContribution | null | undefined; /** * The current state of the ACH deposit. */ state?: AchDepositState | null | undefined; }; /** @internal */ export const Amount$inboundSchema: z.ZodType = z .object({ value: z.string().optional(), }); /** @internal */ export type Amount$Outbound = { value?: string | undefined; }; /** @internal */ export const Amount$outboundSchema: z.ZodType< Amount$Outbound, z.ZodTypeDef, Amount > = 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 Amount$ { /** @deprecated use `Amount$inboundSchema` instead. */ export const inboundSchema = Amount$inboundSchema; /** @deprecated use `Amount$outboundSchema` instead. */ export const outboundSchema = Amount$outboundSchema; /** @deprecated use `Amount$Outbound` instead. */ export type Outbound = Amount$Outbound; } export function amountToJSON(amount: Amount): string { return JSON.stringify(Amount$outboundSchema.parse(amount)); } export function amountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Amount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Amount' from JSON`, ); } /** @internal */ export const AchDepositType$inboundSchema: z.ZodType< AchDepositTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(AchDepositType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const AchDepositType$outboundSchema: z.ZodType< AchDepositTypeOpen, z.ZodTypeDef, AchDepositTypeOpen > = z.union([ z.nativeEnum(AchDepositType), 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 AchDepositType$ { /** @deprecated use `AchDepositType$inboundSchema` instead. */ export const inboundSchema = AchDepositType$inboundSchema; /** @deprecated use `AchDepositType$outboundSchema` instead. */ export const outboundSchema = AchDepositType$outboundSchema; } /** @internal */ export const RetirementContribution$inboundSchema: z.ZodType< RetirementContribution, z.ZodTypeDef, unknown > = z.object({ tax_year: z.number().int().optional(), type: AchDepositType$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "tax_year": "taxYear", }); }); /** @internal */ export type RetirementContribution$Outbound = { tax_year?: number | undefined; type?: string | undefined; }; /** @internal */ export const RetirementContribution$outboundSchema: z.ZodType< RetirementContribution$Outbound, z.ZodTypeDef, RetirementContribution > = z.object({ taxYear: z.number().int().optional(), type: AchDepositType$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 RetirementContribution$ { /** @deprecated use `RetirementContribution$inboundSchema` instead. */ export const inboundSchema = RetirementContribution$inboundSchema; /** @deprecated use `RetirementContribution$outboundSchema` instead. */ export const outboundSchema = RetirementContribution$outboundSchema; /** @deprecated use `RetirementContribution$Outbound` instead. */ export type Outbound = RetirementContribution$Outbound; } export function retirementContributionToJSON( retirementContribution: RetirementContribution, ): string { return JSON.stringify( RetirementContribution$outboundSchema.parse(retirementContribution), ); } export function retirementContributionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => RetirementContribution$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RetirementContribution' from JSON`, ); } /** @internal */ export const AchDepositStateState$inboundSchema: z.ZodType< AchDepositStateStateOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(AchDepositStateState), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const AchDepositStateState$outboundSchema: z.ZodType< AchDepositStateStateOpen, z.ZodTypeDef, AchDepositStateStateOpen > = z.union([ z.nativeEnum(AchDepositStateState), 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 AchDepositStateState$ { /** @deprecated use `AchDepositStateState$inboundSchema` instead. */ export const inboundSchema = AchDepositStateState$inboundSchema; /** @deprecated use `AchDepositStateState$outboundSchema` instead. */ export const outboundSchema = AchDepositStateState$outboundSchema; } /** @internal */ export const AchDepositState$inboundSchema: z.ZodType< AchDepositState, z.ZodTypeDef, unknown > = z.object({ actor: z.string().optional(), message: z.string().optional(), metadata: z.nullable(z.record(z.any())).optional(), state: AchDepositStateState$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 AchDepositState$Outbound = { actor?: string | undefined; message?: string | undefined; metadata?: { [k: string]: any } | null | undefined; state?: string | undefined; update_time?: string | null | undefined; }; /** @internal */ export const AchDepositState$outboundSchema: z.ZodType< AchDepositState$Outbound, z.ZodTypeDef, AchDepositState > = z.object({ actor: z.string().optional(), message: z.string().optional(), metadata: z.nullable(z.record(z.any())).optional(), state: AchDepositStateState$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 AchDepositState$ { /** @deprecated use `AchDepositState$inboundSchema` instead. */ export const inboundSchema = AchDepositState$inboundSchema; /** @deprecated use `AchDepositState$outboundSchema` instead. */ export const outboundSchema = AchDepositState$outboundSchema; /** @deprecated use `AchDepositState$Outbound` instead. */ export type Outbound = AchDepositState$Outbound; } export function achDepositStateToJSON( achDepositState: AchDepositState, ): string { return JSON.stringify(AchDepositState$outboundSchema.parse(achDepositState)); } export function achDepositStateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AchDepositState$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AchDepositState' from JSON`, ); } /** @internal */ export const AchDeposit$inboundSchema: z.ZodType< AchDeposit, z.ZodTypeDef, unknown > = z.object({ amount: z.nullable(z.lazy(() => Amount$inboundSchema)).optional(), bank_relationship: z.string().optional(), client_transfer_id: z.string().optional(), memo: z.string().optional(), name: z.string().optional(), retirement_contribution: z.nullable( z.lazy(() => RetirementContribution$inboundSchema), ).optional(), state: z.nullable(z.lazy(() => AchDepositState$inboundSchema)).optional(), }).transform((v) => { return remap$(v, { "bank_relationship": "bankRelationship", "client_transfer_id": "clientTransferId", "retirement_contribution": "retirementContribution", }); }); /** @internal */ export type AchDeposit$Outbound = { amount?: Amount$Outbound | null | undefined; bank_relationship?: string | undefined; client_transfer_id?: string | undefined; memo?: string | undefined; name?: string | undefined; retirement_contribution?: RetirementContribution$Outbound | null | undefined; state?: AchDepositState$Outbound | null | undefined; }; /** @internal */ export const AchDeposit$outboundSchema: z.ZodType< AchDeposit$Outbound, z.ZodTypeDef, AchDeposit > = z.object({ amount: z.nullable(z.lazy(() => Amount$outboundSchema)).optional(), bankRelationship: z.string().optional(), clientTransferId: z.string().optional(), memo: z.string().optional(), name: z.string().optional(), retirementContribution: z.nullable( z.lazy(() => RetirementContribution$outboundSchema), ).optional(), state: z.nullable(z.lazy(() => AchDepositState$outboundSchema)).optional(), }).transform((v) => { return remap$(v, { bankRelationship: "bank_relationship", clientTransferId: "client_transfer_id", retirementContribution: "retirement_contribution", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace AchDeposit$ { /** @deprecated use `AchDeposit$inboundSchema` instead. */ export const inboundSchema = AchDeposit$inboundSchema; /** @deprecated use `AchDeposit$outboundSchema` instead. */ export const outboundSchema = AchDeposit$outboundSchema; /** @deprecated use `AchDeposit$Outbound` instead. */ export type Outbound = AchDeposit$Outbound; } export function achDepositToJSON(achDeposit: AchDeposit): string { return JSON.stringify(AchDeposit$outboundSchema.parse(achDeposit)); } export function achDepositFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AchDeposit$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AchDeposit' from JSON`, ); }