/* * 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 { GetV1JobsJobIdCompensationsHeaderXGustoAPIVersion, GetV1JobsJobIdCompensationsQueryParamInclude, GetV1JobsJobIdCompensationsRequest, } from "../models/operations/getv1jobsjobidcompensations.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes, } from "./_types.js"; import { buildJobsAndCompensationsGetCompensationsQuery, JobsAndCompensationsGetCompensationsQueryData, prefetchJobsAndCompensationsGetCompensations, queryKeyJobsAndCompensationsGetCompensations, } from "./jobsAndCompensationsGetCompensations.core.js"; export { buildJobsAndCompensationsGetCompensationsQuery, type JobsAndCompensationsGetCompensationsQueryData, prefetchJobsAndCompensationsGetCompensations, queryKeyJobsAndCompensationsGetCompensations, }; export type JobsAndCompensationsGetCompensationsQueryError = | NotFoundErrorObject | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Get compensations for a job * * @remarks * Compensations contain information on how much is paid out for a job. Jobs may have many compensations, but only one that is active. The current compensation is the one with the most recent `effective_date`. * * *Note: Currently the API does not support creating multiple compensations per job - creating a compensation with the same job_uuid as another will fail with a relevant error.* * * Use `flsa_status` to determine if an employee is eligible for overtime * By default the API returns only the current compensation - use the `include` parameter to return all compensations. * * scope: `compensations:read` */ export function useJobsAndCompensationsGetCompensations( request: GetV1JobsJobIdCompensationsRequest, options?: QueryHookOptions< JobsAndCompensationsGetCompensationsQueryData, JobsAndCompensationsGetCompensationsQueryError >, ): UseQueryResult< JobsAndCompensationsGetCompensationsQueryData, JobsAndCompensationsGetCompensationsQueryError > { const client = useGustoEmbeddedContext(); return useQuery({ ...buildJobsAndCompensationsGetCompensationsQuery( client, request, options, ), ...options, }); } /** * Get compensations for a job * * @remarks * Compensations contain information on how much is paid out for a job. Jobs may have many compensations, but only one that is active. The current compensation is the one with the most recent `effective_date`. * * *Note: Currently the API does not support creating multiple compensations per job - creating a compensation with the same job_uuid as another will fail with a relevant error.* * * Use `flsa_status` to determine if an employee is eligible for overtime * By default the API returns only the current compensation - use the `include` parameter to return all compensations. * * scope: `compensations:read` */ export function useJobsAndCompensationsGetCompensationsSuspense( request: GetV1JobsJobIdCompensationsRequest, options?: SuspenseQueryHookOptions< JobsAndCompensationsGetCompensationsQueryData, JobsAndCompensationsGetCompensationsQueryError >, ): UseSuspenseQueryResult< JobsAndCompensationsGetCompensationsQueryData, JobsAndCompensationsGetCompensationsQueryError > { const client = useGustoEmbeddedContext(); return useSuspenseQuery({ ...buildJobsAndCompensationsGetCompensationsQuery( client, request, options, ), ...options, }); } export function setJobsAndCompensationsGetCompensationsData( client: QueryClient, queryKeyBase: [ jobId: string, parameters: { xGustoAPIVersion?: | GetV1JobsJobIdCompensationsHeaderXGustoAPIVersion | undefined; page?: number | undefined; per?: number | undefined; include?: GetV1JobsJobIdCompensationsQueryParamInclude | undefined; }, ], data: JobsAndCompensationsGetCompensationsQueryData, ): JobsAndCompensationsGetCompensationsQueryData | undefined { const key = queryKeyJobsAndCompensationsGetCompensations(...queryKeyBase); return client.setQueryData( key, data, ); } export function invalidateJobsAndCompensationsGetCompensations( client: QueryClient, queryKeyBase: TupleToPrefixes< [ jobId: string, parameters: { xGustoAPIVersion?: | GetV1JobsJobIdCompensationsHeaderXGustoAPIVersion | undefined; page?: number | undefined; per?: number | undefined; include?: GetV1JobsJobIdCompensationsQueryParamInclude | undefined; }, ] >, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: [ "@gusto/embedded-api", "jobsAndCompensations", "getCompensations", ...queryKeyBase, ], }); } export function invalidateAllJobsAndCompensationsGetCompensations( client: QueryClient, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: [ "@gusto/embedded-api", "jobsAndCompensations", "getCompensations", ], }); }