/* * 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 { UnprocessableEntityError } from "../models/errors/unprocessableentityerror.js"; import { GetV1CompaniesCompanyIdPayPeriodsHeaderXGustoAPIVersion, GetV1CompaniesCompanyIdPayPeriodsRequest, PayrollTypes, } from "../models/operations/getv1companiescompanyidpayperiods.js"; import { RFCDate } from "../types/rfcdate.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes, } from "./_types.js"; import { buildPaySchedulesGetPayPeriodsQuery, PaySchedulesGetPayPeriodsQueryData, prefetchPaySchedulesGetPayPeriods, queryKeyPaySchedulesGetPayPeriods, } from "./paySchedulesGetPayPeriods.core.js"; export { buildPaySchedulesGetPayPeriodsQuery, type PaySchedulesGetPayPeriodsQueryData, prefetchPaySchedulesGetPayPeriods, queryKeyPaySchedulesGetPayPeriods, }; export type PaySchedulesGetPayPeriodsQueryError = | NotFoundErrorObject | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Get pay periods for a company * * @remarks * Pay periods are the foundation of payroll. Compensation, time & attendance, taxes, and expense reports all rely on when they happened. * * To begin submitting information for a given payroll, we need to agree on the time period. * * By default, this endpoint returns pay periods starting from 6 months ago to the date today. Use the `start_date` and `end_date` parameters to change the scope of the response. End dates can be up to 3 months in the future and there is no limit on start dates. * * Starting in version 2023-04-01, the `eligible_employees` attribute was removed from the response. The eligible employees for a payroll are determined by the employee_compensations returned from the [PUT /v1/companies/{company_id}/payrolls/{payroll_id}/prepare](ref:put-v1-companies-company_id-payrolls-payroll_id-prepare) endpoint. * * scope: `payrolls:read` */ export function usePaySchedulesGetPayPeriods( request: GetV1CompaniesCompanyIdPayPeriodsRequest, options?: QueryHookOptions< PaySchedulesGetPayPeriodsQueryData, PaySchedulesGetPayPeriodsQueryError >, ): UseQueryResult< PaySchedulesGetPayPeriodsQueryData, PaySchedulesGetPayPeriodsQueryError > { const client = useGustoEmbeddedContext(); return useQuery({ ...buildPaySchedulesGetPayPeriodsQuery( client, request, options, ), ...options, }); } /** * Get pay periods for a company * * @remarks * Pay periods are the foundation of payroll. Compensation, time & attendance, taxes, and expense reports all rely on when they happened. * * To begin submitting information for a given payroll, we need to agree on the time period. * * By default, this endpoint returns pay periods starting from 6 months ago to the date today. Use the `start_date` and `end_date` parameters to change the scope of the response. End dates can be up to 3 months in the future and there is no limit on start dates. * * Starting in version 2023-04-01, the `eligible_employees` attribute was removed from the response. The eligible employees for a payroll are determined by the employee_compensations returned from the [PUT /v1/companies/{company_id}/payrolls/{payroll_id}/prepare](ref:put-v1-companies-company_id-payrolls-payroll_id-prepare) endpoint. * * scope: `payrolls:read` */ export function usePaySchedulesGetPayPeriodsSuspense( request: GetV1CompaniesCompanyIdPayPeriodsRequest, options?: SuspenseQueryHookOptions< PaySchedulesGetPayPeriodsQueryData, PaySchedulesGetPayPeriodsQueryError >, ): UseSuspenseQueryResult< PaySchedulesGetPayPeriodsQueryData, PaySchedulesGetPayPeriodsQueryError > { const client = useGustoEmbeddedContext(); return useSuspenseQuery({ ...buildPaySchedulesGetPayPeriodsQuery( client, request, options, ), ...options, }); } export function setPaySchedulesGetPayPeriodsData( client: QueryClient, queryKeyBase: [ companyId: string, parameters: { xGustoAPIVersion?: | GetV1CompaniesCompanyIdPayPeriodsHeaderXGustoAPIVersion | undefined; startDate?: RFCDate | undefined; endDate?: RFCDate | undefined; payrollTypes?: PayrollTypes | undefined; }, ], data: PaySchedulesGetPayPeriodsQueryData, ): PaySchedulesGetPayPeriodsQueryData | undefined { const key = queryKeyPaySchedulesGetPayPeriods(...queryKeyBase); return client.setQueryData(key, data); } export function invalidatePaySchedulesGetPayPeriods( client: QueryClient, queryKeyBase: TupleToPrefixes< [ companyId: string, parameters: { xGustoAPIVersion?: | GetV1CompaniesCompanyIdPayPeriodsHeaderXGustoAPIVersion | undefined; startDate?: RFCDate | undefined; endDate?: RFCDate | undefined; payrollTypes?: PayrollTypes | undefined; }, ] >, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: [ "@gusto/embedded-api", "paySchedules", "getPayPeriods", ...queryKeyBase, ], }); } export function invalidateAllPaySchedulesGetPayPeriods( client: QueryClient, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "paySchedules", "getPayPeriods"], }); }