/* * 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 { GetV1CompaniesCompanyIdCompanyBenefitsHeaderXGustoAPIVersion, GetV1CompaniesCompanyIdCompanyBenefitsRequest, } from "../models/operations/getv1companiescompanyidcompanybenefits.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes, } from "./_types.js"; import { buildCompanyBenefitsListQuery, CompanyBenefitsListQueryData, prefetchCompanyBenefitsList, queryKeyCompanyBenefitsList, } from "./companyBenefitsList.core.js"; export { buildCompanyBenefitsListQuery, type CompanyBenefitsListQueryData, prefetchCompanyBenefitsList, queryKeyCompanyBenefitsList, }; export type CompanyBenefitsListQueryError = | NotFoundErrorObject | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Get benefits for a company * * @remarks * Company benefits represent the benefits that a company is offering to employees. This ties together a particular supported benefit with the company-specific information for the offering of that benefit. * * Note that company benefits can be deactivated only when no employees are enrolled. * * Benefits containing PHI are only visible to applications with the `company_benefits:read:phi` scope. * * scope: `company_benefits:read` */ export function useCompanyBenefitsList( request: GetV1CompaniesCompanyIdCompanyBenefitsRequest, options?: QueryHookOptions< CompanyBenefitsListQueryData, CompanyBenefitsListQueryError >, ): UseQueryResult { const client = useGustoEmbeddedContext(); return useQuery({ ...buildCompanyBenefitsListQuery( client, request, options, ), ...options, }); } /** * Get benefits for a company * * @remarks * Company benefits represent the benefits that a company is offering to employees. This ties together a particular supported benefit with the company-specific information for the offering of that benefit. * * Note that company benefits can be deactivated only when no employees are enrolled. * * Benefits containing PHI are only visible to applications with the `company_benefits:read:phi` scope. * * scope: `company_benefits:read` */ export function useCompanyBenefitsListSuspense( request: GetV1CompaniesCompanyIdCompanyBenefitsRequest, options?: SuspenseQueryHookOptions< CompanyBenefitsListQueryData, CompanyBenefitsListQueryError >, ): UseSuspenseQueryResult< CompanyBenefitsListQueryData, CompanyBenefitsListQueryError > { const client = useGustoEmbeddedContext(); return useSuspenseQuery({ ...buildCompanyBenefitsListQuery( client, request, options, ), ...options, }); } export function setCompanyBenefitsListData( client: QueryClient, queryKeyBase: [ companyId: string, parameters: { xGustoAPIVersion?: | GetV1CompaniesCompanyIdCompanyBenefitsHeaderXGustoAPIVersion | undefined; active?: boolean | undefined; enrollmentCount?: boolean | undefined; benefitType?: string | undefined; }, ], data: CompanyBenefitsListQueryData, ): CompanyBenefitsListQueryData | undefined { const key = queryKeyCompanyBenefitsList(...queryKeyBase); return client.setQueryData(key, data); } export function invalidateCompanyBenefitsList( client: QueryClient, queryKeyBase: TupleToPrefixes< [ companyId: string, parameters: { xGustoAPIVersion?: | GetV1CompaniesCompanyIdCompanyBenefitsHeaderXGustoAPIVersion | undefined; active?: boolean | undefined; enrollmentCount?: boolean | undefined; benefitType?: string | undefined; }, ] >, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: [ "@gusto/embedded-api", "companyBenefits", "list", ...queryKeyBase, ], }); } export function invalidateAllCompanyBenefitsList( client: QueryClient, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "companyBenefits", "list"], }); }