/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { payrollsUpdate } from "../funcs/payrollsUpdate.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 { 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 { PutV1CompaniesCompanyIdPayrollsRequest, PutV1CompaniesCompanyIdPayrollsResponse, } from "../models/operations/putv1companiescompanyidpayrolls.js"; import { unwrapAsync } from "../types/fp.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type PayrollsUpdateMutationVariables = { request: PutV1CompaniesCompanyIdPayrollsRequest; options?: RequestOptions; }; export type PayrollsUpdateMutationData = PutV1CompaniesCompanyIdPayrollsResponse; export type PayrollsUpdateMutationError = | NotFoundErrorObject | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Update a payroll by ID * * @remarks * This endpoint allows you to update information for one or more employees for a specific **unprocessed** payroll. You can think of the **unprocessed** * payroll object as a template of fields that you can update. You cannot modify the structure of the payroll object through this endpoint, only values * of the fields included in the payroll. If you do not include specific employee compensations, fixed/hourly compensations, or deductions in your request body, they * will not be removed from the payroll. A maximum of 100 employee_compensations can be updated at a time. Only the employee compensation objects that were * inputted will be returned. * * scope: `payrolls:write` */ export function usePayrollsUpdateMutation( options?: MutationHookOptions< PayrollsUpdateMutationData, PayrollsUpdateMutationError, PayrollsUpdateMutationVariables >, ): UseMutationResult< PayrollsUpdateMutationData, PayrollsUpdateMutationError, PayrollsUpdateMutationVariables > { const client = useGustoEmbeddedContext(); return useMutation({ ...buildPayrollsUpdateMutation(client, options), ...options, }); } export function mutationKeyPayrollsUpdate(): MutationKey { return ["@gusto/embedded-api", "Payrolls", "update"]; } export function buildPayrollsUpdateMutation( client$: GustoEmbeddedCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: PayrollsUpdateMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyPayrollsUpdate(), mutationFn: function payrollsUpdateMutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(payrollsUpdate( client$, request, mergedOptions, )); }, }; }