/* * 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 PostV1EmployeesHeaderXGustoAPIVersion = { 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 PostV1EmployeesHeaderXGustoAPIVersion = ClosedEnum< typeof PostV1EmployeesHeaderXGustoAPIVersion >; export type PostV1EmployeesRequestBody = { firstName: string; middleInitial?: string | undefined; lastName: string; /** * The employee's personal email address. Required if self_onboarding is true. */ email?: string | null | undefined; /** * The employee's work email address. */ workEmail?: string | undefined; dateOfBirth?: RFCDate | undefined; ssn?: string | undefined; preferredFirstName?: string | undefined; /** * If true, employee is expected to self-onboard. If false, payroll admin is expected to enter in the employee's onboarding information */ selfOnboarding?: boolean | undefined; }; export type PostV1EmployeesRequest = { /** * 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?: PostV1EmployeesHeaderXGustoAPIVersion | undefined; /** * Company ID */ companyId: string; requestBody?: PostV1EmployeesRequestBody | undefined; }; export type PostV1EmployeesResponse = { httpMeta: HTTPMetadata; /** * successful */ employee?: Employee | undefined; }; /** @internal */ export const PostV1EmployeesHeaderXGustoAPIVersion$outboundSchema: z.ZodNativeEnum = z.nativeEnum( PostV1EmployeesHeaderXGustoAPIVersion, ); /** @internal */ export type PostV1EmployeesRequestBody$Outbound = { first_name: string; middle_initial?: string | undefined; last_name: string; email?: string | null | undefined; work_email?: string | undefined; date_of_birth?: string | undefined; ssn?: string | undefined; preferred_first_name?: string | undefined; self_onboarding?: boolean | undefined; }; /** @internal */ export const PostV1EmployeesRequestBody$outboundSchema: z.ZodType< PostV1EmployeesRequestBody$Outbound, z.ZodTypeDef, PostV1EmployeesRequestBody > = z.object({ firstName: z.string(), middleInitial: z.string().optional(), lastName: z.string(), email: z.nullable(z.string()).optional(), workEmail: z.string().optional(), dateOfBirth: z.instanceof(RFCDate).transform(v => v.toString()).optional(), ssn: z.string().optional(), preferredFirstName: z.string().optional(), selfOnboarding: z.boolean().optional(), }).transform((v) => { return remap$(v, { firstName: "first_name", middleInitial: "middle_initial", lastName: "last_name", workEmail: "work_email", dateOfBirth: "date_of_birth", preferredFirstName: "preferred_first_name", selfOnboarding: "self_onboarding", }); }); export function postV1EmployeesRequestBodyToJSON( postV1EmployeesRequestBody: PostV1EmployeesRequestBody, ): string { return JSON.stringify( PostV1EmployeesRequestBody$outboundSchema.parse(postV1EmployeesRequestBody), ); } /** @internal */ export type PostV1EmployeesRequest$Outbound = { "X-Gusto-API-Version": string; company_id: string; RequestBody?: PostV1EmployeesRequestBody$Outbound | undefined; }; /** @internal */ export const PostV1EmployeesRequest$outboundSchema: z.ZodType< PostV1EmployeesRequest$Outbound, z.ZodTypeDef, PostV1EmployeesRequest > = z.object({ xGustoAPIVersion: PostV1EmployeesHeaderXGustoAPIVersion$outboundSchema .default("2025-06-15"), companyId: z.string(), requestBody: z.lazy(() => PostV1EmployeesRequestBody$outboundSchema) .optional(), }).transform((v) => { return remap$(v, { xGustoAPIVersion: "X-Gusto-API-Version", companyId: "company_id", requestBody: "RequestBody", }); }); export function postV1EmployeesRequestToJSON( postV1EmployeesRequest: PostV1EmployeesRequest, ): string { return JSON.stringify( PostV1EmployeesRequest$outboundSchema.parse(postV1EmployeesRequest), ); } /** @internal */ export const PostV1EmployeesResponse$inboundSchema: z.ZodType< PostV1EmployeesResponse, z.ZodTypeDef, unknown > = z.object({ HttpMeta: HTTPMetadata$inboundSchema, Employee: Employee$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "HttpMeta": "httpMeta", "Employee": "employee", }); }); export function postV1EmployeesResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PostV1EmployeesResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PostV1EmployeesResponse' from JSON`, ); }