import {z} from 'zod' export type EmployeeBenefitUpdateRequest = {version: string, active?: boolean | undefined, employee_deduction?: string | undefined, deduct_as_percentage?: boolean | undefined, employee_deduction_annual_maximum?: (string | null) | undefined, effective_date?: string | undefined, expiration_date?: (string | null) | undefined, contribution?: ({type?: ('amount' | 'percentage' | 'tiered') | undefined, value?: (string | Array<{rate?: string | undefined, threshold?: string | undefined}>) | undefined}) | undefined, elective?: boolean | undefined, company_contribution_annual_maximum?: (string | null) | undefined, limit_option?: ('Family' | 'Individual' | 'Joint Filing or Single' | 'Married and Filing Separately' | null) | undefined, catch_up?: boolean | undefined, coverage_amount?: (string | null) | undefined, deduction_reduces_taxable_income?: ('unset' | 'reduces_taxable_income' | 'does_not_reduce_taxable_income' | null) | undefined, coverage_salary_multiplier?: string | undefined, company_contribution?: string | undefined, contribute_as_percentage?: boolean | undefined}; export type UpdateApiV1EmployeeBenefitsEmployeeBenefitIdArgs = {'X-Gusto-API-Version'?: '2026-06-15' | undefined, employee_benefit_id: string, body: EmployeeBenefitUpdateRequest}; export type UpdateApiV1EmployeeBenefitsEmployeeBenefitIdOptions = {baseUrl?: string | undefined, CompanyAccessAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const employeeBenefit = z.object({version: z.string().optional(), active: z.boolean().optional(), employee_deduction: z.string().optional(), deduct_as_percentage: z.boolean().optional(), employee_deduction_annual_maximum: z.string().nullable().optional(), contribution: z.object({type: z.string().optional(), value: z.union([z.string(), z.object({tiers: z.array(z.object({rate: z.string().optional(), threshold: z.string().optional(), threshold_delta: z.string().optional()})).optional()})]).optional()}).optional(), elective: z.boolean().optional(), company_contribution_annual_maximum: z.string().nullable().optional(), limit_option: z.string().nullable().optional(), catch_up: z.boolean().nullable().optional(), retirement_loan_identifier: z.string().nullable().optional(), coverage_amount: z.string().nullable().optional(), deduction_reduces_taxable_income: z.enum(["unset", "reduces_taxable_income", "does_not_reduce_taxable_income"]).nullable().optional(), coverage_salary_multiplier: z.string().nullable().optional(), company_contribution: z.string().optional(), contribute_as_percentage: z.boolean().optional(), effective_date: z.string().optional(), expiration_date: z.string().nullable().optional(), employee_uuid: z.string().optional(), company_benefit_uuid: z.string().optional(), uuid: z.string()}).and(z.record(z.string(), z.unknown())); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Update an employee benefit * * PUT /v1/employee_benefits/{employee_benefit_id} */ export const updateApiV1EmployeeBenefitsEmployeeBenefitId = async (args: UpdateApiV1EmployeeBenefitsEmployeeBenefitIdArgs, options?: UpdateApiV1EmployeeBenefitsEmployeeBenefitIdOptions) => { const {baseUrl = "https://api.gusto-demo.com", fetch: fetchFn = fetch, CompanyAccessAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['X-Gusto-API-Version'] != null) headers.set("X-Gusto-API-Version", String(args['X-Gusto-API-Version'])) if (CompanyAccessAuth !== undefined) headers.set('authorization', `Bearer ${CompanyAccessAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/employee_benefits/${encodeURIComponent(String(args.employee_benefit_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(employeeBenefit, await res.json()) };