/* * 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"; /** * Monetary amount associated with the withholding */ export type WithholdingAmount = { /** * 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 rate at which monies were withheld */ export type WithholdingRate = { /** * 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; }; export enum WithholdingState { WithholdingStateUnspecified = "WITHHOLDING_STATE_UNSPECIFIED", Ca = "CA", Me = "ME", Vt = "VT", Al = "AL", Ak = "AK", Az = "AZ", Ar = "AR", Co = "CO", Ct = "CT", De = "DE", Fl = "FL", Ga = "GA", Hi = "HI", Id = "ID", Il = "IL", In = "IN", Ia = "IA", Ks = "KS", Ky = "KY", La = "LA", Md = "MD", Ma = "MA", Mi = "MI", Mn = "MN", Ms = "MS", Mo = "MO", Mt = "MT", Ne = "NE", Nv = "NV", Nh = "NH", Nj = "NJ", Nm = "NM", Ny = "NY", Nc = "NC", Nd = "ND", Oh = "OH", Ok = "OK", Or = "OR", Pa = "PA", Ri = "RI", Sc = "SC", Sd = "SD", Tn = "TN", Tx = "TX", Ut = "UT", Va = "VA", Wa = "WA", Wv = "WV", Wi = "WI", Wy = "WY", Dc = "DC", } export type WithholdingStateOpen = OpenEnum; /** * Describes the type of the withholding (Federal, State, etc.) */ export enum WithholdingType1 { WithholdingTypeUnspecified = "WITHHOLDING_TYPE_UNSPECIFIED", Federal = "FEDERAL", State = "STATE", ForeignSecurity = "FOREIGN_SECURITY", FederalIra = "FEDERAL_IRA", StateIra = "STATE_IRA", NonResidentAlien = "NON_RESIDENT_ALIEN", } /** * Describes the type of the withholding (Federal, State, etc.) */ export type WithholdingType1Open = OpenEnum; export type Withholding = { /** * Monetary amount associated with the withholding */ amount?: WithholdingAmount | null | undefined; /** * The rate at which monies were withheld */ rate?: WithholdingRate | null | undefined; state?: WithholdingStateOpen | undefined; /** * The tax year associated with the withholding */ taxYear?: number | undefined; /** * Describes the type of the withholding (Federal, State, etc.) */ type?: WithholdingType1Open | undefined; }; /** @internal */ export const WithholdingAmount$inboundSchema: z.ZodType< WithholdingAmount, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type WithholdingAmount$Outbound = { value?: string | undefined; }; /** @internal */ export const WithholdingAmount$outboundSchema: z.ZodType< WithholdingAmount$Outbound, z.ZodTypeDef, WithholdingAmount > = 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 WithholdingAmount$ { /** @deprecated use `WithholdingAmount$inboundSchema` instead. */ export const inboundSchema = WithholdingAmount$inboundSchema; /** @deprecated use `WithholdingAmount$outboundSchema` instead. */ export const outboundSchema = WithholdingAmount$outboundSchema; /** @deprecated use `WithholdingAmount$Outbound` instead. */ export type Outbound = WithholdingAmount$Outbound; } export function withholdingAmountToJSON( withholdingAmount: WithholdingAmount, ): string { return JSON.stringify( WithholdingAmount$outboundSchema.parse(withholdingAmount), ); } export function withholdingAmountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WithholdingAmount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WithholdingAmount' from JSON`, ); } /** @internal */ export const WithholdingRate$inboundSchema: z.ZodType< WithholdingRate, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type WithholdingRate$Outbound = { value?: string | undefined; }; /** @internal */ export const WithholdingRate$outboundSchema: z.ZodType< WithholdingRate$Outbound, z.ZodTypeDef, WithholdingRate > = 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 WithholdingRate$ { /** @deprecated use `WithholdingRate$inboundSchema` instead. */ export const inboundSchema = WithholdingRate$inboundSchema; /** @deprecated use `WithholdingRate$outboundSchema` instead. */ export const outboundSchema = WithholdingRate$outboundSchema; /** @deprecated use `WithholdingRate$Outbound` instead. */ export type Outbound = WithholdingRate$Outbound; } export function withholdingRateToJSON( withholdingRate: WithholdingRate, ): string { return JSON.stringify(WithholdingRate$outboundSchema.parse(withholdingRate)); } export function withholdingRateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WithholdingRate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WithholdingRate' from JSON`, ); } /** @internal */ export const WithholdingState$inboundSchema: z.ZodType< WithholdingStateOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(WithholdingState), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const WithholdingState$outboundSchema: z.ZodType< WithholdingStateOpen, z.ZodTypeDef, WithholdingStateOpen > = z.union([ z.nativeEnum(WithholdingState), 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 WithholdingState$ { /** @deprecated use `WithholdingState$inboundSchema` instead. */ export const inboundSchema = WithholdingState$inboundSchema; /** @deprecated use `WithholdingState$outboundSchema` instead. */ export const outboundSchema = WithholdingState$outboundSchema; } /** @internal */ export const WithholdingType1$inboundSchema: z.ZodType< WithholdingType1Open, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(WithholdingType1), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const WithholdingType1$outboundSchema: z.ZodType< WithholdingType1Open, z.ZodTypeDef, WithholdingType1Open > = z.union([ z.nativeEnum(WithholdingType1), 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 WithholdingType1$ { /** @deprecated use `WithholdingType1$inboundSchema` instead. */ export const inboundSchema = WithholdingType1$inboundSchema; /** @deprecated use `WithholdingType1$outboundSchema` instead. */ export const outboundSchema = WithholdingType1$outboundSchema; } /** @internal */ export const Withholding$inboundSchema: z.ZodType< Withholding, z.ZodTypeDef, unknown > = z.object({ amount: z.nullable(z.lazy(() => WithholdingAmount$inboundSchema)).optional(), rate: z.nullable(z.lazy(() => WithholdingRate$inboundSchema)).optional(), state: WithholdingState$inboundSchema.optional(), tax_year: z.number().int().optional(), type: WithholdingType1$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "tax_year": "taxYear", }); }); /** @internal */ export type Withholding$Outbound = { amount?: WithholdingAmount$Outbound | null | undefined; rate?: WithholdingRate$Outbound | null | undefined; state?: string | undefined; tax_year?: number | undefined; type?: string | undefined; }; /** @internal */ export const Withholding$outboundSchema: z.ZodType< Withholding$Outbound, z.ZodTypeDef, Withholding > = z.object({ amount: z.nullable(z.lazy(() => WithholdingAmount$outboundSchema)).optional(), rate: z.nullable(z.lazy(() => WithholdingRate$outboundSchema)).optional(), state: WithholdingState$outboundSchema.optional(), taxYear: z.number().int().optional(), type: WithholdingType1$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 Withholding$ { /** @deprecated use `Withholding$inboundSchema` instead. */ export const inboundSchema = Withholding$inboundSchema; /** @deprecated use `Withholding$outboundSchema` instead. */ export const outboundSchema = Withholding$outboundSchema; /** @deprecated use `Withholding$Outbound` instead. */ export type Outbound = Withholding$Outbound; } export function withholdingToJSON(withholding: Withholding): string { return JSON.stringify(Withholding$outboundSchema.parse(withholding)); } export function withholdingFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Withholding$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Withholding' from JSON`, ); }