/* * 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"; /** * The contractor's wage type, either "Fixed" or "Hourly". */ export const WageType = { Fixed: "Fixed", Hourly: "Hourly", } as const; /** * The contractor's wage type, either "Fixed" or "Hourly". */ export type WageType = ClosedEnum; /** * The contractor's type, either "Individual" or "Business". */ export const ContractorType = { Individual: "Individual", Business: "Business", } as const; /** * The contractor's type, either "Individual" or "Business". */ export type ContractorType = ClosedEnum; /** * The contractor’s home address. */ export type Address = { street1?: string | undefined; street2?: string | null | undefined; city?: string | undefined; state?: string | undefined; zip?: string | undefined; country?: string | undefined; }; /** * One of the "onboarding_status" enum values. */ export const ContractorOnboardingStatus1 = { AdminOnboardingIncomplete: "admin_onboarding_incomplete", AdminOnboardingReview: "admin_onboarding_review", SelfOnboardingNotInvited: "self_onboarding_not_invited", SelfOnboardingInvited: "self_onboarding_invited", SelfOnboardingStarted: "self_onboarding_started", SelfOnboardingReview: "self_onboarding_review", OnboardingCompleted: "onboarding_completed", } as const; /** * One of the "onboarding_status" enum values. */ export type ContractorOnboardingStatus1 = ClosedEnum< typeof ContractorOnboardingStatus1 >; export const ContractorPaymentMethod1 = { DirectDeposit: "Direct Deposit", Check: "Check", } as const; export type ContractorPaymentMethod1 = ClosedEnum< typeof ContractorPaymentMethod1 >; /** * The contractor's upcoming employment details, if a rehire is scheduled. */ export type UpcomingEmployment = { /** * The start date of the upcoming employment. */ startDate?: string | undefined; /** * The setup status of the upcoming employment. */ setupStatus?: string | null | undefined; }; /** * The current status of the member portal invitation. */ export const ContractorStatus = { Pending: "pending", Sent: "sent", Verified: "verified", Complete: "complete", Cancelled: "cancelled", } as const; /** * The current status of the member portal invitation. */ export type ContractorStatus = ClosedEnum; /** * Member portal invitation status information. Only included when the include param has the portal_invitations value set. */ export type ContractorMemberPortalInvitationStatus = { /** * The current status of the member portal invitation. */ status?: ContractorStatus | undefined; /** * Whether the invitation token has expired. */ tokenExpired?: boolean | null | undefined; /** * The date and time when the welcome email was sent. */ welcomeEmailSentAt?: Date | null | undefined; /** * The date and time when the password reset was last resent. */ lastPasswordResentAt?: Date | null | undefined; }; /** * The representation of a contractor (individual or business) in Gusto. */ export type Contractor = { /** * The UUID of the contractor in Gusto. */ uuid: string; /** * The UUID of the company the contractor is employed by. */ companyUuid?: string | undefined; /** * The contractor's wage type, either "Fixed" or "Hourly". */ wageType?: WageType | undefined; /** * The status of the contractor with the company. */ isActive: boolean; /** * 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 | undefined; /** * The contractor's type, either "Individual" or "Business". */ type?: ContractorType | undefined; /** * The contractor’s first name. This attribute is required for “Individual” contractors and will be ignored for “Business” contractors. */ firstName?: string | null | undefined; /** * The contractor’s last name. This attribute is required for “Individual” contractors and will be ignored for “Business” contractors. */ lastName?: string | null | undefined; /** * The contractor’s middle initial. This attribute is optional for “Individual” contractors and will be ignored for “Business” contractors. */ middleInitial?: string | null | undefined; /** * The name of the contractor business. This attribute is required for “Business” contractors and will be ignored for “Individual” contractors. */ businessName?: string | null | undefined; /** * The Federal Employer Identification Number of the contractor business. This attribute is optional for “Business” contractors and will be ignored for “Individual” contractors. */ ein?: string | null | undefined; /** * Whether company's Employer Identification Number (EIN) is present */ hasEin?: boolean | null | undefined; /** * The contractor’s email address. This attribute is optional for “Individual” contractors and will be ignored for “Business” contractors. */ email?: string | null | undefined; /** * The contractor's start date. */ startDate?: string | undefined; /** * The contractor’s home address. */ address?: Address | null | undefined; /** * The contractor’s hourly rate. This attribute is required if the wage_type is “Hourly”. */ hourlyRate?: string | undefined; /** * The boolean flag indicating whether Gusto will file a new hire report for the contractor */ fileNewHireReport?: boolean | null | undefined; /** * State where the contractor will be conducting the majority of their work for the company. * * @remarks * This value is used when generating the new hire report. */ workState?: string | null | undefined; /** * The updated onboarding status for the contractor */ onboarded?: boolean | undefined; /** * One of the "onboarding_status" enum values. */ onboardingStatus?: ContractorOnboardingStatus1 | undefined; /** * The contractor's payment method. */ paymentMethod?: ContractorPaymentMethod1 | null | undefined; /** * Indicates whether the contractor has an SSN in Gusto. */ hasSsn?: boolean | undefined; /** * The UUID of the department the contractor is under */ departmentUuid?: string | null | undefined; /** * The contractor's department in the company. */ department?: string | null | undefined; /** * The title of the contractor's department. */ departmentTitle?: string | null | undefined; /** * The contractor's dismissal date. */ dismissalDate?: string | null | undefined; /** * The contractor's upcoming employment details, if a rehire is scheduled. */ upcomingEmployment?: UpcomingEmployment | null | undefined; /** * Whether the contractor's pending dismissal can be cancelled. */ dismissalCancellationEligible?: boolean | undefined; /** * Whether the contractor's pending rehire can be cancelled. */ rehireCancellationEligible?: boolean | undefined; /** * Member portal invitation status information. Only included when the include param has the portal_invitations value set. */ memberPortalInvitationStatus?: | ContractorMemberPortalInvitationStatus | null | undefined; /** * Whether an external partner portal invitation webhook has been sent for this contractor. Only included when the include param has the portal_invitations value set. */ partnerPortalInvitationSent?: boolean | null | undefined; }; /** @internal */ export const WageType$inboundSchema: z.ZodNativeEnum = z .nativeEnum(WageType); /** @internal */ export const ContractorType$inboundSchema: z.ZodNativeEnum< typeof ContractorType > = z.nativeEnum(ContractorType); /** @internal */ export const Address$inboundSchema: z.ZodType = z.object({ street_1: z.string().optional(), street_2: z.nullable(z.string()).optional(), city: z.string().optional(), state: z.string().optional(), zip: z.string().optional(), country: z.string().optional(), }).transform((v) => { return remap$(v, { "street_1": "street1", "street_2": "street2", }); }); export function addressFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Address$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Address' from JSON`, ); } /** @internal */ export const ContractorOnboardingStatus1$inboundSchema: z.ZodNativeEnum< typeof ContractorOnboardingStatus1 > = z.nativeEnum(ContractorOnboardingStatus1); /** @internal */ export const ContractorPaymentMethod1$inboundSchema: z.ZodNativeEnum< typeof ContractorPaymentMethod1 > = z.nativeEnum(ContractorPaymentMethod1); /** @internal */ export const UpcomingEmployment$inboundSchema: z.ZodType< UpcomingEmployment, z.ZodTypeDef, unknown > = z.object({ start_date: z.string().optional(), setup_status: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "start_date": "startDate", "setup_status": "setupStatus", }); }); export function upcomingEmploymentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UpcomingEmployment$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UpcomingEmployment' from JSON`, ); } /** @internal */ export const ContractorStatus$inboundSchema: z.ZodNativeEnum< typeof ContractorStatus > = z.nativeEnum(ContractorStatus); /** @internal */ export const ContractorMemberPortalInvitationStatus$inboundSchema: z.ZodType< ContractorMemberPortalInvitationStatus, z.ZodTypeDef, unknown > = z.object({ status: ContractorStatus$inboundSchema.optional(), token_expired: z.nullable(z.boolean()).optional(), welcome_email_sent_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), last_password_resent_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }).transform((v) => { return remap$(v, { "token_expired": "tokenExpired", "welcome_email_sent_at": "welcomeEmailSentAt", "last_password_resent_at": "lastPasswordResentAt", }); }); export function contractorMemberPortalInvitationStatusFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ContractorMemberPortalInvitationStatus$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContractorMemberPortalInvitationStatus' from JSON`, ); } /** @internal */ export const Contractor$inboundSchema: z.ZodType< Contractor, z.ZodTypeDef, unknown > = z.object({ uuid: z.string(), company_uuid: z.string().optional(), wage_type: WageType$inboundSchema.optional(), is_active: z.boolean().default(true), version: z.string().optional(), type: ContractorType$inboundSchema.optional(), first_name: z.nullable(z.string()).optional(), last_name: z.nullable(z.string()).optional(), middle_initial: z.nullable(z.string()).optional(), business_name: z.nullable(z.string()).optional(), ein: z.nullable(z.string()).optional(), has_ein: z.nullable(z.boolean()).optional(), email: z.nullable(z.string()).optional(), start_date: z.string().optional(), address: z.nullable(z.lazy(() => Address$inboundSchema)).optional(), hourly_rate: z.string().optional(), file_new_hire_report: z.nullable(z.boolean()).optional(), work_state: z.nullable(z.string()).optional(), onboarded: z.boolean().optional(), onboarding_status: ContractorOnboardingStatus1$inboundSchema.optional(), payment_method: z.nullable(ContractorPaymentMethod1$inboundSchema).optional(), has_ssn: z.boolean().optional(), department_uuid: z.nullable(z.string()).optional(), department: z.nullable(z.string()).optional(), department_title: z.nullable(z.string()).optional(), dismissal_date: z.nullable(z.string()).optional(), upcoming_employment: z.nullable( z.lazy(() => UpcomingEmployment$inboundSchema), ).optional(), dismissal_cancellation_eligible: z.boolean().optional(), rehire_cancellation_eligible: z.boolean().optional(), member_portal_invitation_status: z.nullable( z.lazy(() => ContractorMemberPortalInvitationStatus$inboundSchema), ).optional(), partner_portal_invitation_sent: z.nullable(z.boolean()).optional(), }).transform((v) => { return remap$(v, { "company_uuid": "companyUuid", "wage_type": "wageType", "is_active": "isActive", "first_name": "firstName", "last_name": "lastName", "middle_initial": "middleInitial", "business_name": "businessName", "has_ein": "hasEin", "start_date": "startDate", "hourly_rate": "hourlyRate", "file_new_hire_report": "fileNewHireReport", "work_state": "workState", "onboarding_status": "onboardingStatus", "payment_method": "paymentMethod", "has_ssn": "hasSsn", "department_uuid": "departmentUuid", "department_title": "departmentTitle", "dismissal_date": "dismissalDate", "upcoming_employment": "upcomingEmployment", "dismissal_cancellation_eligible": "dismissalCancellationEligible", "rehire_cancellation_eligible": "rehireCancellationEligible", "member_portal_invitation_status": "memberPortalInvitationStatus", "partner_portal_invitation_sent": "partnerPortalInvitationSent", }); }); export function contractorFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Contractor$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Contractor' from JSON`, ); }