/* * 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 { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import { UnprocessableEntityError } from "../models/errors/unprocessableentityerror.js"; import { GetInvoicesInvoicePeriodHeaderXGustoAPIVersion, GetInvoicesInvoicePeriodRequest, GetInvoicesInvoicePeriodSecurity, } from "../models/operations/getinvoicesinvoiceperiod.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { QueryHookOptions, SuspenseQueryHookOptions, TupleToPrefixes, } from "./_types.js"; import { buildInvoicesGetQuery, InvoicesGetQueryData, prefetchInvoicesGet, queryKeyInvoicesGet, } from "./invoicesGet.core.js"; export { buildInvoicesGetQuery, type InvoicesGetQueryData, prefetchInvoicesGet, queryKeyInvoicesGet, }; export type InvoicesGetQueryError = | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Retrieve invoicing data for companies * * @remarks * Retrieve data for active companies used to calculate invoices for Gusto Embedded Payroll. A company is considered active for an invoice period if they are an active partner managed company, have run payroll or created contractor payments since becoming a partner managed company, and are not suspended at any point during the invoice period. This endpoint forces pagination, with 100 results returned at a time. You can learn more about our pagination here: [pagination guide](https://docs.gusto.com/embedded-payroll/docs/pagination) * * 📘 System Access Authentication * * This endpoint uses the [Bearer Auth scheme with the system-level access token in the HTTP Authorization header](https://docs.gusto.com/embedded-payroll/docs/system-access) * * scope: `invoices:read` */ export function useInvoicesGet( security: GetInvoicesInvoicePeriodSecurity, request: GetInvoicesInvoicePeriodRequest, options?: QueryHookOptions, ): UseQueryResult { const client = useGustoEmbeddedContext(); return useQuery({ ...buildInvoicesGetQuery( client, security, request, options, ), ...options, }); } /** * Retrieve invoicing data for companies * * @remarks * Retrieve data for active companies used to calculate invoices for Gusto Embedded Payroll. A company is considered active for an invoice period if they are an active partner managed company, have run payroll or created contractor payments since becoming a partner managed company, and are not suspended at any point during the invoice period. This endpoint forces pagination, with 100 results returned at a time. You can learn more about our pagination here: [pagination guide](https://docs.gusto.com/embedded-payroll/docs/pagination) * * 📘 System Access Authentication * * This endpoint uses the [Bearer Auth scheme with the system-level access token in the HTTP Authorization header](https://docs.gusto.com/embedded-payroll/docs/system-access) * * scope: `invoices:read` */ export function useInvoicesGetSuspense( security: GetInvoicesInvoicePeriodSecurity, request: GetInvoicesInvoicePeriodRequest, options?: SuspenseQueryHookOptions< InvoicesGetQueryData, InvoicesGetQueryError >, ): UseSuspenseQueryResult { const client = useGustoEmbeddedContext(); return useSuspenseQuery({ ...buildInvoicesGetQuery( client, security, request, options, ), ...options, }); } export function setInvoicesGetData( client: QueryClient, queryKeyBase: [ invoicePeriod: string, parameters: { xGustoAPIVersion?: | GetInvoicesInvoicePeriodHeaderXGustoAPIVersion | undefined; page?: number | undefined; per?: number | undefined; companyUuids?: string | undefined; }, ], data: InvoicesGetQueryData, ): InvoicesGetQueryData | undefined { const key = queryKeyInvoicesGet(...queryKeyBase); return client.setQueryData(key, data); } export function invalidateInvoicesGet( client: QueryClient, queryKeyBase: TupleToPrefixes< [ invoicePeriod: string, parameters: { xGustoAPIVersion?: | GetInvoicesInvoicePeriodHeaderXGustoAPIVersion | undefined; page?: number | undefined; per?: number | undefined; companyUuids?: string | undefined; }, ] >, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "Invoices", "get", ...queryKeyBase], }); } export function invalidateAllInvoicesGet( client: QueryClient, filters?: Omit, ): Promise { return client.invalidateQueries({ ...filters, queryKey: ["@gusto/embedded-api", "Invoices", "get"], }); }