import {z} from 'zod' export type GetApiV1NotificationsNotificationUuidArgs = {'X-Gusto-API-Version'?: '2026-06-15' | undefined, notification_uuid: string}; export type GetApiV1NotificationsNotificationUuidOptions = {baseUrl?: string | undefined, CompanyAccessAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const notification = z.object({uuid: z.string(), company_uuid: z.string(), title: z.string(), message: z.string(), status: z.enum(["open", "resolved", "expired"]), category: z.string(), actionable: z.boolean(), can_block_payroll: z.boolean(), published_at: z.string(), due_at: z.string().nullable(), template_variables: z.record(z.string(), z.string()).optional(), resources: z.array(z.object({entity_type: z.enum(["BankAccount", "Contractor", "ContractorPayment", "Employee", "Payroll", "PaySchedule", "RecoveryCase", "Signatory", "Wire In Request"]), entity_uuid: z.string(), reference_type: z.string().optional(), reference_uuid: z.string().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 notification's details * * GET /v1/notifications/{notification_uuid} */ export const getApiV1NotificationsNotificationUuid = async (args: GetApiV1NotificationsNotificationUuidArgs, options?: GetApiV1NotificationsNotificationUuidOptions) => { 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 (CompanyAccessAuth !== undefined) headers.set('authorization', `Bearer ${CompanyAccessAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/notifications/${encodeURIComponent(String(args.notification_uuid))}${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(notification, await res.json()) };