/* * 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 { GetV1EmployeesEmployeeIdGarnishmentsHeaderXGustoAPIVersion, GetV1EmployeesEmployeeIdGarnishmentsRequest, } from "../models/operations/getv1employeesemployeeidgarnishments.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes, } from "./_types.js"; import { buildGarnishmentsListQuery, GarnishmentsListQueryData, prefetchGarnishmentsList, queryKeyGarnishmentsList, } from "./garnishmentsList.core.js"; export { buildGarnishmentsListQuery, type GarnishmentsListQueryData, prefetchGarnishmentsList, queryKeyGarnishmentsList, }; export type GarnishmentsListQueryError = | NotFoundErrorObject | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Get garnishments for an employee * * @remarks * Garnishments, or employee deductions, are fixed amounts or percentages deducted from an employee’s pay. They can be deducted a specific number of times or on a recurring basis. Garnishments can also have maximum deductions on a yearly or per-pay-period bases. Common uses for garnishments are court-ordered payments for child support or back taxes. Some companies provide loans to their employees that are repaid via garnishments. * * scope: `garnishments:read` */ export function useGarnishmentsList( request: GetV1EmployeesEmployeeIdGarnishmentsRequest, options?: QueryHookOptions< GarnishmentsListQueryData, GarnishmentsListQueryError >, ): UseQueryResult { const client = useGustoEmbeddedContext(); return useQuery({ ...buildGarnishmentsListQuery( client, request, options, ), ...options, }); } /** * Get garnishments for an employee * * @remarks * Garnishments, or employee deductions, are fixed amounts or percentages deducted from an employee’s pay. They can be deducted a specific number of times or on a recurring basis. Garnishments can also have maximum deductions on a yearly or per-pay-period bases. Common uses for garnishments are court-ordered payments for child support or back taxes. Some companies provide loans to their employees that are repaid via garnishments. * * scope: `garnishments:read` */ export function useGarnishmentsListSuspense( request: GetV1EmployeesEmployeeIdGarnishmentsRequest, options?: SuspenseQueryHookOptions< GarnishmentsListQueryData, GarnishmentsListQueryError >, ): UseSuspenseQueryResult< GarnishmentsListQueryData, GarnishmentsListQueryError > { const client = useGustoEmbeddedContext(); return useSuspenseQuery({ ...buildGarnishmentsListQuery( client, request, options, ), ...options, }); } export function setGarnishmentsListData( client: QueryClient, queryKeyBase: [ employeeId: string, parameters: { xGustoAPIVersion?: | GetV1EmployeesEmployeeIdGarnishmentsHeaderXGustoAPIVersion | undefined; page?: number | undefined; per?: number | undefined; }, ], data: GarnishmentsListQueryData, ): GarnishmentsListQueryData | undefined { const key = queryKeyGarnishmentsList(...queryKeyBase); return client.setQueryData(key, data); } export function invalidateGarnishmentsList( client: QueryClient, queryKeyBase: TupleToPrefixes< [ employeeId: string, parameters: { xGustoAPIVersion?: | GetV1EmployeesEmployeeIdGarnishmentsHeaderXGustoAPIVersion | undefined; page?: number | undefined; per?: number | undefined; }, ] >, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "Garnishments", "list", ...queryKeyBase], }); } export function invalidateAllGarnishmentsList( client: QueryClient, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "Garnishments", "list"], }); }