/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { QueryClient, QueryFunctionContext, QueryKey, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { locationsRetrieve } from "../funcs/locationsRetrieve.js"; import { combineSignals } from "../lib/primitives.js"; import { RequestOptions } from "../lib/sdks.js"; import { GetV1LocationsLocationIdHeaderXGustoAPIVersion, GetV1LocationsLocationIdRequest, GetV1LocationsLocationIdResponse, } from "../models/operations/getv1locationslocationid.js"; import { unwrapAsync } from "../types/fp.js"; export type LocationsRetrieveQueryData = GetV1LocationsLocationIdResponse; export function prefetchLocationsRetrieve( queryClient: QueryClient, client$: GustoEmbeddedCore, request: GetV1LocationsLocationIdRequest, options?: RequestOptions, ): Promise { return queryClient.prefetchQuery({ ...buildLocationsRetrieveQuery( client$, request, options, ), }); } export function buildLocationsRetrieveQuery( client$: GustoEmbeddedCore, request: GetV1LocationsLocationIdRequest, options?: RequestOptions, ): { queryKey: QueryKey; queryFn: ( context: QueryFunctionContext, ) => Promise; } { return { queryKey: queryKeyLocationsRetrieve(request.locationId, { xGustoAPIVersion: request.xGustoAPIVersion, }), queryFn: async function locationsRetrieveQueryFn( ctx, ): Promise { const sig = combineSignals( ctx.signal, options?.signal, options?.fetchOptions?.signal, ); const mergedOptions = { ...options?.fetchOptions, ...options, signal: sig, }; return unwrapAsync(locationsRetrieve( client$, request, mergedOptions, )); }, }; } export function queryKeyLocationsRetrieve( locationId: string, parameters: { xGustoAPIVersion?: | GetV1LocationsLocationIdHeaderXGustoAPIVersion | undefined; }, ): QueryKey { return [ "@gusto/embedded-api", "Locations", "retrieve", locationId, parameters, ]; }