/* * 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"; /** * Type of the time off policy. Only "vacation" and "sick" can be created through the API, but other types may be present if the company was previously a Gusto.com customer. */ export const PolicyType = { Vacation: "vacation", Sick: "sick", Bereavement: "bereavement", Custom: "custom", FloatingHoliday: "floating_holiday", JuryDuty: "jury_duty", LearningAndDevelopment: "learning_and_development", ParentalLeave: "parental_leave", PersonalDay: "personal_day", Volunteer: "volunteer", Weather: "weather", } as const; /** * Type of the time off policy. Only "vacation" and "sick" can be created through the API, but other types may be present if the company was previously a Gusto.com customer. */ export type PolicyType = ClosedEnum; export type TimeOffPolicyEmployees = { uuid?: string | undefined; /** * The time off balance for the employee */ balance?: string | undefined; }; /** * Representation of a Time Off Policy */ export type TimeOffPolicy = { /** * Unique identifier of a time off policy */ uuid: string; /** * Unique identifier for the company owning the time off policy */ companyUuid: string; /** * Name of the time off policy */ name: string; /** * Type of the time off policy. Only "vacation" and "sick" can be created through the API, but other types may be present if the company was previously a Gusto.com customer. */ policyType: PolicyType; /** * Policy time off accrual method */ accrualMethod: string; /** * The rate at which the time off hours will accrue for an employee on the policy. Represented as a float, e.g. "40.0". */ accrualRate?: string | null | undefined; /** * The number of hours an employee has to work or be paid for to accrue the number of hours set in the accrual rate. Only used for hourly policies (per_hour_paid, per_hour_paid_no_overtime, per_hour_work, per_hour_worked_no_overtime). Represented as a float, e.g. "40.0". */ accrualRateUnit?: string | null | undefined; /** * Boolean representing if an employee's accrued time off hours will be paid out on termination */ paidOutOnTermination?: boolean | undefined; /** * Number of days before an employee on the policy will begin accruing time off hours */ accrualWaitingPeriodDays?: number | null | undefined; /** * The max number of hours an employee can carryover from one year to the next */ carryoverLimitHours?: string | null | undefined; /** * The max number of hours an employee can accrue in a year */ maxAccrualHoursPerYear?: string | null | undefined; /** * The max number of hours an employee can accrue */ maxHours?: string | null | undefined; /** * The date the policy resets. Format MM-DD */ policyResetDate?: string | null | undefined; /** * boolean representing if a policy has completed configuration */ complete?: boolean | undefined; /** * The current version of the object. See the [versioning guide](https://docs.gusto.com/embedded-payroll/docs/versioning#object-layer) for information on how to use this field. The version will be null if the policy is no longer active. */ version?: string | null | undefined; /** * boolean representing if a policy is active or not */ isActive: boolean; /** * List of employee UUIDs under a time off policy */ employees: Array; }; /** @internal */ export const PolicyType$inboundSchema: z.ZodNativeEnum = z .nativeEnum(PolicyType); /** @internal */ export const TimeOffPolicyEmployees$inboundSchema: z.ZodType< TimeOffPolicyEmployees, z.ZodTypeDef, unknown > = z.object({ uuid: z.string().optional(), balance: z.string().optional(), }); export function timeOffPolicyEmployeesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TimeOffPolicyEmployees$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TimeOffPolicyEmployees' from JSON`, ); } /** @internal */ export const TimeOffPolicy$inboundSchema: z.ZodType< TimeOffPolicy, z.ZodTypeDef, unknown > = z.object({ uuid: z.string(), company_uuid: z.string(), name: z.string(), policy_type: PolicyType$inboundSchema, accrual_method: z.string(), accrual_rate: z.nullable(z.string()).optional(), accrual_rate_unit: z.nullable(z.string()).optional(), paid_out_on_termination: z.boolean().optional(), accrual_waiting_period_days: z.nullable(z.number().int()).optional(), carryover_limit_hours: z.nullable(z.string()).optional(), max_accrual_hours_per_year: z.nullable(z.string()).optional(), max_hours: z.nullable(z.string()).optional(), policy_reset_date: z.nullable(z.string()).optional(), complete: z.boolean().optional(), version: z.nullable(z.string()).optional(), is_active: z.boolean(), employees: z.array(z.lazy(() => TimeOffPolicyEmployees$inboundSchema)), }).transform((v) => { return remap$(v, { "company_uuid": "companyUuid", "policy_type": "policyType", "accrual_method": "accrualMethod", "accrual_rate": "accrualRate", "accrual_rate_unit": "accrualRateUnit", "paid_out_on_termination": "paidOutOnTermination", "accrual_waiting_period_days": "accrualWaitingPeriodDays", "carryover_limit_hours": "carryoverLimitHours", "max_accrual_hours_per_year": "maxAccrualHoursPerYear", "max_hours": "maxHours", "policy_reset_date": "policyResetDate", "is_active": "isActive", }); }); export function timeOffPolicyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TimeOffPolicy$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TimeOffPolicy' from JSON`, ); }