/* * 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 { GetDepartmentHeaderXGustoAPIVersion, GetDepartmentRequest, } from "../models/operations/getdepartment.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes, } from "./_types.js"; import { buildDepartmentsGetQuery, DepartmentsGetQueryData, prefetchDepartmentsGet, queryKeyDepartmentsGet, } from "./departmentsGet.core.js"; export { buildDepartmentsGetQuery, type DepartmentsGetQueryData, prefetchDepartmentsGet, queryKeyDepartmentsGet, }; export type DepartmentsGetQueryError = | NotFoundErrorObject | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Get a department * * @remarks * Get a department given the UUID * * scope: `departments:read` */ export function useDepartmentsGet( request: GetDepartmentRequest, options?: QueryHookOptions, ): UseQueryResult { const client = useGustoEmbeddedContext(); return useQuery({ ...buildDepartmentsGetQuery( client, request, options, ), ...options, }); } /** * Get a department * * @remarks * Get a department given the UUID * * scope: `departments:read` */ export function useDepartmentsGetSuspense( request: GetDepartmentRequest, options?: SuspenseQueryHookOptions< DepartmentsGetQueryData, DepartmentsGetQueryError >, ): UseSuspenseQueryResult { const client = useGustoEmbeddedContext(); return useSuspenseQuery({ ...buildDepartmentsGetQuery( client, request, options, ), ...options, }); } export function setDepartmentsGetData( client: QueryClient, queryKeyBase: [ departmentUuid: string, parameters: { xGustoAPIVersion?: GetDepartmentHeaderXGustoAPIVersion | undefined; }, ], data: DepartmentsGetQueryData, ): DepartmentsGetQueryData | undefined { const key = queryKeyDepartmentsGet(...queryKeyBase); return client.setQueryData(key, data); } export function invalidateDepartmentsGet( client: QueryClient, queryKeyBase: TupleToPrefixes< [ departmentUuid: string, parameters: { xGustoAPIVersion?: GetDepartmentHeaderXGustoAPIVersion | undefined; }, ] >, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "Departments", "get", ...queryKeyBase], }); } export function invalidateAllDepartmentsGet( client: QueryClient, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "Departments", "get"], }); }