/* * 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 { GetV1EmployeesEmployeeIdTerminationsHeaderXGustoAPIVersion, GetV1EmployeesEmployeeIdTerminationsRequest, } from "../models/operations/getv1employeesemployeeidterminations.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes, } from "./_types.js"; import { buildEmployeeEmploymentsGetTerminationsQuery, EmployeeEmploymentsGetTerminationsQueryData, prefetchEmployeeEmploymentsGetTerminations, queryKeyEmployeeEmploymentsGetTerminations, } from "./employeeEmploymentsGetTerminations.core.js"; export { buildEmployeeEmploymentsGetTerminationsQuery, type EmployeeEmploymentsGetTerminationsQueryData, prefetchEmployeeEmploymentsGetTerminations, queryKeyEmployeeEmploymentsGetTerminations, }; export type EmployeeEmploymentsGetTerminationsQueryError = | NotFoundErrorObject | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Get terminations for an employee * * @remarks * Terminations are created whenever an employee is scheduled to leave the company. The only things required are an effective date (their last day of work) and whether they should receive their wages in a one-off termination payroll or with the rest of the company. * * Note that some states require employees to receive their final wages within 24 hours (unless they consent otherwise,) in which case running a one-off payroll may be the only option. * * scope: `employments:read` */ export function useEmployeeEmploymentsGetTerminations( request: GetV1EmployeesEmployeeIdTerminationsRequest, options?: QueryHookOptions< EmployeeEmploymentsGetTerminationsQueryData, EmployeeEmploymentsGetTerminationsQueryError >, ): UseQueryResult< EmployeeEmploymentsGetTerminationsQueryData, EmployeeEmploymentsGetTerminationsQueryError > { const client = useGustoEmbeddedContext(); return useQuery({ ...buildEmployeeEmploymentsGetTerminationsQuery( client, request, options, ), ...options, }); } /** * Get terminations for an employee * * @remarks * Terminations are created whenever an employee is scheduled to leave the company. The only things required are an effective date (their last day of work) and whether they should receive their wages in a one-off termination payroll or with the rest of the company. * * Note that some states require employees to receive their final wages within 24 hours (unless they consent otherwise,) in which case running a one-off payroll may be the only option. * * scope: `employments:read` */ export function useEmployeeEmploymentsGetTerminationsSuspense( request: GetV1EmployeesEmployeeIdTerminationsRequest, options?: SuspenseQueryHookOptions< EmployeeEmploymentsGetTerminationsQueryData, EmployeeEmploymentsGetTerminationsQueryError >, ): UseSuspenseQueryResult< EmployeeEmploymentsGetTerminationsQueryData, EmployeeEmploymentsGetTerminationsQueryError > { const client = useGustoEmbeddedContext(); return useSuspenseQuery({ ...buildEmployeeEmploymentsGetTerminationsQuery( client, request, options, ), ...options, }); } export function setEmployeeEmploymentsGetTerminationsData( client: QueryClient, queryKeyBase: [ employeeId: string, parameters: { xGustoAPIVersion?: | GetV1EmployeesEmployeeIdTerminationsHeaderXGustoAPIVersion | undefined; }, ], data: EmployeeEmploymentsGetTerminationsQueryData, ): EmployeeEmploymentsGetTerminationsQueryData | undefined { const key = queryKeyEmployeeEmploymentsGetTerminations(...queryKeyBase); return client.setQueryData( key, data, ); } export function invalidateEmployeeEmploymentsGetTerminations( client: QueryClient, queryKeyBase: TupleToPrefixes< [ employeeId: string, parameters: { xGustoAPIVersion?: | GetV1EmployeesEmployeeIdTerminationsHeaderXGustoAPIVersion | undefined; }, ] >, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: [ "@gusto/embedded-api", "employeeEmployments", "getTerminations", ...queryKeyBase, ], }); } export function invalidateAllEmployeeEmploymentsGetTerminations( client: QueryClient, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "employeeEmployments", "getTerminations"], }); }