/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { QueryClient, QueryFunctionContext, QueryKey, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { employeeEmploymentsGetHistory } from "../funcs/employeeEmploymentsGetHistory.js"; import { combineSignals } from "../lib/primitives.js"; import { RequestOptions } from "../lib/sdks.js"; import { GetV1EmployeesEmployeeIdEmploymentHistoryHeaderXGustoAPIVersion, GetV1EmployeesEmployeeIdEmploymentHistoryRequest, GetV1EmployeesEmployeeIdEmploymentHistoryResponse, } from "../models/operations/getv1employeesemployeeidemploymenthistory.js"; import { unwrapAsync } from "../types/fp.js"; export type EmployeeEmploymentsGetHistoryQueryData = GetV1EmployeesEmployeeIdEmploymentHistoryResponse; export function prefetchEmployeeEmploymentsGetHistory( queryClient: QueryClient, client$: GustoEmbeddedCore, request: GetV1EmployeesEmployeeIdEmploymentHistoryRequest, options?: RequestOptions, ): Promise { return queryClient.prefetchQuery({ ...buildEmployeeEmploymentsGetHistoryQuery( client$, request, options, ), }); } export function buildEmployeeEmploymentsGetHistoryQuery( client$: GustoEmbeddedCore, request: GetV1EmployeesEmployeeIdEmploymentHistoryRequest, options?: RequestOptions, ): { queryKey: QueryKey; queryFn: ( context: QueryFunctionContext, ) => Promise; } { return { queryKey: queryKeyEmployeeEmploymentsGetHistory(request.employeeId, { xGustoAPIVersion: request.xGustoAPIVersion, }), queryFn: async function employeeEmploymentsGetHistoryQueryFn( ctx, ): Promise { const sig = combineSignals( ctx.signal, options?.signal, options?.fetchOptions?.signal, ); const mergedOptions = { ...options?.fetchOptions, ...options, signal: sig, }; return unwrapAsync(employeeEmploymentsGetHistory( client$, request, mergedOptions, )); }, }; } export function queryKeyEmployeeEmploymentsGetHistory( employeeId: string, parameters: { xGustoAPIVersion?: | GetV1EmployeesEmployeeIdEmploymentHistoryHeaderXGustoAPIVersion | undefined; }, ): QueryKey { return [ "@gusto/embedded-api", "employeeEmployments", "getHistory", employeeId, parameters, ]; }