/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { QueryClient, QueryFunctionContext, QueryKey, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { departmentsGetAll } from "../funcs/departmentsGetAll.js"; import { combineSignals } from "../lib/primitives.js"; import { RequestOptions } from "../lib/sdks.js"; import { GetCompaniesDepartmentsHeaderXGustoAPIVersion, GetCompaniesDepartmentsRequest, GetCompaniesDepartmentsResponse, } from "../models/operations/getcompaniesdepartments.js"; import { unwrapAsync } from "../types/fp.js"; export type DepartmentsGetAllQueryData = GetCompaniesDepartmentsResponse; export function prefetchDepartmentsGetAll( queryClient: QueryClient, client$: GustoEmbeddedCore, request: GetCompaniesDepartmentsRequest, options?: RequestOptions, ): Promise { return queryClient.prefetchQuery({ ...buildDepartmentsGetAllQuery( client$, request, options, ), }); } export function buildDepartmentsGetAllQuery( client$: GustoEmbeddedCore, request: GetCompaniesDepartmentsRequest, options?: RequestOptions, ): { queryKey: QueryKey; queryFn: ( context: QueryFunctionContext, ) => Promise; } { return { queryKey: queryKeyDepartmentsGetAll(request.companyUuid, { xGustoAPIVersion: request.xGustoAPIVersion, }), queryFn: async function departmentsGetAllQueryFn( ctx, ): Promise { const sig = combineSignals( ctx.signal, options?.signal, options?.fetchOptions?.signal, ); const mergedOptions = { ...options?.fetchOptions, ...options, signal: sig, }; return unwrapAsync(departmentsGetAll( client$, request, mergedOptions, )); }, }; } export function queryKeyDepartmentsGetAll( companyUuid: string, parameters: { xGustoAPIVersion?: | GetCompaniesDepartmentsHeaderXGustoAPIVersion | undefined; }, ): QueryKey { return [ "@gusto/embedded-api", "Departments", "getAll", companyUuid, parameters, ]; }