/* * 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 { GetV1CompaniesCompanyIdContractorPaymentsHeaderXGustoAPIVersion, GetV1CompaniesCompanyIdContractorPaymentsRequest, } from "../models/operations/getv1companiescompanyidcontractorpayments.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes, } from "./_types.js"; import { buildContractorPaymentsListQuery, ContractorPaymentsListQueryData, prefetchContractorPaymentsList, queryKeyContractorPaymentsList, } from "./contractorPaymentsList.core.js"; export { buildContractorPaymentsListQuery, type ContractorPaymentsListQueryData, prefetchContractorPaymentsList, queryKeyContractorPaymentsList, }; export type ContractorPaymentsListQueryError = | NotFoundErrorObject | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Get contractor payments for a company * * @remarks * Returns an object containing individual contractor payments, within a given time period, including totals. * * Results are returned in reverse chronological order (newest first). * * scope: `payrolls:read` */ export function useContractorPaymentsList( request: GetV1CompaniesCompanyIdContractorPaymentsRequest, options?: QueryHookOptions< ContractorPaymentsListQueryData, ContractorPaymentsListQueryError >, ): UseQueryResult< ContractorPaymentsListQueryData, ContractorPaymentsListQueryError > { const client = useGustoEmbeddedContext(); return useQuery({ ...buildContractorPaymentsListQuery( client, request, options, ), ...options, }); } /** * Get contractor payments for a company * * @remarks * Returns an object containing individual contractor payments, within a given time period, including totals. * * Results are returned in reverse chronological order (newest first). * * scope: `payrolls:read` */ export function useContractorPaymentsListSuspense( request: GetV1CompaniesCompanyIdContractorPaymentsRequest, options?: SuspenseQueryHookOptions< ContractorPaymentsListQueryData, ContractorPaymentsListQueryError >, ): UseSuspenseQueryResult< ContractorPaymentsListQueryData, ContractorPaymentsListQueryError > { const client = useGustoEmbeddedContext(); return useSuspenseQuery({ ...buildContractorPaymentsListQuery( client, request, options, ), ...options, }); } export function setContractorPaymentsListData( client: QueryClient, queryKeyBase: [ companyId: string, parameters: { xGustoAPIVersion?: | GetV1CompaniesCompanyIdContractorPaymentsHeaderXGustoAPIVersion | undefined; startDate: string; endDate: string; contractorUuid?: string | undefined; groupByDate?: boolean | undefined; page?: number | undefined; per?: number | undefined; }, ], data: ContractorPaymentsListQueryData, ): ContractorPaymentsListQueryData | undefined { const key = queryKeyContractorPaymentsList(...queryKeyBase); return client.setQueryData(key, data); } export function invalidateContractorPaymentsList( client: QueryClient, queryKeyBase: TupleToPrefixes< [ companyId: string, parameters: { xGustoAPIVersion?: | GetV1CompaniesCompanyIdContractorPaymentsHeaderXGustoAPIVersion | undefined; startDate: string; endDate: string; contractorUuid?: string | undefined; groupByDate?: boolean | undefined; page?: number | undefined; per?: number | undefined; }, ] >, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: [ "@gusto/embedded-api", "contractorPayments", "list", ...queryKeyBase, ], }); } export function invalidateAllContractorPaymentsList( client: QueryClient, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "contractorPayments", "list"], }); }