/* * 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 { RFCDate } from "../../types/rfcdate.js"; import { Employee, Employee$inboundSchema } from "../components/employee.js"; import { HTTPMetadata, HTTPMetadata$inboundSchema, } from "../components/httpmetadata.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Determines the date-based API version associated with your API call. If none is provided, your application's [minimum API version](https://docs.gusto.com/embedded-payroll/docs/api-versioning#minimum-api-version) is used. */ export const PutV1HistoricalEmployeesHeaderXGustoAPIVersion = { TwoThousandAndTwentyFiveMinus06Minus15: "2025-06-15", } as const; /** * Determines the date-based API version associated with your API call. If none is provided, your application's [minimum API version](https://docs.gusto.com/embedded-payroll/docs/api-versioning#minimum-api-version) is used. */ export type PutV1HistoricalEmployeesHeaderXGustoAPIVersion = ClosedEnum< typeof PutV1HistoricalEmployeesHeaderXGustoAPIVersion >; /** * Primary work location for this historical employment row. */ export type WorkAddress = { /** * UUID of a company work location from the company locations response. */ locationUuid: string; }; /** * Residential address on file for tax withholding and compliance mail. */ export type HomeAddress = { /** * Street address line 1. */ street1: string; /** * Apartment, suite, unit, or building (optional). */ street2?: string | null | undefined; /** * City. */ city: string; /** * Two-letter U.S. state or territory postal abbreviation. */ state: string; /** * ZIP or ZIP+4. */ zip: string; }; /** * End of the historical employment period. */ export type Termination = { /** * Last day of employment (termination date). This is recorded on the employment; use the calendar date the person stopped working for the company. */ effectiveDate: RFCDate; }; /** * Hire date for the historical job used to build employments and filings. */ export type Job = { /** * First calendar day the employee was employed in this role at the company. */ hireDate: RFCDate; }; /** * Workers' compensation fields for Washington (WA) or Wyoming (WY) when the work address is in those states; omit when not applicable. */ export type EmployeeStateTaxes = { /** * Whether this job is eligible for workers' compensation coverage in the states of Washington (WA) or Wyoming (WY). */ wcCovered?: boolean | undefined; /** * The risk class code for workers' compensation in Washington or Wyoming state. For Washington, visit [Washington state's Risk Class page](https://www.lni.wa.gov/insurance/rates-risk-classes/risk-classes-for-workers-compensation/risk-class-lookup#/) to learn more. For Wyoming you can search for the code online using [WY Workforce Services website](https://dws.wyo.gov/dws-division/workers-compensation/) or call the agency at (307) 235-3217. */ wcClassCode?: string | undefined; }; /** * Request body for creating or updating a **historical employee**—someone who already separated from the company and must appear on year-to-date or tax filings without receiving ongoing payroll. * * @remarks * * Send this object under the JSON root key `employee`. All dates are ISO 8601 (`YYYY-MM-DD`). Use a `work_address.location_uuid` returned from your company locations API for an active work site. */ export type PutV1HistoricalEmployeesRequestBody = { /** * 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; /** * Legal first name as it appears on government-issued identification. */ firstName: string; /** * Single middle initial, if any. */ middleInitial?: string | undefined; /** * Legal last name as it appears on government-issued identification. */ lastName: string; /** * Preferred given name for display; omit when the same as legal first name. */ preferredFirstName?: string | undefined; /** * Date of birth (YYYY-MM-DD). */ dateOfBirth: RFCDate; /** * Nine-digit U.S. Social Security number **without** dashes or spaces. Must pass Gusto/SSA validation in production; use a valid test SSN in sandbox environments. * * @remarks */ ssn: string; /** * Primary work location for this historical employment row. */ workAddress: WorkAddress; /** * Residential address on file for tax withholding and compliance mail. */ homeAddress: HomeAddress; /** * End of the historical employment period. */ termination: Termination; /** * Optional. When provided, stored on the employee record for notifications and profile. */ email?: string | undefined; /** * Hire date for the historical job used to build employments and filings. */ job: Job; /** * Workers' compensation fields for Washington (WA) or Wyoming (WY) when the work address is in those states; omit when not applicable. */ employeeStateTaxes?: EmployeeStateTaxes | undefined; }; export type PutV1HistoricalEmployeesRequest = { /** * Determines the date-based API version associated with your API call. If none is provided, your application's [minimum API version](https://docs.gusto.com/embedded-payroll/docs/api-versioning#minimum-api-version) is used. */ xGustoAPIVersion?: PutV1HistoricalEmployeesHeaderXGustoAPIVersion | undefined; /** * The UUID of the company that will employ this historical record. */ companyUuid: string; /** * The UUID of the historical employee returned from create or list responses. */ historicalEmployeeUuid: string; requestBody: PutV1HistoricalEmployeesRequestBody; }; export type PutV1HistoricalEmployeesResponse = { httpMeta: HTTPMetadata; /** * Successful */ employee?: Employee | undefined; }; /** @internal */ export const PutV1HistoricalEmployeesHeaderXGustoAPIVersion$outboundSchema: z.ZodNativeEnum = z .nativeEnum(PutV1HistoricalEmployeesHeaderXGustoAPIVersion); /** @internal */ export type WorkAddress$Outbound = { location_uuid: string; }; /** @internal */ export const WorkAddress$outboundSchema: z.ZodType< WorkAddress$Outbound, z.ZodTypeDef, WorkAddress > = z.object({ locationUuid: z.string(), }).transform((v) => { return remap$(v, { locationUuid: "location_uuid", }); }); export function workAddressToJSON(workAddress: WorkAddress): string { return JSON.stringify(WorkAddress$outboundSchema.parse(workAddress)); } /** @internal */ export type HomeAddress$Outbound = { street_1: string; street_2?: string | null | undefined; city: string; state: string; zip: string; }; /** @internal */ export const HomeAddress$outboundSchema: z.ZodType< HomeAddress$Outbound, z.ZodTypeDef, HomeAddress > = z.object({ street1: z.string(), street2: z.nullable(z.string()).optional(), city: z.string(), state: z.string(), zip: z.string(), }).transform((v) => { return remap$(v, { street1: "street_1", street2: "street_2", }); }); export function homeAddressToJSON(homeAddress: HomeAddress): string { return JSON.stringify(HomeAddress$outboundSchema.parse(homeAddress)); } /** @internal */ export type Termination$Outbound = { effective_date: string; }; /** @internal */ export const Termination$outboundSchema: z.ZodType< Termination$Outbound, z.ZodTypeDef, Termination > = z.object({ effectiveDate: z.instanceof(RFCDate).transform(v => v.toString()), }).transform((v) => { return remap$(v, { effectiveDate: "effective_date", }); }); export function terminationToJSON(termination: Termination): string { return JSON.stringify(Termination$outboundSchema.parse(termination)); } /** @internal */ export type Job$Outbound = { hire_date: string; }; /** @internal */ export const Job$outboundSchema: z.ZodType = z .object({ hireDate: z.instanceof(RFCDate).transform(v => v.toString()), }).transform((v) => { return remap$(v, { hireDate: "hire_date", }); }); export function jobToJSON(job: Job): string { return JSON.stringify(Job$outboundSchema.parse(job)); } /** @internal */ export type EmployeeStateTaxes$Outbound = { wc_covered?: boolean | undefined; wc_class_code?: string | undefined; }; /** @internal */ export const EmployeeStateTaxes$outboundSchema: z.ZodType< EmployeeStateTaxes$Outbound, z.ZodTypeDef, EmployeeStateTaxes > = z.object({ wcCovered: z.boolean().optional(), wcClassCode: z.string().optional(), }).transform((v) => { return remap$(v, { wcCovered: "wc_covered", wcClassCode: "wc_class_code", }); }); export function employeeStateTaxesToJSON( employeeStateTaxes: EmployeeStateTaxes, ): string { return JSON.stringify( EmployeeStateTaxes$outboundSchema.parse(employeeStateTaxes), ); } /** @internal */ export type PutV1HistoricalEmployeesRequestBody$Outbound = { version: string; first_name: string; middle_initial?: string | undefined; last_name: string; preferred_first_name?: string | undefined; date_of_birth: string; ssn: string; work_address: WorkAddress$Outbound; home_address: HomeAddress$Outbound; termination: Termination$Outbound; email?: string | undefined; job: Job$Outbound; employee_state_taxes?: EmployeeStateTaxes$Outbound | undefined; }; /** @internal */ export const PutV1HistoricalEmployeesRequestBody$outboundSchema: z.ZodType< PutV1HistoricalEmployeesRequestBody$Outbound, z.ZodTypeDef, PutV1HistoricalEmployeesRequestBody > = z.object({ version: z.string(), firstName: z.string(), middleInitial: z.string().optional(), lastName: z.string(), preferredFirstName: z.string().optional(), dateOfBirth: z.instanceof(RFCDate).transform(v => v.toString()), ssn: z.string(), workAddress: z.lazy(() => WorkAddress$outboundSchema), homeAddress: z.lazy(() => HomeAddress$outboundSchema), termination: z.lazy(() => Termination$outboundSchema), email: z.string().optional(), job: z.lazy(() => Job$outboundSchema), employeeStateTaxes: z.lazy(() => EmployeeStateTaxes$outboundSchema) .optional(), }).transform((v) => { return remap$(v, { firstName: "first_name", middleInitial: "middle_initial", lastName: "last_name", preferredFirstName: "preferred_first_name", dateOfBirth: "date_of_birth", workAddress: "work_address", homeAddress: "home_address", employeeStateTaxes: "employee_state_taxes", }); }); export function putV1HistoricalEmployeesRequestBodyToJSON( putV1HistoricalEmployeesRequestBody: PutV1HistoricalEmployeesRequestBody, ): string { return JSON.stringify( PutV1HistoricalEmployeesRequestBody$outboundSchema.parse( putV1HistoricalEmployeesRequestBody, ), ); } /** @internal */ export type PutV1HistoricalEmployeesRequest$Outbound = { "X-Gusto-API-Version": string; company_uuid: string; historical_employee_uuid: string; RequestBody: PutV1HistoricalEmployeesRequestBody$Outbound; }; /** @internal */ export const PutV1HistoricalEmployeesRequest$outboundSchema: z.ZodType< PutV1HistoricalEmployeesRequest$Outbound, z.ZodTypeDef, PutV1HistoricalEmployeesRequest > = z.object({ xGustoAPIVersion: PutV1HistoricalEmployeesHeaderXGustoAPIVersion$outboundSchema.default( "2025-06-15", ), companyUuid: z.string(), historicalEmployeeUuid: z.string(), requestBody: z.lazy(() => PutV1HistoricalEmployeesRequestBody$outboundSchema), }).transform((v) => { return remap$(v, { xGustoAPIVersion: "X-Gusto-API-Version", companyUuid: "company_uuid", historicalEmployeeUuid: "historical_employee_uuid", requestBody: "RequestBody", }); }); export function putV1HistoricalEmployeesRequestToJSON( putV1HistoricalEmployeesRequest: PutV1HistoricalEmployeesRequest, ): string { return JSON.stringify( PutV1HistoricalEmployeesRequest$outboundSchema.parse( putV1HistoricalEmployeesRequest, ), ); } /** @internal */ export const PutV1HistoricalEmployeesResponse$inboundSchema: z.ZodType< PutV1HistoricalEmployeesResponse, z.ZodTypeDef, unknown > = z.object({ HttpMeta: HTTPMetadata$inboundSchema, Employee: Employee$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "HttpMeta": "httpMeta", "Employee": "employee", }); }); export function putV1HistoricalEmployeesResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PutV1HistoricalEmployeesResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PutV1HistoricalEmployeesResponse' from JSON`, ); }