/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { QueryClient, QueryFunctionContext, QueryKey, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { garnishmentsGet } from "../funcs/garnishmentsGet.js"; import { combineSignals } from "../lib/primitives.js"; import { RequestOptions } from "../lib/sdks.js"; import { GetV1GarnishmentsGarnishmentIdHeaderXGustoAPIVersion, GetV1GarnishmentsGarnishmentIdRequest, GetV1GarnishmentsGarnishmentIdResponse, } from "../models/operations/getv1garnishmentsgarnishmentid.js"; import { unwrapAsync } from "../types/fp.js"; export type GarnishmentsGetQueryData = GetV1GarnishmentsGarnishmentIdResponse; export function prefetchGarnishmentsGet( queryClient: QueryClient, client$: GustoEmbeddedCore, request: GetV1GarnishmentsGarnishmentIdRequest, options?: RequestOptions, ): Promise { return queryClient.prefetchQuery({ ...buildGarnishmentsGetQuery( client$, request, options, ), }); } export function buildGarnishmentsGetQuery( client$: GustoEmbeddedCore, request: GetV1GarnishmentsGarnishmentIdRequest, options?: RequestOptions, ): { queryKey: QueryKey; queryFn: (context: QueryFunctionContext) => Promise; } { return { queryKey: queryKeyGarnishmentsGet(request.garnishmentId, { xGustoAPIVersion: request.xGustoAPIVersion, }), queryFn: async function garnishmentsGetQueryFn( ctx, ): Promise { const sig = combineSignals( ctx.signal, options?.signal, options?.fetchOptions?.signal, ); const mergedOptions = { ...options?.fetchOptions, ...options, signal: sig, }; return unwrapAsync(garnishmentsGet( client$, request, mergedOptions, )); }, }; } export function queryKeyGarnishmentsGet( garnishmentId: string, parameters: { xGustoAPIVersion?: | GetV1GarnishmentsGarnishmentIdHeaderXGustoAPIVersion | undefined; }, ): QueryKey { return [ "@gusto/embedded-api", "Garnishments", "get", garnishmentId, parameters, ]; }