/* * 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 { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The source of the company benefit. This can be "internal", "external", or "partnered". Company benefits created via the API default to "external". Certain partners can create company benefits with a source of "partnered". */ export const CompanyBenefitWithEmployeeBenefitsSource = { Internal: "internal", External: "external", Partnered: "partnered", } as const; /** * The source of the company benefit. This can be "internal", "external", or "partnered". Company benefits created via the API default to "external". Certain partners can create company benefits with a source of "partnered". */ export type CompanyBenefitWithEmployeeBenefitsSource = ClosedEnum< typeof CompanyBenefitWithEmployeeBenefitsSource >; export const CompanyBenefitWithEmployeeBenefitsCatchUpType = { Elective: "elective", Deemed: "deemed", } as const; export type CompanyBenefitWithEmployeeBenefitsCatchUpType = ClosedEnum< typeof CompanyBenefitWithEmployeeBenefitsCatchUpType >; /** * A single tier of a tiered matching scheme. */ export type CompanyBenefitWithEmployeeBenefitsValueTiers = { /** * 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 CompanyBenefitWithEmployeeBenefitsValue2 = { 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 CompanyBenefitWithEmployeeBenefitsValue = | string | CompanyBenefitWithEmployeeBenefitsValue2; /** * An object representing the type and value of the company contribution. */ export type CompanyBenefitWithEmployeeBenefitsContribution = { /** * 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 | CompanyBenefitWithEmployeeBenefitsValue2 | undefined; }; export type EmployeeBenefits = { /** * The UUID of the employee to which the benefit belongs. */ employeeUuid?: string | undefined; /** * The UUID of the company benefit. */ companyBenefitUuid?: string | undefined; /** * Whether the employee benefit is active. */ active: boolean; /** * Whether the employee deduction amount should be treated as a percentage to be deducted from each payroll. */ deductAsPercentage: boolean; /** * The amount to be deducted, per pay period, from the employee's pay. */ employeeDeduction: string; /** * The value of the company contribution */ companyContribution?: string | undefined; /** * The date when the employee benefit becomes effective. If not provided, the benefit will be effective from 1970-01-01 (unix epoch). */ effectiveDate?: string | undefined; /** * The date when the employee benefit expires. If not provided, the benefit will have no expiration date. */ expirationDate?: string | undefined; /** * An object representing the type and value of the company contribution. */ contribution?: CompanyBenefitWithEmployeeBenefitsContribution | undefined; }; /** * The representation of a company benefit. */ export type CompanyBenefitWithEmployeeBenefits = { /** * 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; /** * The UUID of the company. */ companyUuid?: string | undefined; /** * The UUID of the company benefit. */ uuid: string; /** * The type of the benefit to which the company benefit belongs (same as benefit_id). */ benefitType?: number | undefined; /** * Whether this benefit is active for employee participation. Company benefits may only be deactivated if no employees are actively participating. */ active: boolean; /** * The description of the company benefit. For example, a company may offer multiple benefits with an ID of 1 (for Medical Insurance). The description would show something more specific like “Kaiser Permanente” or “Blue Cross/ Blue Shield”. */ description?: string | undefined; /** * The source of the company benefit. This can be "internal", "external", or "partnered". Company benefits created via the API default to "external". Certain partners can create company benefits with a source of "partnered". */ source?: CompanyBenefitWithEmployeeBenefitsSource | undefined; /** * The partner name of the partner that created the company benefit. For example, "XYZ Corp". */ partnerName?: string | null | undefined; /** * Whether this company benefit can be deleted. Deletable will be set to true if the benefit has not been used in payroll, has no employee benefits associated, and the benefit is not owned by Gusto or a Partner */ deletable?: boolean | undefined; /** * Whether employee deductions and company contributions can be set as percentages of payroll for an individual employee. This is determined by the type of benefit and is not configurable by the company. */ supportsPercentageAmounts?: boolean | undefined; /** * Whether the employer is subject to pay employer taxes when an employee is on leave. Only applicable to third party sick pay benefits. */ responsibleForEmployerTaxes?: boolean | undefined; /** * Whether the employer is subject to file W-2 forms for an employee on leave. Only applicable to third party sick pay benefits. */ responsibleForEmployeeW2?: boolean | undefined; /** * The type of catch-up contribution for this benefit, as required by Section 603 of the SECURE 2.0 Act. Only applicable to pre-tax 401(k) and 403(b) benefits. */ catchUpType?: | CompanyBenefitWithEmployeeBenefitsCatchUpType | null | undefined; employeeBenefits?: Array | undefined; }; /** @internal */ export const CompanyBenefitWithEmployeeBenefitsSource$inboundSchema: z.ZodNativeEnum = z .nativeEnum(CompanyBenefitWithEmployeeBenefitsSource); /** @internal */ export const CompanyBenefitWithEmployeeBenefitsCatchUpType$inboundSchema: z.ZodNativeEnum = z .nativeEnum(CompanyBenefitWithEmployeeBenefitsCatchUpType); /** @internal */ export const CompanyBenefitWithEmployeeBenefitsValueTiers$inboundSchema: z.ZodType< CompanyBenefitWithEmployeeBenefitsValueTiers, z.ZodTypeDef, unknown > = 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 companyBenefitWithEmployeeBenefitsValueTiersFromJSON( jsonString: string, ): SafeParseResult< CompanyBenefitWithEmployeeBenefitsValueTiers, SDKValidationError > { return safeParse( jsonString, (x) => CompanyBenefitWithEmployeeBenefitsValueTiers$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'CompanyBenefitWithEmployeeBenefitsValueTiers' from JSON`, ); } /** @internal */ export const CompanyBenefitWithEmployeeBenefitsValue2$inboundSchema: z.ZodType< CompanyBenefitWithEmployeeBenefitsValue2, z.ZodTypeDef, unknown > = z.object({ tiers: z.array( z.lazy(() => CompanyBenefitWithEmployeeBenefitsValueTiers$inboundSchema), ).optional(), }); export function companyBenefitWithEmployeeBenefitsValue2FromJSON( jsonString: string, ): SafeParseResult< CompanyBenefitWithEmployeeBenefitsValue2, SDKValidationError > { return safeParse( jsonString, (x) => CompanyBenefitWithEmployeeBenefitsValue2$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'CompanyBenefitWithEmployeeBenefitsValue2' from JSON`, ); } /** @internal */ export const CompanyBenefitWithEmployeeBenefitsValue$inboundSchema: z.ZodType< CompanyBenefitWithEmployeeBenefitsValue, z.ZodTypeDef, unknown > = z.union([ z.string(), z.lazy(() => CompanyBenefitWithEmployeeBenefitsValue2$inboundSchema), ]); export function companyBenefitWithEmployeeBenefitsValueFromJSON( jsonString: string, ): SafeParseResult< CompanyBenefitWithEmployeeBenefitsValue, SDKValidationError > { return safeParse( jsonString, (x) => CompanyBenefitWithEmployeeBenefitsValue$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'CompanyBenefitWithEmployeeBenefitsValue' from JSON`, ); } /** @internal */ export const CompanyBenefitWithEmployeeBenefitsContribution$inboundSchema: z.ZodType< CompanyBenefitWithEmployeeBenefitsContribution, z.ZodTypeDef, unknown > = z.object({ type: z.string().optional(), value: z.union([ z.string(), z.lazy(() => CompanyBenefitWithEmployeeBenefitsValue2$inboundSchema), ]).optional(), }); export function companyBenefitWithEmployeeBenefitsContributionFromJSON( jsonString: string, ): SafeParseResult< CompanyBenefitWithEmployeeBenefitsContribution, SDKValidationError > { return safeParse( jsonString, (x) => CompanyBenefitWithEmployeeBenefitsContribution$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'CompanyBenefitWithEmployeeBenefitsContribution' from JSON`, ); } /** @internal */ export const EmployeeBenefits$inboundSchema: z.ZodType< EmployeeBenefits, z.ZodTypeDef, unknown > = z.object({ employee_uuid: z.string().optional(), company_benefit_uuid: z.string().optional(), active: z.boolean().default(true), deduct_as_percentage: z.boolean().default(false), employee_deduction: z.string().default("0.00"), company_contribution: z.string().optional(), effective_date: z.string().optional(), expiration_date: z.string().optional(), contribution: z.lazy(() => CompanyBenefitWithEmployeeBenefitsContribution$inboundSchema ).optional(), }).transform((v) => { return remap$(v, { "employee_uuid": "employeeUuid", "company_benefit_uuid": "companyBenefitUuid", "deduct_as_percentage": "deductAsPercentage", "employee_deduction": "employeeDeduction", "company_contribution": "companyContribution", "effective_date": "effectiveDate", "expiration_date": "expirationDate", }); }); export function employeeBenefitsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EmployeeBenefits$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EmployeeBenefits' from JSON`, ); } /** @internal */ export const CompanyBenefitWithEmployeeBenefits$inboundSchema: z.ZodType< CompanyBenefitWithEmployeeBenefits, z.ZodTypeDef, unknown > = z.object({ version: z.string().optional(), company_uuid: z.string().optional(), uuid: z.string(), benefit_type: z.number().int().optional(), active: z.boolean().default(true), description: z.string().optional(), source: CompanyBenefitWithEmployeeBenefitsSource$inboundSchema.optional(), partner_name: z.nullable(z.string()).optional(), deletable: z.boolean().optional(), supports_percentage_amounts: z.boolean().optional(), responsible_for_employer_taxes: z.boolean().optional(), responsible_for_employee_w2: z.boolean().optional(), catch_up_type: z.nullable( CompanyBenefitWithEmployeeBenefitsCatchUpType$inboundSchema, ).optional(), employee_benefits: z.array(z.lazy(() => EmployeeBenefits$inboundSchema)) .optional(), }).transform((v) => { return remap$(v, { "company_uuid": "companyUuid", "benefit_type": "benefitType", "partner_name": "partnerName", "supports_percentage_amounts": "supportsPercentageAmounts", "responsible_for_employer_taxes": "responsibleForEmployerTaxes", "responsible_for_employee_w2": "responsibleForEmployeeW2", "catch_up_type": "catchUpType", "employee_benefits": "employeeBenefits", }); }); export function companyBenefitWithEmployeeBenefitsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CompanyBenefitWithEmployeeBenefits$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CompanyBenefitWithEmployeeBenefits' from JSON`, ); }