/* * 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 { RFCDate } from "../../types/rfcdate.js"; /** * 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 HistoricalEmployeeBodyHomeAddress = { /** * 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 HistoricalEmployeeBodyTermination = { /** * 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 HistoricalEmployeeBodyJob = { /** * 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 HistoricalEmployeeBody = { /** * 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: HistoricalEmployeeBodyHomeAddress; /** * End of the historical employment period. */ termination: HistoricalEmployeeBodyTermination; /** * 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: HistoricalEmployeeBodyJob; /** * Workers' compensation fields for Washington (WA) or Wyoming (WY) when the work address is in those states; omit when not applicable. */ employeeStateTaxes?: EmployeeStateTaxes | undefined; }; /** @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 HistoricalEmployeeBodyHomeAddress$Outbound = { street_1: string; street_2?: string | null | undefined; city: string; state: string; zip: string; }; /** @internal */ export const HistoricalEmployeeBodyHomeAddress$outboundSchema: z.ZodType< HistoricalEmployeeBodyHomeAddress$Outbound, z.ZodTypeDef, HistoricalEmployeeBodyHomeAddress > = 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 historicalEmployeeBodyHomeAddressToJSON( historicalEmployeeBodyHomeAddress: HistoricalEmployeeBodyHomeAddress, ): string { return JSON.stringify( HistoricalEmployeeBodyHomeAddress$outboundSchema.parse( historicalEmployeeBodyHomeAddress, ), ); } /** @internal */ export type HistoricalEmployeeBodyTermination$Outbound = { effective_date: string; }; /** @internal */ export const HistoricalEmployeeBodyTermination$outboundSchema: z.ZodType< HistoricalEmployeeBodyTermination$Outbound, z.ZodTypeDef, HistoricalEmployeeBodyTermination > = z.object({ effectiveDate: z.instanceof(RFCDate).transform(v => v.toString()), }).transform((v) => { return remap$(v, { effectiveDate: "effective_date", }); }); export function historicalEmployeeBodyTerminationToJSON( historicalEmployeeBodyTermination: HistoricalEmployeeBodyTermination, ): string { return JSON.stringify( HistoricalEmployeeBodyTermination$outboundSchema.parse( historicalEmployeeBodyTermination, ), ); } /** @internal */ export type HistoricalEmployeeBodyJob$Outbound = { hire_date: string; }; /** @internal */ export const HistoricalEmployeeBodyJob$outboundSchema: z.ZodType< HistoricalEmployeeBodyJob$Outbound, z.ZodTypeDef, HistoricalEmployeeBodyJob > = z.object({ hireDate: z.instanceof(RFCDate).transform(v => v.toString()), }).transform((v) => { return remap$(v, { hireDate: "hire_date", }); }); export function historicalEmployeeBodyJobToJSON( historicalEmployeeBodyJob: HistoricalEmployeeBodyJob, ): string { return JSON.stringify( HistoricalEmployeeBodyJob$outboundSchema.parse(historicalEmployeeBodyJob), ); } /** @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 HistoricalEmployeeBody$Outbound = { 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: HistoricalEmployeeBodyHomeAddress$Outbound; termination: HistoricalEmployeeBodyTermination$Outbound; email?: string | undefined; job: HistoricalEmployeeBodyJob$Outbound; employee_state_taxes?: EmployeeStateTaxes$Outbound | undefined; }; /** @internal */ export const HistoricalEmployeeBody$outboundSchema: z.ZodType< HistoricalEmployeeBody$Outbound, z.ZodTypeDef, HistoricalEmployeeBody > = z.object({ 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(() => HistoricalEmployeeBodyHomeAddress$outboundSchema), termination: z.lazy(() => HistoricalEmployeeBodyTermination$outboundSchema), email: z.string().optional(), job: z.lazy(() => HistoricalEmployeeBodyJob$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 historicalEmployeeBodyToJSON( historicalEmployeeBody: HistoricalEmployeeBody, ): string { return JSON.stringify( HistoricalEmployeeBody$outboundSchema.parse(historicalEmployeeBody), ); }