/* * 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 { GetCompaniesDepartmentsHeaderXGustoAPIVersion, GetCompaniesDepartmentsRequest, } from "../models/operations/getcompaniesdepartments.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes, } from "./_types.js"; import { buildDepartmentsGetAllQuery, DepartmentsGetAllQueryData, prefetchDepartmentsGetAll, queryKeyDepartmentsGetAll, } from "./departmentsGetAll.core.js"; export { buildDepartmentsGetAllQuery, type DepartmentsGetAllQueryData, prefetchDepartmentsGetAll, queryKeyDepartmentsGetAll, }; export type DepartmentsGetAllQueryError = | NotFoundErrorObject | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Get all departments of a company * * @remarks * Get all of the departments for a given company with the employees and contractors assigned to that department. * * scope: `departments:read` */ export function useDepartmentsGetAll( request: GetCompaniesDepartmentsRequest, options?: QueryHookOptions< DepartmentsGetAllQueryData, DepartmentsGetAllQueryError >, ): UseQueryResult { const client = useGustoEmbeddedContext(); return useQuery({ ...buildDepartmentsGetAllQuery( client, request, options, ), ...options, }); } /** * Get all departments of a company * * @remarks * Get all of the departments for a given company with the employees and contractors assigned to that department. * * scope: `departments:read` */ export function useDepartmentsGetAllSuspense( request: GetCompaniesDepartmentsRequest, options?: SuspenseQueryHookOptions< DepartmentsGetAllQueryData, DepartmentsGetAllQueryError >, ): UseSuspenseQueryResult< DepartmentsGetAllQueryData, DepartmentsGetAllQueryError > { const client = useGustoEmbeddedContext(); return useSuspenseQuery({ ...buildDepartmentsGetAllQuery( client, request, options, ), ...options, }); } export function setDepartmentsGetAllData( client: QueryClient, queryKeyBase: [ companyUuid: string, parameters: { xGustoAPIVersion?: | GetCompaniesDepartmentsHeaderXGustoAPIVersion | undefined; }, ], data: DepartmentsGetAllQueryData, ): DepartmentsGetAllQueryData | undefined { const key = queryKeyDepartmentsGetAll(...queryKeyBase); return client.setQueryData(key, data); } export function invalidateDepartmentsGetAll( client: QueryClient, queryKeyBase: TupleToPrefixes< [ companyUuid: string, parameters: { xGustoAPIVersion?: | GetCompaniesDepartmentsHeaderXGustoAPIVersion | undefined; }, ] >, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "Departments", "getAll", ...queryKeyBase], }); } export function invalidateAllDepartmentsGetAll( client: QueryClient, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "Departments", "getAll"], }); }