/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { QueryClient, QueryFunctionContext, QueryKey, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { locationsGet } from "../funcs/locationsGet.js"; import { combineSignals } from "../lib/primitives.js"; import { RequestOptions } from "../lib/sdks.js"; import { GetV1CompaniesCompanyIdLocationsHeaderXGustoAPIVersion, GetV1CompaniesCompanyIdLocationsRequest, GetV1CompaniesCompanyIdLocationsResponse, } from "../models/operations/getv1companiescompanyidlocations.js"; import { unwrapAsync } from "../types/fp.js"; export type LocationsGetQueryData = GetV1CompaniesCompanyIdLocationsResponse; export function prefetchLocationsGet( queryClient: QueryClient, client$: GustoEmbeddedCore, request: GetV1CompaniesCompanyIdLocationsRequest, options?: RequestOptions, ): Promise { return queryClient.prefetchQuery({ ...buildLocationsGetQuery( client$, request, options, ), }); } export function buildLocationsGetQuery( client$: GustoEmbeddedCore, request: GetV1CompaniesCompanyIdLocationsRequest, options?: RequestOptions, ): { queryKey: QueryKey; queryFn: (context: QueryFunctionContext) => Promise; } { return { queryKey: queryKeyLocationsGet(request.companyId, { xGustoAPIVersion: request.xGustoAPIVersion, page: request.page, per: request.per, }), queryFn: async function locationsGetQueryFn( ctx, ): Promise { const sig = combineSignals( ctx.signal, options?.signal, options?.fetchOptions?.signal, ); const mergedOptions = { ...options?.fetchOptions, ...options, signal: sig, }; return unwrapAsync(locationsGet( client$, request, mergedOptions, )); }, }; } export function queryKeyLocationsGet( companyId: string, parameters: { xGustoAPIVersion?: | GetV1CompaniesCompanyIdLocationsHeaderXGustoAPIVersion | undefined; page?: number | undefined; per?: number | undefined; }, ): QueryKey { return ["@gusto/embedded-api", "Locations", "get", companyId, parameters]; }