/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { payrollDigestsPostV1PayrollDigests } from "../funcs/payrollDigestsPostV1PayrollDigests.js"; import { combineSignals } from "../lib/primitives.js"; import { RequestOptions } from "../lib/sdks.js"; import { GustoEmbeddedError } from "../models/errors/gustoembeddederror.js"; import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; import { PayrollDigestConflictError } from "../models/errors/payrolldigestconflicterror.js"; import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import { UnprocessableEntityError } from "../models/errors/unprocessableentityerror.js"; import { PostV1PayrollDigestsRequest, PostV1PayrollDigestsResponse, PostV1PayrollDigestsSecurity, } from "../models/operations/postv1payrolldigests.js"; import { unwrapAsync } from "../types/fp.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type PayrollDigestsPostV1PayrollDigestsMutationVariables = { security: PostV1PayrollDigestsSecurity; request: PostV1PayrollDigestsRequest; options?: RequestOptions; }; export type PayrollDigestsPostV1PayrollDigestsMutationData = PostV1PayrollDigestsResponse; export type PayrollDigestsPostV1PayrollDigestsMutationError = | PayrollDigestConflictError | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Create a payroll digest batch * * @remarks * Triggers an asynchronous computation of payroll digest data (statuses, blockers, pay periods, totals) across up to 25 companies that the partner is mapped to. * * The batch is processed asynchronously. Use the returned batch UUID to poll `GET /v1/payroll_digests/{payroll_digest_uuid}` for status and results. * * Idempotency is scoped per `(partner, idempotency_key)`. A duplicate POST with the same `idempotency_key` returns a 409 Conflict referencing the existing batch UUID — no duplicate computation occurs. * * 📘 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: `payroll_digests:write` */ export function usePayrollDigestsPostV1PayrollDigestsMutation( options?: MutationHookOptions< PayrollDigestsPostV1PayrollDigestsMutationData, PayrollDigestsPostV1PayrollDigestsMutationError, PayrollDigestsPostV1PayrollDigestsMutationVariables >, ): UseMutationResult< PayrollDigestsPostV1PayrollDigestsMutationData, PayrollDigestsPostV1PayrollDigestsMutationError, PayrollDigestsPostV1PayrollDigestsMutationVariables > { const client = useGustoEmbeddedContext(); return useMutation({ ...buildPayrollDigestsPostV1PayrollDigestsMutation(client, options), ...options, }); } export function mutationKeyPayrollDigestsPostV1PayrollDigests(): MutationKey { return ["@gusto/embedded-api", "Payroll Digests", "postV1PayrollDigests"]; } export function buildPayrollDigestsPostV1PayrollDigestsMutation( client$: GustoEmbeddedCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: PayrollDigestsPostV1PayrollDigestsMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyPayrollDigestsPostV1PayrollDigests(), mutationFn: function payrollDigestsPostV1PayrollDigestsMutationFn({ security, request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(payrollDigestsPostV1PayrollDigests( client$, security, request, mergedOptions, )); }, }; }