/* * 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 { GetV1CompaniesCompanyIdEarningTypesHeaderXGustoAPIVersion, GetV1CompaniesCompanyIdEarningTypesRequest, } from "../models/operations/getv1companiescompanyidearningtypes.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes, } from "./_types.js"; import { buildEarningTypesListQuery, EarningTypesListQueryData, prefetchEarningTypesList, queryKeyEarningTypesList, } from "./earningTypesList.core.js"; export { buildEarningTypesListQuery, type EarningTypesListQueryData, prefetchEarningTypesList, queryKeyEarningTypesList, }; export type EarningTypesListQueryError = | NotFoundErrorObject | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Get all earning types for a company * * @remarks * A payroll item in Gusto is associated to an earning type to name the type of earning described by the payroll item. * * #### Default Earning Type * Certain earning types are special because they have tax considerations. Those earning types are mostly the same for every company depending on its legal structure (LLC, Corporation, etc.) * * #### Custom Earning Type * Custom earning types are all the other earning types added specifically for a company. * * scope: `payrolls:read` */ export function useEarningTypesList( request: GetV1CompaniesCompanyIdEarningTypesRequest, options?: QueryHookOptions< EarningTypesListQueryData, EarningTypesListQueryError >, ): UseQueryResult { const client = useGustoEmbeddedContext(); return useQuery({ ...buildEarningTypesListQuery( client, request, options, ), ...options, }); } /** * Get all earning types for a company * * @remarks * A payroll item in Gusto is associated to an earning type to name the type of earning described by the payroll item. * * #### Default Earning Type * Certain earning types are special because they have tax considerations. Those earning types are mostly the same for every company depending on its legal structure (LLC, Corporation, etc.) * * #### Custom Earning Type * Custom earning types are all the other earning types added specifically for a company. * * scope: `payrolls:read` */ export function useEarningTypesListSuspense( request: GetV1CompaniesCompanyIdEarningTypesRequest, options?: SuspenseQueryHookOptions< EarningTypesListQueryData, EarningTypesListQueryError >, ): UseSuspenseQueryResult< EarningTypesListQueryData, EarningTypesListQueryError > { const client = useGustoEmbeddedContext(); return useSuspenseQuery({ ...buildEarningTypesListQuery( client, request, options, ), ...options, }); } export function setEarningTypesListData( client: QueryClient, queryKeyBase: [ companyId: string, parameters: { xGustoAPIVersion?: | GetV1CompaniesCompanyIdEarningTypesHeaderXGustoAPIVersion | undefined; }, ], data: EarningTypesListQueryData, ): EarningTypesListQueryData | undefined { const key = queryKeyEarningTypesList(...queryKeyBase); return client.setQueryData(key, data); } export function invalidateEarningTypesList( client: QueryClient, queryKeyBase: TupleToPrefixes< [ companyId: string, parameters: { xGustoAPIVersion?: | GetV1CompaniesCompanyIdEarningTypesHeaderXGustoAPIVersion | undefined; }, ] >, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "earningTypes", "list", ...queryKeyBase], }); } export function invalidateAllEarningTypesList( client: QueryClient, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "earningTypes", "list"], }); }