/* * 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 { GetV1EmployeesHeaderXGustoAPIVersion, GetV1EmployeesRequest, QueryParamInclude, } from "../models/operations/getv1employees.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes, } from "./_types.js"; import { buildEmployeesGetQuery, EmployeesGetQueryData, prefetchEmployeesGet, queryKeyEmployeesGet, } from "./employeesGet.core.js"; export { buildEmployeesGetQuery, type EmployeesGetQueryData, prefetchEmployeesGet, queryKeyEmployeesGet, }; export type EmployeesGetQueryError = | NotFoundErrorObject | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Get an employee * * @remarks * Get an employee. * * Note: Compensation data (pay rate, payment unit, and related fields) represents sensitive employee pay information. When retrieving employee job data, these fields (`rate`, `payment_unit`, `current_compensation_uuid`, `compensations`) are only returned when the `compensations:read` scope is included. This allows you to access employee and job metadata without exposing pay rates. * * scope: `employees:read` */ export function useEmployeesGet( request: GetV1EmployeesRequest, options?: QueryHookOptions, ): UseQueryResult { const client = useGustoEmbeddedContext(); return useQuery({ ...buildEmployeesGetQuery( client, request, options, ), ...options, }); } /** * Get an employee * * @remarks * Get an employee. * * Note: Compensation data (pay rate, payment unit, and related fields) represents sensitive employee pay information. When retrieving employee job data, these fields (`rate`, `payment_unit`, `current_compensation_uuid`, `compensations`) are only returned when the `compensations:read` scope is included. This allows you to access employee and job metadata without exposing pay rates. * * scope: `employees:read` */ export function useEmployeesGetSuspense( request: GetV1EmployeesRequest, options?: SuspenseQueryHookOptions< EmployeesGetQueryData, EmployeesGetQueryError >, ): UseSuspenseQueryResult { const client = useGustoEmbeddedContext(); return useSuspenseQuery({ ...buildEmployeesGetQuery( client, request, options, ), ...options, }); } export function setEmployeesGetData( client: QueryClient, queryKeyBase: [ employeeId: string, parameters: { xGustoAPIVersion?: GetV1EmployeesHeaderXGustoAPIVersion | undefined; include?: Array | undefined; }, ], data: EmployeesGetQueryData, ): EmployeesGetQueryData | undefined { const key = queryKeyEmployeesGet(...queryKeyBase); return client.setQueryData(key, data); } export function invalidateEmployeesGet( client: QueryClient, queryKeyBase: TupleToPrefixes< [ employeeId: string, parameters: { xGustoAPIVersion?: GetV1EmployeesHeaderXGustoAPIVersion | undefined; include?: Array | undefined; }, ] >, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "Employees", "get", ...queryKeyBase], }); } export function invalidateAllEmployeesGet( client: QueryClient, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "Employees", "get"], }); }