/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { QueryClient, QueryFunctionContext, QueryKey, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { garnishmentsList } from "../funcs/garnishmentsList.js"; import { combineSignals } from "../lib/primitives.js"; import { RequestOptions } from "../lib/sdks.js"; import { GetV1EmployeesEmployeeIdGarnishmentsHeaderXGustoAPIVersion, GetV1EmployeesEmployeeIdGarnishmentsRequest, GetV1EmployeesEmployeeIdGarnishmentsResponse, } from "../models/operations/getv1employeesemployeeidgarnishments.js"; import { unwrapAsync } from "../types/fp.js"; export type GarnishmentsListQueryData = GetV1EmployeesEmployeeIdGarnishmentsResponse; export function prefetchGarnishmentsList( queryClient: QueryClient, client$: GustoEmbeddedCore, request: GetV1EmployeesEmployeeIdGarnishmentsRequest, options?: RequestOptions, ): Promise { return queryClient.prefetchQuery({ ...buildGarnishmentsListQuery( client$, request, options, ), }); } export function buildGarnishmentsListQuery( client$: GustoEmbeddedCore, request: GetV1EmployeesEmployeeIdGarnishmentsRequest, options?: RequestOptions, ): { queryKey: QueryKey; queryFn: ( context: QueryFunctionContext, ) => Promise; } { return { queryKey: queryKeyGarnishmentsList(request.employeeId, { xGustoAPIVersion: request.xGustoAPIVersion, page: request.page, per: request.per, }), queryFn: async function garnishmentsListQueryFn( ctx, ): Promise { const sig = combineSignals( ctx.signal, options?.signal, options?.fetchOptions?.signal, ); const mergedOptions = { ...options?.fetchOptions, ...options, signal: sig, }; return unwrapAsync(garnishmentsList( client$, request, mergedOptions, )); }, }; } export function queryKeyGarnishmentsList( employeeId: string, parameters: { xGustoAPIVersion?: | GetV1EmployeesEmployeeIdGarnishmentsHeaderXGustoAPIVersion | undefined; page?: number | undefined; per?: number | undefined; }, ): QueryKey { return [ "@gusto/embedded-api", "Garnishments", "list", employeeId, parameters, ]; }