import {z} from 'zod' export type PatchApiPayrollsPayrollCOPYArgs = {payroll: string, body: {period_start?: string | undefined, period_end?: string | undefined, payday?: string | undefined, processing_period?: string | undefined, type?: string | undefined, pay_frequency?: string | undefined, funding_payment_method?: string | undefined, pay_schedule?: string | undefined, off_cycle_options?: ({force_supplemental_withholding?: boolean | undefined, apply_benefits?: boolean | undefined, apply_post_tax_deductions?: boolean | undefined}) | undefined, items?: (Array<{employee: string, payment_method?: string | undefined, earnings?: (Array<{type?: string | undefined, workplace: string, earning_code?: string | undefined, description?: string | undefined, earning_rate?: string | undefined, amount?: string | undefined, hours?: number | undefined, piece_units?: number | undefined, metadata?: unknown | undefined}>) | undefined, reimbursements?: (Array<{amount: string, description?: string | undefined, code?: string | undefined, metadata?: unknown | undefined}>) | undefined, benefit_overrides?: (Array<{benefit: string, employee_contribution_amount?: string | undefined, company_contribution_amount?: string | undefined}>) | undefined, post_tax_deduction_overrides?: Array<{post_tax_deduction: string, amount: string}> | undefined, tax_overrides?: Array<{tax: string, amount: string}> | undefined, pto_balance_hours?: number | undefined, sick_balance_hours?: number | undefined, state_covid_sick_balance_hours?: number | undefined, supplemental_tax_calc_method?: string | undefined, paper_check_number?: string | undefined, metadata?: unknown | undefined}>) | undefined, contractor_payments?: (Array<{contractor: string, payment_method?: string | undefined, amount?: string | undefined, reimbursement_amount?: string | undefined, paper_check_number?: string | undefined, workplace?: string | undefined}>) | undefined, metadata?: unknown | undefined}}; export type PatchApiPayrollsPayrollCOPYOptions = {baseUrl?: string | undefined, sec0?: string | undefined, fetch?: typeof fetch | undefined}; export const patchApiPayrollsPayrollCOPYResponse = z.object({}); 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 payroll * * PATCH /payrolls/{payroll} (COPY) */ export const patchApiPayrollsPayrollCOPY = async (args: PatchApiPayrollsPayrollCOPYArgs, options?: PatchApiPayrollsPayrollCOPYOptions) => { const {baseUrl = "https://sandbox.checkhq.com", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (sec0 !== undefined) headers.set("Authorization", sec0) const url = `${baseUrl.replace(/\/+$/, '')}/payrolls/${encodeURIComponent(String(args.payroll))} (COPY)${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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(patchApiPayrollsPayrollCOPYResponse, await res.json()) };