/* * 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 { GetV1EmployeesEmployeeIdEmployeeBenefitsHeaderXGustoAPIVersion, GetV1EmployeesEmployeeIdEmployeeBenefitsQueryParamInclude, GetV1EmployeesEmployeeIdEmployeeBenefitsRequest, } from "../models/operations/getv1employeesemployeeidemployeebenefits.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes, } from "./_types.js"; import { buildEmployeeBenefitsGetQuery, EmployeeBenefitsGetQueryData, prefetchEmployeeBenefitsGet, queryKeyEmployeeBenefitsGet, } from "./employeeBenefitsGet.core.js"; export { buildEmployeeBenefitsGetQuery, type EmployeeBenefitsGetQueryData, prefetchEmployeeBenefitsGet, queryKeyEmployeeBenefitsGet, }; export type EmployeeBenefitsGetQueryError = | NotFoundErrorObject | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Get all benefits for an employee * * @remarks * Employee benefits represent an employee enrolled in a particular company benefit. It includes information specific to that employee’s enrollment. * * Returns an array of all employee benefits for this employee * * Benefits containing PHI are only visible to applications with the `employee_benefits:read:phi` scope. * * scope: `employee_benefits:read` */ export function useEmployeeBenefitsGet( request: GetV1EmployeesEmployeeIdEmployeeBenefitsRequest, options?: QueryHookOptions< EmployeeBenefitsGetQueryData, EmployeeBenefitsGetQueryError >, ): UseQueryResult { const client = useGustoEmbeddedContext(); return useQuery({ ...buildEmployeeBenefitsGetQuery( client, request, options, ), ...options, }); } /** * Get all benefits for an employee * * @remarks * Employee benefits represent an employee enrolled in a particular company benefit. It includes information specific to that employee’s enrollment. * * Returns an array of all employee benefits for this employee * * Benefits containing PHI are only visible to applications with the `employee_benefits:read:phi` scope. * * scope: `employee_benefits:read` */ export function useEmployeeBenefitsGetSuspense( request: GetV1EmployeesEmployeeIdEmployeeBenefitsRequest, options?: SuspenseQueryHookOptions< EmployeeBenefitsGetQueryData, EmployeeBenefitsGetQueryError >, ): UseSuspenseQueryResult< EmployeeBenefitsGetQueryData, EmployeeBenefitsGetQueryError > { const client = useGustoEmbeddedContext(); return useSuspenseQuery({ ...buildEmployeeBenefitsGetQuery( client, request, options, ), ...options, }); } export function setEmployeeBenefitsGetData( client: QueryClient, queryKeyBase: [ employeeId: string, parameters: { xGustoAPIVersion?: | GetV1EmployeesEmployeeIdEmployeeBenefitsHeaderXGustoAPIVersion | undefined; page?: number | undefined; per?: number | undefined; include?: | GetV1EmployeesEmployeeIdEmployeeBenefitsQueryParamInclude | undefined; }, ], data: EmployeeBenefitsGetQueryData, ): EmployeeBenefitsGetQueryData | undefined { const key = queryKeyEmployeeBenefitsGet(...queryKeyBase); return client.setQueryData(key, data); } export function invalidateEmployeeBenefitsGet( client: QueryClient, queryKeyBase: TupleToPrefixes< [ employeeId: string, parameters: { xGustoAPIVersion?: | GetV1EmployeesEmployeeIdEmployeeBenefitsHeaderXGustoAPIVersion | undefined; page?: number | undefined; per?: number | undefined; include?: | GetV1EmployeesEmployeeIdEmployeeBenefitsQueryParamInclude | undefined; }, ] >, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: [ "@gusto/embedded-api", "employeeBenefits", "get", ...queryKeyBase, ], }); } export function invalidateAllEmployeeBenefitsGet( client: QueryClient, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "employeeBenefits", "get"], }); }