/* * 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 { GetV1CompaniesCompanyIdPayrollsPayrollIdHeaderXGustoAPIVersion, GetV1CompaniesCompanyIdPayrollsPayrollIdQueryParamInclude, GetV1CompaniesCompanyIdPayrollsPayrollIdRequest, } from "../models/operations/getv1companiescompanyidpayrollspayrollid.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes, } from "./_types.js"; import { buildPayrollsGetQuery, PayrollsGetQueryData, prefetchPayrollsGet, queryKeyPayrollsGet, } from "./payrollsGet.core.js"; export { buildPayrollsGetQuery, type PayrollsGetQueryData, prefetchPayrollsGet, queryKeyPayrollsGet, }; export type PayrollsGetQueryError = | NotFoundErrorObject | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Get a single payroll * * @remarks * Returns a payroll. If payroll is calculated or processed, will return employee_compensations and totals. * * Results are paginated, with a maximum page size of 100 employee_compensations. * * Notes: * * Hour and dollar amounts are returned as string representations of numeric decimals. * * Hours are represented to the thousands place; dollar amounts are represented to the cent. * * Every eligible compensation is returned for each employee. If no data has yet be inserted for a given field, it defaults to "0.00" (for fixed amounts) or "0.000" (for hours ). * * When include parameter with benefits value is passed, employee_benefits:read scope is required to return benefits * * Benefits containing PHI are only visible with the `employee_benefits:read:phi` scope * * scope: `payrolls:read` */ export function usePayrollsGet( request: GetV1CompaniesCompanyIdPayrollsPayrollIdRequest, options?: QueryHookOptions, ): UseQueryResult { const client = useGustoEmbeddedContext(); return useQuery({ ...buildPayrollsGetQuery( client, request, options, ), ...options, }); } /** * Get a single payroll * * @remarks * Returns a payroll. If payroll is calculated or processed, will return employee_compensations and totals. * * Results are paginated, with a maximum page size of 100 employee_compensations. * * Notes: * * Hour and dollar amounts are returned as string representations of numeric decimals. * * Hours are represented to the thousands place; dollar amounts are represented to the cent. * * Every eligible compensation is returned for each employee. If no data has yet be inserted for a given field, it defaults to "0.00" (for fixed amounts) or "0.000" (for hours ). * * When include parameter with benefits value is passed, employee_benefits:read scope is required to return benefits * * Benefits containing PHI are only visible with the `employee_benefits:read:phi` scope * * scope: `payrolls:read` */ export function usePayrollsGetSuspense( request: GetV1CompaniesCompanyIdPayrollsPayrollIdRequest, options?: SuspenseQueryHookOptions< PayrollsGetQueryData, PayrollsGetQueryError >, ): UseSuspenseQueryResult { const client = useGustoEmbeddedContext(); return useSuspenseQuery({ ...buildPayrollsGetQuery( client, request, options, ), ...options, }); } export function setPayrollsGetData( client: QueryClient, queryKeyBase: [ companyId: string, payrollId: string, parameters: { xGustoAPIVersion?: | GetV1CompaniesCompanyIdPayrollsPayrollIdHeaderXGustoAPIVersion | undefined; include?: | Array | undefined; page?: number | undefined; per?: number | undefined; sortBy?: string | undefined; }, ], data: PayrollsGetQueryData, ): PayrollsGetQueryData | undefined { const key = queryKeyPayrollsGet(...queryKeyBase); return client.setQueryData(key, data); } export function invalidatePayrollsGet( client: QueryClient, queryKeyBase: TupleToPrefixes< [ companyId: string, payrollId: string, parameters: { xGustoAPIVersion?: | GetV1CompaniesCompanyIdPayrollsPayrollIdHeaderXGustoAPIVersion | undefined; include?: | Array | undefined; page?: number | undefined; per?: number | undefined; sortBy?: string | undefined; }, ] >, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "Payrolls", "get", ...queryKeyBase], }); } export function invalidateAllPayrollsGet( client: QueryClient, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "Payrolls", "get"], }); }