/* * 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 { GetV1EmployeesEmployeeIdEmploymentHistoryHeaderXGustoAPIVersion, GetV1EmployeesEmployeeIdEmploymentHistoryRequest, } from "../models/operations/getv1employeesemployeeidemploymenthistory.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes, } from "./_types.js"; import { buildEmployeeEmploymentsGetHistoryQuery, EmployeeEmploymentsGetHistoryQueryData, prefetchEmployeeEmploymentsGetHistory, queryKeyEmployeeEmploymentsGetHistory, } from "./employeeEmploymentsGetHistory.core.js"; export { buildEmployeeEmploymentsGetHistoryQuery, type EmployeeEmploymentsGetHistoryQueryData, prefetchEmployeeEmploymentsGetHistory, queryKeyEmployeeEmploymentsGetHistory, }; export type EmployeeEmploymentsGetHistoryQueryError = | NotFoundErrorObject | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Get employment history for an employee * * @remarks * Retrieve the employment history for a given employee, which includes termination and rehire. * * scope: `employments:read` */ export function useEmployeeEmploymentsGetHistory( request: GetV1EmployeesEmployeeIdEmploymentHistoryRequest, options?: QueryHookOptions< EmployeeEmploymentsGetHistoryQueryData, EmployeeEmploymentsGetHistoryQueryError >, ): UseQueryResult< EmployeeEmploymentsGetHistoryQueryData, EmployeeEmploymentsGetHistoryQueryError > { const client = useGustoEmbeddedContext(); return useQuery({ ...buildEmployeeEmploymentsGetHistoryQuery( client, request, options, ), ...options, }); } /** * Get employment history for an employee * * @remarks * Retrieve the employment history for a given employee, which includes termination and rehire. * * scope: `employments:read` */ export function useEmployeeEmploymentsGetHistorySuspense( request: GetV1EmployeesEmployeeIdEmploymentHistoryRequest, options?: SuspenseQueryHookOptions< EmployeeEmploymentsGetHistoryQueryData, EmployeeEmploymentsGetHistoryQueryError >, ): UseSuspenseQueryResult< EmployeeEmploymentsGetHistoryQueryData, EmployeeEmploymentsGetHistoryQueryError > { const client = useGustoEmbeddedContext(); return useSuspenseQuery({ ...buildEmployeeEmploymentsGetHistoryQuery( client, request, options, ), ...options, }); } export function setEmployeeEmploymentsGetHistoryData( client: QueryClient, queryKeyBase: [ employeeId: string, parameters: { xGustoAPIVersion?: | GetV1EmployeesEmployeeIdEmploymentHistoryHeaderXGustoAPIVersion | undefined; }, ], data: EmployeeEmploymentsGetHistoryQueryData, ): EmployeeEmploymentsGetHistoryQueryData | undefined { const key = queryKeyEmployeeEmploymentsGetHistory(...queryKeyBase); return client.setQueryData(key, data); } export function invalidateEmployeeEmploymentsGetHistory( client: QueryClient, queryKeyBase: TupleToPrefixes< [ employeeId: string, parameters: { xGustoAPIVersion?: | GetV1EmployeesEmployeeIdEmploymentHistoryHeaderXGustoAPIVersion | undefined; }, ] >, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: [ "@gusto/embedded-api", "employeeEmployments", "getHistory", ...queryKeyBase, ], }); } export function invalidateAllEmployeeEmploymentsGetHistory( client: QueryClient, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "employeeEmployments", "getHistory"], }); }