/* * 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 { collectExtraKeys as collectExtraKeys$, safeParse, } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { RFCDate } from "../../types/rfcdate.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * A single tier of a tiered matching scheme. */ export type Tiers = { /** * The percentage of employee deduction within this tier the company contribution will match. */ rate?: string | undefined; /** * Specifies the upper limit (inclusive) percentage of the employee contribution that this tier applies to. * * @remarks * * Use threshold to define each tier's end point, with tiers applied cumulatively from 0% upwards. * * For example: * * If the first tier has a threshold of "3", and `rate` of "100", the company will match 100% of employee contributions from 0% up to and including 3% of payroll. * * If the next tier has a threshold of "5" and a rate of "50", the company will match 50% of contributions from above 3% up to and including 5% of payroll. */ threshold?: string | undefined; /** * The step up difference between this tier's threshold and the previous tier's threshold. In the first tier, this is equivalent to threshold. */ thresholdDelta?: string | undefined; }; export type Two = { tiers?: Array | undefined; }; /** * For the `amount` and `percentage` contribution types, the value of the corresponding amount or percentage. * * @remarks * * For the `tiered` contribution type, an array of tiers. */ export type EmployeeBenefitValue = string | Two; /** * An object representing the type and value of the company contribution. */ export type Contribution = { /** * The company contribution scheme. * * @remarks * * "amount": The company contributes a fixed amount per payroll. If elective is true, the contribution is matching, dollar-for-dollar. * * "percentage": The company contributes a percentage of the payroll amount per payroll period. If elective is true, the contribution is matching, dollar-for-dollar. * * "tiered": The company contribution varies according to the size of the employee deduction. */ type?: string | undefined; /** * For the `amount` and `percentage` contribution types, the value of the corresponding amount or percentage. * * @remarks * * For the `tiered` contribution type, an array of tiers. */ value?: string | Two | undefined; }; export const DeductionReducesTaxableIncome = { Unset: "unset", ReducesTaxableIncome: "reduces_taxable_income", DoesNotReduceTaxableIncome: "does_not_reduce_taxable_income", } as const; export type DeductionReducesTaxableIncome = ClosedEnum< typeof DeductionReducesTaxableIncome >; /** * The representation of an employee benefit. */ export type EmployeeBenefit = { /** * 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 | undefined; /** * Whether the employee benefit is active. */ active: boolean; /** * The amount to be deducted, per pay period, from the employee's pay. */ employeeDeduction: string; /** * Whether the employee deduction amount should be treated as a percentage to be deducted from each payroll. */ deductAsPercentage: boolean; /** * The maximum employee deduction amount per year. A null value signifies no limit. */ employeeDeductionAnnualMaximum?: string | null | undefined; /** * An object representing the type and value of the company contribution. */ contribution?: Contribution | undefined; /** * Whether the company contribution is elective (aka matching). For "tiered" contribution types, this is always true. */ elective: boolean; /** * The maximum company contribution amount per year. A null value signifies no limit. */ companyContributionAnnualMaximum?: string | null | undefined; /** * Some benefits require additional information to determine their limit. * * @remarks * * `Family` and `Individual` are applicable to HSA benefit. * * `Joint Filing or Single` and `Married and Filing Separately` are applicable to Dependent Care FSA benefit. */ limitOption?: string | null | undefined; /** * Whether the employee should use a benefit's "catch up" rate. Only Roth 401k and 401k benefits use this value for employees over 50. */ catchUp: boolean | null; /** * Identifier for a 401(k) loan assigned by the 401(k) provider */ retirementLoanIdentifier?: string | null | undefined; /** * The amount that the employee is insured for. Note: company contribution cannot be present if coverage amount is set. */ coverageAmount?: string | null | undefined; /** * Whether the employee deduction reduces taxable income or not. Only valid for Group Term Life benefits. Note: when the value is not "unset", coverage amount and coverage salary multiplier are ignored. */ deductionReducesTaxableIncome?: | DeductionReducesTaxableIncome | null | undefined; /** * The coverage amount as a multiple of the employee's salary. Only applicable for Group Term Life benefits. Note: cannot be set if coverage amount is also set. */ coverageSalaryMultiplier: string | null; /** * The amount to be paid, per pay period, by the company. This field will not appear for tiered contribution types. * * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ companyContribution: string; /** * Whether the company_contribution value should be treated as a percentage to be added to each payroll. This field will not appear for tiered contribution types. * * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ contributeAsPercentage: boolean; /** * The date the employee benefit will start. */ effectiveDate?: RFCDate | undefined; /** * The date the employee benefit will expire. A null value indicates the benefit will not expire. */ expirationDate?: RFCDate | null | undefined; /** * The UUID of the employee to which the benefit belongs. */ employeeUuid?: string | undefined; /** * The UUID of the company benefit. */ companyBenefitUuid?: string | undefined; /** * The UUID of the employee benefit. */ uuid: string; additionalProperties?: { [k: string]: any } | undefined; }; /** @internal */ export const Tiers$inboundSchema: z.ZodType = z .object({ rate: z.string().optional(), threshold: z.string().optional(), threshold_delta: z.string().optional(), }).transform((v) => { return remap$(v, { "threshold_delta": "thresholdDelta", }); }); export function tiersFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Tiers$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Tiers' from JSON`, ); } /** @internal */ export const Two$inboundSchema: z.ZodType = z .object({ tiers: z.array(z.lazy(() => Tiers$inboundSchema)).optional(), }); export function twoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Two$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Two' from JSON`, ); } /** @internal */ export const EmployeeBenefitValue$inboundSchema: z.ZodType< EmployeeBenefitValue, z.ZodTypeDef, unknown > = z.union([z.string(), z.lazy(() => Two$inboundSchema)]); export function employeeBenefitValueFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EmployeeBenefitValue$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EmployeeBenefitValue' from JSON`, ); } /** @internal */ export const Contribution$inboundSchema: z.ZodType< Contribution, z.ZodTypeDef, unknown > = z.object({ type: z.string().optional(), value: z.union([z.string(), z.lazy(() => Two$inboundSchema)]).optional(), }); export function contributionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Contribution$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Contribution' from JSON`, ); } /** @internal */ export const DeductionReducesTaxableIncome$inboundSchema: z.ZodNativeEnum< typeof DeductionReducesTaxableIncome > = z.nativeEnum(DeductionReducesTaxableIncome); /** @internal */ export const EmployeeBenefit$inboundSchema: z.ZodType< EmployeeBenefit, z.ZodTypeDef, unknown > = collectExtraKeys$( z.object({ version: z.string().optional(), active: z.boolean().default(true), employee_deduction: z.string().default("0.00"), deduct_as_percentage: z.boolean().default(false), employee_deduction_annual_maximum: z.nullable(z.string()).optional(), contribution: z.lazy(() => Contribution$inboundSchema).optional(), elective: z.boolean().default(false), company_contribution_annual_maximum: z.nullable(z.string()).optional(), limit_option: z.nullable(z.string()).optional(), catch_up: z.nullable(z.boolean().default(false)), retirement_loan_identifier: z.nullable(z.string()).optional(), coverage_amount: z.nullable(z.string()).optional(), deduction_reduces_taxable_income: z.nullable( DeductionReducesTaxableIncome$inboundSchema, ).optional(), coverage_salary_multiplier: z.nullable(z.string().default("0.00")), company_contribution: z.string().default("0.00"), contribute_as_percentage: z.boolean().default(false), effective_date: z.string().transform(v => new RFCDate(v)).optional(), expiration_date: z.nullable(z.string().transform(v => new RFCDate(v))) .optional(), employee_uuid: z.string().optional(), company_benefit_uuid: z.string().optional(), uuid: z.string(), }).catchall(z.any()), "additionalProperties", true, ).transform((v) => { return remap$(v, { "employee_deduction": "employeeDeduction", "deduct_as_percentage": "deductAsPercentage", "employee_deduction_annual_maximum": "employeeDeductionAnnualMaximum", "company_contribution_annual_maximum": "companyContributionAnnualMaximum", "limit_option": "limitOption", "catch_up": "catchUp", "retirement_loan_identifier": "retirementLoanIdentifier", "coverage_amount": "coverageAmount", "deduction_reduces_taxable_income": "deductionReducesTaxableIncome", "coverage_salary_multiplier": "coverageSalaryMultiplier", "company_contribution": "companyContribution", "contribute_as_percentage": "contributeAsPercentage", "effective_date": "effectiveDate", "expiration_date": "expirationDate", "employee_uuid": "employeeUuid", "company_benefit_uuid": "companyBenefitUuid", }); }); export function employeeBenefitFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EmployeeBenefit$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EmployeeBenefit' from JSON`, ); }