/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { QueryClient, QueryFunctionContext, QueryKey, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { departmentsGet } from "../funcs/departmentsGet.js"; import { combineSignals } from "../lib/primitives.js"; import { RequestOptions } from "../lib/sdks.js"; import { GetDepartmentHeaderXGustoAPIVersion, GetDepartmentRequest, GetDepartmentResponse, } from "../models/operations/getdepartment.js"; import { unwrapAsync } from "../types/fp.js"; export type DepartmentsGetQueryData = GetDepartmentResponse; export function prefetchDepartmentsGet( queryClient: QueryClient, client$: GustoEmbeddedCore, request: GetDepartmentRequest, options?: RequestOptions, ): Promise { return queryClient.prefetchQuery({ ...buildDepartmentsGetQuery( client$, request, options, ), }); } export function buildDepartmentsGetQuery( client$: GustoEmbeddedCore, request: GetDepartmentRequest, options?: RequestOptions, ): { queryKey: QueryKey; queryFn: (context: QueryFunctionContext) => Promise; } { return { queryKey: queryKeyDepartmentsGet(request.departmentUuid, { xGustoAPIVersion: request.xGustoAPIVersion, }), queryFn: async function departmentsGetQueryFn( ctx, ): Promise { const sig = combineSignals( ctx.signal, options?.signal, options?.fetchOptions?.signal, ); const mergedOptions = { ...options?.fetchOptions, ...options, signal: sig, }; return unwrapAsync(departmentsGet( client$, request, mergedOptions, )); }, }; } export function queryKeyDepartmentsGet( departmentUuid: string, parameters: { xGustoAPIVersion?: GetDepartmentHeaderXGustoAPIVersion | undefined; }, ): QueryKey { return [ "@gusto/embedded-api", "Departments", "get", departmentUuid, parameters, ]; }