/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { InvalidateQueryFilters, QueryClient, useQuery, UseQueryResult, useSuspenseQuery, UseSuspenseQueryResult, } from "@tanstack/react-query"; import { GustoEmbeddedError } from "../models/errors/gustoembeddederror.js"; import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; import { NotFoundErrorObject } from "../models/errors/notfounderrorobject.js"; import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import { GetV1CompaniesHeaderXGustoAPIVersion, GetV1CompaniesRequest, } from "../models/operations/getv1companies.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes, } from "./_types.js"; import { buildCompaniesGetQuery, CompaniesGetQueryData, prefetchCompaniesGet, queryKeyCompaniesGet, } from "./companiesGet.core.js"; export { buildCompaniesGetQuery, type CompaniesGetQueryData, prefetchCompaniesGet, queryKeyCompaniesGet, }; export type CompaniesGetQueryError = | NotFoundErrorObject | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Get a company * * @remarks * Get a company. * * The employees:read scope is required to return home_address and non-work locations. * The company_admin:read scope is required to return primary_payroll_admin. * The signatories:read scope is required to return primary_signatory. * * scope: `companies:read` */ export function useCompaniesGet( request: GetV1CompaniesRequest, options?: QueryHookOptions, ): UseQueryResult { const client = useGustoEmbeddedContext(); return useQuery({ ...buildCompaniesGetQuery( client, request, options, ), ...options, }); } /** * Get a company * * @remarks * Get a company. * * The employees:read scope is required to return home_address and non-work locations. * The company_admin:read scope is required to return primary_payroll_admin. * The signatories:read scope is required to return primary_signatory. * * scope: `companies:read` */ export function useCompaniesGetSuspense( request: GetV1CompaniesRequest, options?: SuspenseQueryHookOptions< CompaniesGetQueryData, CompaniesGetQueryError >, ): UseSuspenseQueryResult { const client = useGustoEmbeddedContext(); return useSuspenseQuery({ ...buildCompaniesGetQuery( client, request, options, ), ...options, }); } export function setCompaniesGetData( client: QueryClient, queryKeyBase: [ companyId: string, parameters: { xGustoAPIVersion?: GetV1CompaniesHeaderXGustoAPIVersion | undefined; }, ], data: CompaniesGetQueryData, ): CompaniesGetQueryData | undefined { const key = queryKeyCompaniesGet(...queryKeyBase); return client.setQueryData(key, data); } export function invalidateCompaniesGet( client: QueryClient, queryKeyBase: TupleToPrefixes< [ companyId: string, parameters: { xGustoAPIVersion?: GetV1CompaniesHeaderXGustoAPIVersion | undefined; }, ] >, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "Companies", "get", ...queryKeyBase], }); } export function invalidateAllCompaniesGet( client: QueryClient, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "Companies", "get"], }); }