/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { ClosedEnum } from "../../types/enums.js"; import { GarnishmentChildSupport, GarnishmentChildSupport$Outbound, GarnishmentChildSupport$outboundSchema, } from "./garnishmentchildsupport.js"; export const UpdateGarnishmentRequestGarnishmentType = { ChildSupport: "child_support", FederalTaxLien: "federal_tax_lien", StateTaxLien: "state_tax_lien", StudentLoan: "student_loan", CreditorGarnishment: "creditor_garnishment", FederalLoan: "federal_loan", OtherGarnishment: "other_garnishment", } as const; export type UpdateGarnishmentRequestGarnishmentType = ClosedEnum< typeof UpdateGarnishmentRequestGarnishmentType >; /** * Request body for updating a garnishment. */ export type UpdateGarnishmentRequest = { /** * Whether or not this garnishment is currently active. */ active?: boolean | undefined; /** * The amount of the garnishment. Either a percentage or a fixed dollar amount. Represented as a float, e.g. "8.00". */ amount?: string | undefined; /** * The description of the garnishment. */ description?: string | undefined; /** * Whether the garnishment is court ordered. */ courtOrdered?: boolean | undefined; /** * The specific type of garnishment for court ordered garnishments. */ garnishmentType?: UpdateGarnishmentRequestGarnishmentType | null | undefined; /** * The number of times to apply the garnishment. Ignored if recurring is true. */ times?: number | null | undefined; /** * Whether the garnishment should recur indefinitely. */ recurring?: boolean | undefined; /** * The maximum deduction per annum. A null value indicates no maximum. Represented as a float, e.g. "200.00". */ annualMaximum?: string | null | undefined; /** * The maximum deduction per pay period. A null value indicates no maximum. Represented as a float, e.g. "16.00". */ payPeriodMaximum?: string | null | undefined; /** * Whether the amount should be treated as a percentage to be deducted per pay period. */ deductAsPercentage?: boolean | undefined; /** * A maximum total deduction for the lifetime of this garnishment. A null value indicates no maximum. */ totalAmount?: string | null | undefined; /** * Additional child support order details */ childSupport?: GarnishmentChildSupport | null | undefined; /** * The current version of the object. See the [versioning guide](https://docs.gusto.com/embedded-payroll/docs/idempotency) for information on how to use this field. */ version: string; }; /** @internal */ export const UpdateGarnishmentRequestGarnishmentType$outboundSchema: z.ZodNativeEnum = z .nativeEnum(UpdateGarnishmentRequestGarnishmentType); /** @internal */ export type UpdateGarnishmentRequest$Outbound = { active: boolean; amount?: string | undefined; description?: string | undefined; court_ordered?: boolean | undefined; garnishment_type?: string | null | undefined; times: number | null; recurring: boolean; annual_maximum: string | null; pay_period_maximum: string | null; deduct_as_percentage: boolean; total_amount?: string | null | undefined; child_support?: GarnishmentChildSupport$Outbound | null | undefined; version: string; }; /** @internal */ export const UpdateGarnishmentRequest$outboundSchema: z.ZodType< UpdateGarnishmentRequest$Outbound, z.ZodTypeDef, UpdateGarnishmentRequest > = z.object({ active: z.boolean().default(true), amount: z.string().optional(), description: z.string().optional(), courtOrdered: z.boolean().optional(), garnishmentType: z.nullable( UpdateGarnishmentRequestGarnishmentType$outboundSchema, ).optional(), times: z.nullable(z.number().int()).default(null), recurring: z.boolean().default(false), annualMaximum: z.nullable(z.string()).default(null), payPeriodMaximum: z.nullable(z.string()).default(null), deductAsPercentage: z.boolean().default(false), totalAmount: z.nullable(z.string()).optional(), childSupport: z.nullable(GarnishmentChildSupport$outboundSchema).optional(), version: z.string(), }).transform((v) => { return remap$(v, { courtOrdered: "court_ordered", garnishmentType: "garnishment_type", annualMaximum: "annual_maximum", payPeriodMaximum: "pay_period_maximum", deductAsPercentage: "deduct_as_percentage", totalAmount: "total_amount", childSupport: "child_support", }); }); export function updateGarnishmentRequestToJSON( updateGarnishmentRequest: UpdateGarnishmentRequest, ): string { return JSON.stringify( UpdateGarnishmentRequest$outboundSchema.parse(updateGarnishmentRequest), ); }