/* * 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 in USD. */ export type CheckDepositAmount = { /** * 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 CheckDepositType { 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 CheckDepositTypeOpen = OpenEnum; /** * The retirement contribution details. */ export type CheckDepositRetirementContribution = { /** * 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?: CheckDepositTypeOpen | 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 CheckDepositStateState { 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 CheckDepositStateStateOpen = OpenEnum< typeof CheckDepositStateState >; /** * The current state of the check deposit. */ export type CheckDepositState = { /** * 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?: CheckDepositStateStateOpen | undefined; /** * The time of the state update. */ updateTime?: Date | null | undefined; }; /** * A deposit transfer using the check mechanism. */ export type CheckDeposit = { /** * The amount in USD. */ amount?: CheckDepositAmount | null | undefined; /** * The resource name of the check deposit. Format: accounts/{account}/checkDeposits/{check_deposit} */ name?: string | undefined; /** * The retirement contribution details. */ retirementContribution?: | CheckDepositRetirementContribution | null | undefined; /** * The current state of the check deposit. */ state?: CheckDepositState | null | undefined; }; /** @internal */ export const CheckDepositAmount$inboundSchema: z.ZodType< CheckDepositAmount, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type CheckDepositAmount$Outbound = { value?: string | undefined; }; /** @internal */ export const CheckDepositAmount$outboundSchema: z.ZodType< CheckDepositAmount$Outbound, z.ZodTypeDef, CheckDepositAmount > = 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 CheckDepositAmount$ { /** @deprecated use `CheckDepositAmount$inboundSchema` instead. */ export const inboundSchema = CheckDepositAmount$inboundSchema; /** @deprecated use `CheckDepositAmount$outboundSchema` instead. */ export const outboundSchema = CheckDepositAmount$outboundSchema; /** @deprecated use `CheckDepositAmount$Outbound` instead. */ export type Outbound = CheckDepositAmount$Outbound; } export function checkDepositAmountToJSON( checkDepositAmount: CheckDepositAmount, ): string { return JSON.stringify( CheckDepositAmount$outboundSchema.parse(checkDepositAmount), ); } export function checkDepositAmountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CheckDepositAmount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CheckDepositAmount' from JSON`, ); } /** @internal */ export const CheckDepositType$inboundSchema: z.ZodType< CheckDepositTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(CheckDepositType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const CheckDepositType$outboundSchema: z.ZodType< CheckDepositTypeOpen, z.ZodTypeDef, CheckDepositTypeOpen > = z.union([ z.nativeEnum(CheckDepositType), 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 CheckDepositType$ { /** @deprecated use `CheckDepositType$inboundSchema` instead. */ export const inboundSchema = CheckDepositType$inboundSchema; /** @deprecated use `CheckDepositType$outboundSchema` instead. */ export const outboundSchema = CheckDepositType$outboundSchema; } /** @internal */ export const CheckDepositRetirementContribution$inboundSchema: z.ZodType< CheckDepositRetirementContribution, z.ZodTypeDef, unknown > = z.object({ tax_year: z.number().int().optional(), type: CheckDepositType$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "tax_year": "taxYear", }); }); /** @internal */ export type CheckDepositRetirementContribution$Outbound = { tax_year?: number | undefined; type?: string | undefined; }; /** @internal */ export const CheckDepositRetirementContribution$outboundSchema: z.ZodType< CheckDepositRetirementContribution$Outbound, z.ZodTypeDef, CheckDepositRetirementContribution > = z.object({ taxYear: z.number().int().optional(), type: CheckDepositType$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 CheckDepositRetirementContribution$ { /** @deprecated use `CheckDepositRetirementContribution$inboundSchema` instead. */ export const inboundSchema = CheckDepositRetirementContribution$inboundSchema; /** @deprecated use `CheckDepositRetirementContribution$outboundSchema` instead. */ export const outboundSchema = CheckDepositRetirementContribution$outboundSchema; /** @deprecated use `CheckDepositRetirementContribution$Outbound` instead. */ export type Outbound = CheckDepositRetirementContribution$Outbound; } export function checkDepositRetirementContributionToJSON( checkDepositRetirementContribution: CheckDepositRetirementContribution, ): string { return JSON.stringify( CheckDepositRetirementContribution$outboundSchema.parse( checkDepositRetirementContribution, ), ); } export function checkDepositRetirementContributionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CheckDepositRetirementContribution$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CheckDepositRetirementContribution' from JSON`, ); } /** @internal */ export const CheckDepositStateState$inboundSchema: z.ZodType< CheckDepositStateStateOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(CheckDepositStateState), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const CheckDepositStateState$outboundSchema: z.ZodType< CheckDepositStateStateOpen, z.ZodTypeDef, CheckDepositStateStateOpen > = z.union([ z.nativeEnum(CheckDepositStateState), 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 CheckDepositStateState$ { /** @deprecated use `CheckDepositStateState$inboundSchema` instead. */ export const inboundSchema = CheckDepositStateState$inboundSchema; /** @deprecated use `CheckDepositStateState$outboundSchema` instead. */ export const outboundSchema = CheckDepositStateState$outboundSchema; } /** @internal */ export const CheckDepositState$inboundSchema: z.ZodType< CheckDepositState, z.ZodTypeDef, unknown > = z.object({ actor: z.string().optional(), message: z.string().optional(), metadata: z.nullable(z.record(z.any())).optional(), state: CheckDepositStateState$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 CheckDepositState$Outbound = { actor?: string | undefined; message?: string | undefined; metadata?: { [k: string]: any } | null | undefined; state?: string | undefined; update_time?: string | null | undefined; }; /** @internal */ export const CheckDepositState$outboundSchema: z.ZodType< CheckDepositState$Outbound, z.ZodTypeDef, CheckDepositState > = z.object({ actor: z.string().optional(), message: z.string().optional(), metadata: z.nullable(z.record(z.any())).optional(), state: CheckDepositStateState$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 CheckDepositState$ { /** @deprecated use `CheckDepositState$inboundSchema` instead. */ export const inboundSchema = CheckDepositState$inboundSchema; /** @deprecated use `CheckDepositState$outboundSchema` instead. */ export const outboundSchema = CheckDepositState$outboundSchema; /** @deprecated use `CheckDepositState$Outbound` instead. */ export type Outbound = CheckDepositState$Outbound; } export function checkDepositStateToJSON( checkDepositState: CheckDepositState, ): string { return JSON.stringify( CheckDepositState$outboundSchema.parse(checkDepositState), ); } export function checkDepositStateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CheckDepositState$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CheckDepositState' from JSON`, ); } /** @internal */ export const CheckDeposit$inboundSchema: z.ZodType< CheckDeposit, z.ZodTypeDef, unknown > = z.object({ amount: z.nullable(z.lazy(() => CheckDepositAmount$inboundSchema)).optional(), name: z.string().optional(), retirement_contribution: z.nullable( z.lazy(() => CheckDepositRetirementContribution$inboundSchema), ).optional(), state: z.nullable(z.lazy(() => CheckDepositState$inboundSchema)).optional(), }).transform((v) => { return remap$(v, { "retirement_contribution": "retirementContribution", }); }); /** @internal */ export type CheckDeposit$Outbound = { amount?: CheckDepositAmount$Outbound | null | undefined; name?: string | undefined; retirement_contribution?: | CheckDepositRetirementContribution$Outbound | null | undefined; state?: CheckDepositState$Outbound | null | undefined; }; /** @internal */ export const CheckDeposit$outboundSchema: z.ZodType< CheckDeposit$Outbound, z.ZodTypeDef, CheckDeposit > = z.object({ amount: z.nullable(z.lazy(() => CheckDepositAmount$outboundSchema)) .optional(), name: z.string().optional(), retirementContribution: z.nullable( z.lazy(() => CheckDepositRetirementContribution$outboundSchema), ).optional(), state: z.nullable(z.lazy(() => CheckDepositState$outboundSchema)).optional(), }).transform((v) => { return remap$(v, { 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 CheckDeposit$ { /** @deprecated use `CheckDeposit$inboundSchema` instead. */ export const inboundSchema = CheckDeposit$inboundSchema; /** @deprecated use `CheckDeposit$outboundSchema` instead. */ export const outboundSchema = CheckDeposit$outboundSchema; /** @deprecated use `CheckDeposit$Outbound` instead. */ export type Outbound = CheckDeposit$Outbound; } export function checkDepositToJSON(checkDeposit: CheckDeposit): string { return JSON.stringify(CheckDeposit$outboundSchema.parse(checkDeposit)); } export function checkDepositFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CheckDeposit$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CheckDeposit' from JSON`, ); }