import {z} from 'zod' export type CreateApiQuickbooksDesktopEmployeesIdArgs = {'Conductor-End-User-Id': string, id: string, body: {revisionNumber: string, isActive?: boolean | undefined, salutation?: string | undefined, firstName?: string | undefined, middleName?: string | undefined, lastName?: string | undefined, jobTitle?: string | undefined, supervisorId?: string | undefined, department?: string | undefined, description?: string | undefined, targetBonus?: string | undefined, address?: ({line1?: string | undefined, line2?: string | undefined, line3?: string | undefined, line4?: string | undefined, city?: string | undefined, state?: ('none' | 'armed_forces_americas' | 'armed_forces_europe' | 'armed_forces_pacific' | 'AB' | 'AK' | 'AL' | 'AR' | 'AZ' | 'BC' | 'CA' | 'CO' | 'CT' | 'DC' | 'DE' | 'FL' | 'GA' | 'HI' | 'IA' | 'ID' | 'IL' | 'IN' | 'KS' | 'KY' | 'LA' | 'MA' | 'MB' | 'MD' | 'ME' | 'MI' | 'MN' | 'MO' | 'MS' | 'MT' | 'NB' | 'NC' | 'ND' | 'NE' | 'NH' | 'NJ' | 'NL' | 'NM' | 'NS' | 'NT' | 'NU' | 'NV' | 'NY' | 'OH' | 'OK' | 'ON' | 'OR' | 'PA' | 'PE' | 'PR' | 'QC' | 'RI' | 'SC' | 'SD' | 'SK' | 'TN' | 'TX' | 'UT' | 'VA' | 'VT' | 'WA' | 'WI' | 'WV' | 'WY' | 'YT') | undefined, postalCode?: string | undefined, country?: string | undefined}) | undefined, printAs?: string | undefined, phone?: string | undefined, mobile?: string | undefined, pager?: string | undefined, pagerPin?: string | undefined, alternatePhone?: string | undefined, fax?: string | undefined, email?: string | undefined, customContactFields?: Array<{name: string, value: string}> | undefined, emergencyContact?: ({primaryContact?: ({name: string, value: string, relation?: ('brother' | 'daughter' | 'father' | 'friend' | 'mother' | 'other' | 'partner' | 'sister' | 'son' | 'spouse') | undefined}) | undefined, secondaryContact?: ({name: string, value: string, relation?: ('brother' | 'daughter' | 'father' | 'friend' | 'mother' | 'other' | 'partner' | 'sister' | 'son' | 'spouse') | undefined}) | undefined}) | undefined, employeeType?: ('officer' | 'owner' | 'regular' | 'statutory') | undefined, employmentStatus?: ('full_time' | 'part_time') | undefined, overtimeExemptStatus?: ('exempt' | 'non_exempt') | undefined, keyEmployeeStatus?: ('key_employee' | 'non_key_employee') | undefined, hiredDate?: string | undefined, originalHireDate?: string | undefined, adjustedServiceDate?: string | undefined, terminationDate?: string | undefined, birthDate?: string | undefined, usCitizenshipStatus?: ('citizen' | 'non_citizen') | undefined, ethnicity?: ('american_indian' | 'asian' | 'black' | 'hawaiian' | 'hispanic' | 'white' | 'two_or_more_races') | undefined, disabilityStatus?: ('disabled' | 'non_disabled') | undefined, disabilityDescription?: string | undefined, i9OnFileStatus?: ('on_file' | 'not_on_file') | undefined, workAuthorizationExpirationDate?: string | undefined, usVeteranStatus?: ('veteran' | 'non_veteran') | undefined, militaryStatus?: ('active' | 'reserve') | undefined, accountNumber?: string | undefined, note?: string | undefined, additionalNotes?: Array<{id: number, note: string}> | undefined, billingRateId?: string | undefined, employeePayroll?: ({payPeriod?: ('biweekly' | 'daily' | 'monthly' | 'quarterly' | 'semimonthly' | 'weekly' | 'yearly') | undefined, classId?: string | undefined, deleteAllEarnings?: boolean | undefined, earnings?: (Array<{payrollWageItemId: string, rate?: string | undefined, ratePercent?: string | undefined}>) | undefined, useTimeDataToCreatePaychecks?: ('does_not_use_time_data' | 'not_set' | 'uses_time_data') | undefined, sickHours?: ({hoursAvailable?: string | undefined, accrualPeriod?: ('accrues_annually' | 'accrues_hourly' | 'accrues_per_paycheck') | undefined, hoursAccruedPerPeriod?: string | undefined, maximumHours?: string | undefined, resetsHoursEachYear?: boolean | undefined, hoursUsed?: string | undefined, accrualStartDate?: string | undefined}) | undefined, vacationHours?: ({hoursAvailable?: string | undefined, accrualPeriod?: ('accrues_annually' | 'accrues_hourly' | 'accrues_per_paycheck') | undefined, hoursAccruedPerPeriod?: string | undefined, maximumHours?: string | undefined, resetsHoursEachYear?: boolean | undefined, hoursUsed?: string | undefined, accrualStartDate?: string | undefined}) | undefined}) | undefined}}; export type CreateApiQuickbooksDesktopEmployeesIdOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const qbdEmployeeAddress = z.object({line1: z.string().nullable(), line2: z.string().nullable(), line3: z.string().nullable(), line4: z.string().nullable(), city: z.string().nullable(), state: z.string().nullable(), postalCode: z.string().nullable(), country: z.string().nullable()}); export const qbdCustomContactField = z.object({name: z.string(), value: z.string().nullable()}); export const qbdEmergencyContact = z.object({name: z.string(), value: z.string().nullable(), relation: z.enum(["brother", "daughter", "father", "friend", "mother", "other", "partner", "sister", "son", "spouse"]).nullable()}); export const qbdEmergencyContactSet = z.object({primaryContact: qbdEmergencyContact.nullable(), secondaryContact: qbdEmergencyContact.nullable()}); export const qbdNote = z.object({id: z.number(), date: z.string().nullable(), note: z.string()}); export const qbdEarnings = z.object({payrollWageItem: z.object({id: z.string().nullable(), fullName: z.string().nullable()}), rate: z.string().nullable(), ratePercent: z.string().nullable()}); export const qbdSickHours = z.object({hoursAvailable: z.string().nullable(), accrualPeriod: z.enum(["accrues_annually", "accrues_hourly", "accrues_per_paycheck"]).nullable(), hoursAccruedPerPeriod: z.string().nullable(), maximumHours: z.string().nullable(), resetsHoursEachYear: z.boolean().nullable(), hoursUsed: z.string().nullable(), accrualStartDate: z.string().nullable()}); export const qbdVacationHours = z.object({hoursAvailable: z.string().nullable(), accrualPeriod: z.enum(["accrues_annually", "accrues_hourly", "accrues_per_paycheck"]).nullable(), hoursAccruedPerPeriod: z.string().nullable(), maximumHours: z.string().nullable(), resetsHoursEachYear: z.boolean().nullable(), hoursUsed: z.string().nullable(), accrualStartDate: z.string().nullable()}); export const qbdEmployeePayrollInfo = z.object({payPeriod: z.enum(["biweekly", "daily", "monthly", "quarterly", "semimonthly", "weekly", "yearly"]).nullable(), class: z.object({id: z.string().nullable(), fullName: z.string().nullable()}).nullable(), earnings: z.array(qbdEarnings), useTimeDataToCreatePaychecks: z.enum(["does_not_use_time_data", "not_set", "uses_time_data"]).nullable(), sickHours: qbdSickHours.nullable(), vacationHours: qbdVacationHours.nullable()}); export const qbdCustomField = z.object({ownerId: z.string(), name: z.string(), type: z.enum(["amount_type", "date_time_type", "integer_type", "percent_type", "price_type", "quantity_type", "string_1024_type", "string_255_type"]), value: z.string()}); export const qbdEmployee = z.object({id: z.string(), objectType: z.literal("qbd_employee"), createdAt: z.string(), updatedAt: z.string(), revisionNumber: z.string(), name: z.string(), isActive: z.boolean(), salutation: z.string().nullable(), firstName: z.string().nullable(), middleName: z.string().nullable(), lastName: z.string().nullable(), jobTitle: z.string().nullable(), supervisor: z.object({id: z.string().nullable(), fullName: z.string().nullable()}).nullable(), department: z.string().nullable(), description: z.string().nullable(), targetBonus: z.string().nullable(), address: qbdEmployeeAddress.nullable(), printAs: z.string().nullable(), phone: z.string().nullable(), mobile: z.string().nullable(), pager: z.string().nullable(), pagerPin: z.string().nullable(), alternatePhone: z.string().nullable(), fax: z.string().nullable(), ssn: z.string().nullable(), email: z.string().nullable(), customContactFields: z.array(qbdCustomContactField), emergencyContact: qbdEmergencyContactSet.nullable(), employeeType: z.enum(["officer", "owner", "regular", "statutory"]).nullable(), employmentStatus: z.enum(["full_time", "part_time"]).nullable(), overtimeExemptStatus: z.enum(["exempt", "non_exempt"]).nullable(), keyEmployeeStatus: z.enum(["key_employee", "non_key_employee"]).nullable(), gender: z.enum(["male", "female"]).nullable(), hiredDate: z.string().nullable(), originalHireDate: z.string().nullable(), adjustedServiceDate: z.string().nullable(), terminationDate: z.string().nullable(), birthDate: z.string().nullable(), usCitizenshipStatus: z.enum(["citizen", "non_citizen"]).nullable(), ethnicity: z.enum(["american_indian", "asian", "black", "hawaiian", "hispanic", "white", "two_or_more_races"]).nullable(), disabilityStatus: z.enum(["disabled", "non_disabled"]).nullable(), disabilityDescription: z.string().nullable(), i9OnFileStatus: z.enum(["on_file", "not_on_file"]).nullable(), workAuthorizationExpirationDate: z.string().nullable(), usVeteranStatus: z.enum(["veteran", "non_veteran"]).nullable(), militaryStatus: z.enum(["active", "reserve"]).nullable(), accountNumber: z.string().nullable(), note: z.string().nullable(), additionalNotes: z.array(qbdNote), billingRate: z.object({id: z.string().nullable(), fullName: z.string().nullable()}).nullable(), employeePayroll: qbdEmployeePayrollInfo.nullable(), externalId: z.string().nullable(), customFields: z.array(qbdCustomField)}); 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 * * POST /quickbooks-desktop/employees/{id} */ export const createApiQuickbooksDesktopEmployeesId = async (args: CreateApiQuickbooksDesktopEmployeesIdArgs, options?: CreateApiQuickbooksDesktopEmployeesIdOptions) => { const {baseUrl = "https://api.conductor.is/v1", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['Conductor-End-User-Id'] != null) headers.set("Conductor-End-User-Id", String(args['Conductor-End-User-Id'])) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/quickbooks-desktop/employees/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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(qbdEmployee, await res.json()) };