import {z} from 'zod' export type PayScheduleFrequencyCreateUpdate = 'Every week' | 'Every other week' | 'Twice per month' | 'Monthly'; export type PayScheduleDateInput = string; export type PayScheduleWorkweekStartDayCreateUpdate = 'Sunday' | 'Monday' | 'Tuesday' | 'Wednesday' | 'Thursday' | 'Friday' | 'Saturday'; export type PayScheduleUpdateRequest = {version: string, auto_payroll?: boolean | undefined, frequency?: PayScheduleFrequencyCreateUpdate | undefined, anchor_pay_date?: PayScheduleDateInput | undefined, anchor_end_of_pay_period?: PayScheduleDateInput | undefined, day_1?: (number | null) | undefined, day_2?: (number | null) | undefined, first_pay_period_pay_day?: (number | null) | undefined, second_pay_period_pay_day?: (number | null) | undefined, first_pay_period_end_day?: (number | null) | undefined, second_pay_period_end_day?: (number | null) | undefined, custom_name?: (string | null) | undefined, workweek_start_day?: PayScheduleWorkweekStartDayCreateUpdate | undefined}; export type UpdateApiV1CompaniesCompanyIdPaySchedulesPayScheduleIdArgs = {'X-Gusto-API-Version'?: '2026-06-15' | undefined, company_id: string, pay_schedule_id: string, body: PayScheduleUpdateRequest}; export type UpdateApiV1CompaniesCompanyIdPaySchedulesPayScheduleIdOptions = {baseUrl?: string | undefined, CompanyAccessAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const payScheduleUuid = z.string(); export const payScheduleVersion = z.string(); export const payScheduleFrequency = z.enum(["Every week", "Every other week", "Twice per month", "Monthly", "Quarterly", "Annually"]); export const payScheduleAnchorPayDate = z.string(); export const payScheduleAnchorEndOfPayPeriod = z.string(); export const payScheduleDay1 = z.number().int().nullable(); export const payScheduleDay2 = z.number().int().nullable(); export const payScheduleFirstPayPeriodPayDay = z.number().int().nullable(); export const payScheduleSecondPayPeriodPayDay = z.number().int().nullable(); export const payScheduleFirstPayPeriodEndDay = z.number().int().nullable(); export const payScheduleSecondPayPeriodEndDay = z.number().int().nullable(); export const payScheduleName = z.string().nullable(); export const payScheduleCustomName = z.string(); export const payScheduleAutoPayroll = z.boolean(); export const payScheduleActive = z.boolean(); export const payScheduleAutoPayrollEnablementBlocker = z.object({key: z.string().optional(), metadata: z.object({}).optional()}); export const payScheduleAutoPayrollEnablementBlockers = z.array(payScheduleAutoPayrollEnablementBlocker).nullable(); export const payScheduleWorkweekStartDay = z.enum(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]).nullable(); export const payScheduleShow = z.object({uuid: payScheduleUuid, version: payScheduleVersion, frequency: payScheduleFrequency.optional(), anchor_pay_date: payScheduleAnchorPayDate.optional(), anchor_end_of_pay_period: payScheduleAnchorEndOfPayPeriod.optional(), day_1: payScheduleDay1.optional(), day_2: payScheduleDay2.optional(), first_pay_period_pay_day: payScheduleFirstPayPeriodPayDay.optional(), second_pay_period_pay_day: payScheduleSecondPayPeriodPayDay.optional(), first_pay_period_end_day: payScheduleFirstPayPeriodEndDay.optional(), second_pay_period_end_day: payScheduleSecondPayPeriodEndDay.optional(), name: payScheduleName.optional(), custom_name: payScheduleCustomName.optional(), auto_payroll: payScheduleAutoPayroll.optional(), active: payScheduleActive.optional(), auto_payroll_enablement_blockers: payScheduleAutoPayrollEnablementBlockers.optional(), workweek_start_day: payScheduleWorkweekStartDay.optional()}); 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 a pay schedule * * PUT /v1/companies/{company_id}/pay_schedules/{pay_schedule_id} */ export const updateApiV1CompaniesCompanyIdPaySchedulesPayScheduleId = async (args: UpdateApiV1CompaniesCompanyIdPaySchedulesPayScheduleIdArgs, options?: UpdateApiV1CompaniesCompanyIdPaySchedulesPayScheduleIdOptions) => { const {baseUrl = "https://api.gusto-demo.com", fetch: fetchFn = fetch, CompanyAccessAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['X-Gusto-API-Version'] != null) headers.set("X-Gusto-API-Version", String(args['X-Gusto-API-Version'])) if (CompanyAccessAuth !== undefined) headers.set('authorization', `Bearer ${CompanyAccessAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/companies/${encodeURIComponent(String(args.company_id))}/pay_schedules/${encodeURIComponent(String(args.pay_schedule_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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(payScheduleShow, await res.json()) };