/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { InvalidateQueryFilters, QueryClient, useQuery, UseQueryResult, useSuspenseQuery, UseSuspenseQueryResult, } from "@tanstack/react-query"; import { GustoEmbeddedError } from "../models/errors/gustoembeddederror.js"; import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; import { NotFoundErrorObject } from "../models/errors/notfounderrorobject.js"; import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import { GetV1PayrollBatchesPayrollBatchUuidHeaderXGustoAPIVersion, GetV1PayrollBatchesPayrollBatchUuidRequest, GetV1PayrollBatchesPayrollBatchUuidSecurity, } from "../models/operations/getv1payrollbatchespayrollbatchuuid.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes, } from "./_types.js"; import { buildPayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQuery, PayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQueryData, prefetchPayrollCancellationsGetV1PayrollBatchesPayrollBatchUuid, queryKeyPayrollCancellationsGetV1PayrollBatchesPayrollBatchUuid, } from "./payrollCancellationsGetV1PayrollBatchesPayrollBatchUuid.core.js"; export { buildPayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQuery, type PayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQueryData, prefetchPayrollCancellationsGetV1PayrollBatchesPayrollBatchUuid, queryKeyPayrollCancellationsGetV1PayrollBatchesPayrollBatchUuid, }; export type PayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQueryError = | NotFoundErrorObject | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Get a payroll cancellation batch * * @remarks * Returns the status and per-payroll results of a payroll cancellation batch. * * Poll this endpoint until the batch `status` reaches a terminal value (`completed` or `failed`). Once terminal, the response includes the `results` array (one entry per authorized payroll, each with its own per-payroll `status` — `success` or `failed`) and the `exclusions` array (one entry per payroll that could not be processed). A cancel is atomic, so a per-payroll result is only ever `success` or `failed` — never `partial_success`. * * Note that the top-level batch `status` (`pending` / `processing` / `completed` / `failed`) is the request lifecycle, distinct from the per-payroll `status` inside `results[]`. A `completed` batch does not imply every payroll was cancelled — inspect the array for per-payroll outcomes. * * Results are stored in Redis with a limited TTL after completion. If the partner polls after results have expired, this endpoint returns 410 Gone — partners should re-submit a new batch. * * 📘 System Access Authentication * * This endpoint uses the [Bearer Auth scheme with the system-level access token in the HTTP Authorization header](https://docs.gusto.com/embedded-payroll/docs/system-access) * * scope: `payroll_batches:read` */ export function usePayrollCancellationsGetV1PayrollBatchesPayrollBatchUuid( security: GetV1PayrollBatchesPayrollBatchUuidSecurity, request: GetV1PayrollBatchesPayrollBatchUuidRequest, options?: QueryHookOptions< PayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQueryData, PayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQueryError >, ): UseQueryResult< PayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQueryData, PayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQueryError > { const client = useGustoEmbeddedContext(); return useQuery({ ...buildPayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQuery( client, security, request, options, ), ...options, }); } /** * Get a payroll cancellation batch * * @remarks * Returns the status and per-payroll results of a payroll cancellation batch. * * Poll this endpoint until the batch `status` reaches a terminal value (`completed` or `failed`). Once terminal, the response includes the `results` array (one entry per authorized payroll, each with its own per-payroll `status` — `success` or `failed`) and the `exclusions` array (one entry per payroll that could not be processed). A cancel is atomic, so a per-payroll result is only ever `success` or `failed` — never `partial_success`. * * Note that the top-level batch `status` (`pending` / `processing` / `completed` / `failed`) is the request lifecycle, distinct from the per-payroll `status` inside `results[]`. A `completed` batch does not imply every payroll was cancelled — inspect the array for per-payroll outcomes. * * Results are stored in Redis with a limited TTL after completion. If the partner polls after results have expired, this endpoint returns 410 Gone — partners should re-submit a new batch. * * 📘 System Access Authentication * * This endpoint uses the [Bearer Auth scheme with the system-level access token in the HTTP Authorization header](https://docs.gusto.com/embedded-payroll/docs/system-access) * * scope: `payroll_batches:read` */ export function usePayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidSuspense( security: GetV1PayrollBatchesPayrollBatchUuidSecurity, request: GetV1PayrollBatchesPayrollBatchUuidRequest, options?: SuspenseQueryHookOptions< PayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQueryData, PayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQueryError >, ): UseSuspenseQueryResult< PayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQueryData, PayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQueryError > { const client = useGustoEmbeddedContext(); return useSuspenseQuery({ ...buildPayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQuery( client, security, request, options, ), ...options, }); } export function setPayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidData( client: QueryClient, queryKeyBase: [ payrollBatchUuid: string, parameters: { xGustoAPIVersion?: | GetV1PayrollBatchesPayrollBatchUuidHeaderXGustoAPIVersion | undefined; }, ], data: PayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQueryData, ): | PayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQueryData | undefined { const key = queryKeyPayrollCancellationsGetV1PayrollBatchesPayrollBatchUuid( ...queryKeyBase, ); return client.setQueryData< PayrollCancellationsGetV1PayrollBatchesPayrollBatchUuidQueryData >(key, data); } export function invalidatePayrollCancellationsGetV1PayrollBatchesPayrollBatchUuid( client: QueryClient, queryKeyBase: TupleToPrefixes< [ payrollBatchUuid: string, parameters: { xGustoAPIVersion?: | GetV1PayrollBatchesPayrollBatchUuidHeaderXGustoAPIVersion | undefined; }, ] >, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: [ "@gusto/embedded-api", "Payroll Cancellations", "getV1PayrollBatchesPayrollBatchUuid", ...queryKeyBase, ], }); } export function invalidateAllPayrollCancellationsGetV1PayrollBatchesPayrollBatchUuid( client: QueryClient, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: [ "@gusto/embedded-api", "Payroll Cancellations", "getV1PayrollBatchesPayrollBatchUuid", ], }); }