/* * 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 rate at which monies were withheld, expressed as a value between 0-1 */ export type Rate = { /** * 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 WithholdingDataState { 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 WithholdingDataStateOpen = OpenEnum; /** * Provides more detail on the type of the withholding (Federal, State, etc.) */ export enum WithholdingDataType { WithholdingTypeUnspecified = "WITHHOLDING_TYPE_UNSPECIFIED", Federal = "FEDERAL", State = "STATE", ForeignSecurity = "FOREIGN_SECURITY", FederalIra = "FEDERAL_IRA", StateIra = "STATE_IRA", NonResidentAlien = "NON_RESIDENT_ALIEN", } /** * Provides more detail on the type of the withholding (Federal, State, etc.) */ export type WithholdingDataTypeOpen = OpenEnum; export type WithholdingData = { /** * The rate at which monies were withheld, expressed as a value between 0-1 */ rate?: Rate | null | undefined; /** * 2-Letter alpha code for the names of countries, dependent territories, and special areas of geographical interest. Complies with ISO-3166 Alpha-2 Codes */ regionCode?: string | undefined; state?: WithholdingDataStateOpen | undefined; /** * The tax year associated with the withholding */ taxYear?: number | undefined; /** * Provides more detail on the type of the withholding (Federal, State, etc.) */ type?: WithholdingDataTypeOpen | undefined; }; /** @internal */ export const Rate$inboundSchema: z.ZodType = z .object({ value: z.string().optional(), }); /** @internal */ export type Rate$Outbound = { value?: string | undefined; }; /** @internal */ export const Rate$outboundSchema: z.ZodType = 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 Rate$ { /** @deprecated use `Rate$inboundSchema` instead. */ export const inboundSchema = Rate$inboundSchema; /** @deprecated use `Rate$outboundSchema` instead. */ export const outboundSchema = Rate$outboundSchema; /** @deprecated use `Rate$Outbound` instead. */ export type Outbound = Rate$Outbound; } export function rateToJSON(rate: Rate): string { return JSON.stringify(Rate$outboundSchema.parse(rate)); } export function rateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Rate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Rate' from JSON`, ); } /** @internal */ export const WithholdingDataState$inboundSchema: z.ZodType< WithholdingDataStateOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(WithholdingDataState), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const WithholdingDataState$outboundSchema: z.ZodType< WithholdingDataStateOpen, z.ZodTypeDef, WithholdingDataStateOpen > = z.union([ z.nativeEnum(WithholdingDataState), 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 WithholdingDataState$ { /** @deprecated use `WithholdingDataState$inboundSchema` instead. */ export const inboundSchema = WithholdingDataState$inboundSchema; /** @deprecated use `WithholdingDataState$outboundSchema` instead. */ export const outboundSchema = WithholdingDataState$outboundSchema; } /** @internal */ export const WithholdingDataType$inboundSchema: z.ZodType< WithholdingDataTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(WithholdingDataType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const WithholdingDataType$outboundSchema: z.ZodType< WithholdingDataTypeOpen, z.ZodTypeDef, WithholdingDataTypeOpen > = z.union([ z.nativeEnum(WithholdingDataType), 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 WithholdingDataType$ { /** @deprecated use `WithholdingDataType$inboundSchema` instead. */ export const inboundSchema = WithholdingDataType$inboundSchema; /** @deprecated use `WithholdingDataType$outboundSchema` instead. */ export const outboundSchema = WithholdingDataType$outboundSchema; } /** @internal */ export const WithholdingData$inboundSchema: z.ZodType< WithholdingData, z.ZodTypeDef, unknown > = z.object({ rate: z.nullable(z.lazy(() => Rate$inboundSchema)).optional(), region_code: z.string().optional(), state: WithholdingDataState$inboundSchema.optional(), tax_year: z.number().int().optional(), type: WithholdingDataType$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "region_code": "regionCode", "tax_year": "taxYear", }); }); /** @internal */ export type WithholdingData$Outbound = { rate?: Rate$Outbound | null | undefined; region_code?: string | undefined; state?: string | undefined; tax_year?: number | undefined; type?: string | undefined; }; /** @internal */ export const WithholdingData$outboundSchema: z.ZodType< WithholdingData$Outbound, z.ZodTypeDef, WithholdingData > = z.object({ rate: z.nullable(z.lazy(() => Rate$outboundSchema)).optional(), regionCode: z.string().optional(), state: WithholdingDataState$outboundSchema.optional(), taxYear: z.number().int().optional(), type: WithholdingDataType$outboundSchema.optional(), }).transform((v) => { return remap$(v, { regionCode: "region_code", 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 WithholdingData$ { /** @deprecated use `WithholdingData$inboundSchema` instead. */ export const inboundSchema = WithholdingData$inboundSchema; /** @deprecated use `WithholdingData$outboundSchema` instead. */ export const outboundSchema = WithholdingData$outboundSchema; /** @deprecated use `WithholdingData$Outbound` instead. */ export type Outbound = WithholdingData$Outbound; } export function withholdingDataToJSON( withholdingData: WithholdingData, ): string { return JSON.stringify(WithholdingData$outboundSchema.parse(withholdingData)); } export function withholdingDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WithholdingData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WithholdingData' from JSON`, ); }