import {z} from 'zod' export type GetApiV1PayrollsPayrollUuidReceiptArgs = {'X-Gusto-API-Version'?: '2026-06-15' | undefined, payroll_uuid: string, page?: number | undefined, per?: number | undefined}; export type GetApiV1PayrollsPayrollUuidReceiptOptions = {baseUrl?: string | undefined, CompanyAccessAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const payrollReceipt = z.object({payroll_uuid: z.string().optional(), company_uuid: z.string().optional(), name_of_sender: z.string().optional(), name_of_recipient: z.string().optional(), recipient_notice: z.string().optional(), debit_date: z.string().optional(), license: z.string().optional(), license_uri: z.string().optional(), right_to_refund: z.string().optional(), liability_of_licensee: z.string().optional(), totals: z.object({company_debit: z.string().optional(), net_pay_debit: z.string().optional(), child_support_debit: z.string().optional(), reimbursement_debit: z.string().optional(), tax_debit: z.string().optional()}).optional(), taxes: z.array(z.object({name: z.string().optional(), amount: z.string().optional()})).optional(), employee_compensations: z.array(z.object({employee_uuid: z.string().optional(), employee_first_name: z.string().optional(), employee_last_name: z.string().optional(), payment_method: z.enum(["Direct Deposit", "Check"]).optional(), net_pay: z.string().optional(), total_tax: z.string().optional(), total_garnishments: z.string().optional(), child_support_garnishment: z.string().optional(), total_reimbursement: z.string().optional()})).optional(), licensee: z.object({name: z.string().optional(), address: z.string().optional(), city: z.string().optional(), state: z.string().optional(), postal_code: z.string().optional(), phone_number: z.string().optional()}).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 }; /** * Get a single payroll receipt * * GET /v1/payrolls/{payroll_uuid}/receipt */ export const getApiV1PayrollsPayrollUuidReceipt = async (args: GetApiV1PayrollsPayrollUuidReceiptArgs, options?: GetApiV1PayrollsPayrollUuidReceiptOptions) => { const {baseUrl = "https://api.gusto-demo.com", fetch: fetchFn = fetch, CompanyAccessAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() 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 (args.page != null) query.append("page", String(args.page)) if (args.per != null) query.append("per", String(args.per)) if (CompanyAccessAuth !== undefined) headers.set('authorization', `Bearer ${CompanyAccessAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/payrolls/${encodeURIComponent(String(args.payroll_uuid))}/receipt${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(payrollReceipt, await res.json()) };