/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { payrollsCreateOffCycle } from "../funcs/payrollsCreateOffCycle.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 { PostV1CompaniesCompanyIdPayrollsRequest, PostV1CompaniesCompanyIdPayrollsResponse, } from "../models/operations/postv1companiescompanyidpayrolls.js"; import { unwrapAsync } from "../types/fp.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type PayrollsCreateOffCycleMutationVariables = { request: PostV1CompaniesCompanyIdPayrollsRequest; options?: RequestOptions; }; export type PayrollsCreateOffCycleMutationData = PostV1CompaniesCompanyIdPayrollsResponse; export type PayrollsCreateOffCycleMutationError = | NotFoundErrorObject | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Create an off-cycle payroll * * @remarks * Creates a new, unprocessed, off-cycle payroll. * * ## `off_cycle_reason` * By default: * - External benefits and deductions will be included when the `off_cycle_reason` is set to `Correction`. * - All benefits and deductions are blocked when the `off_cycle_reason` is set to `Bonus`. * * These elections can be overridden with the `skip_regular_deductions` boolean. * * scope: `payrolls:run` */ export function usePayrollsCreateOffCycleMutation( options?: MutationHookOptions< PayrollsCreateOffCycleMutationData, PayrollsCreateOffCycleMutationError, PayrollsCreateOffCycleMutationVariables >, ): UseMutationResult< PayrollsCreateOffCycleMutationData, PayrollsCreateOffCycleMutationError, PayrollsCreateOffCycleMutationVariables > { const client = useGustoEmbeddedContext(); return useMutation({ ...buildPayrollsCreateOffCycleMutation(client, options), ...options, }); } export function mutationKeyPayrollsCreateOffCycle(): MutationKey { return ["@gusto/embedded-api", "Payrolls", "createOffCycle"]; } export function buildPayrollsCreateOffCycleMutation( client$: GustoEmbeddedCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: PayrollsCreateOffCycleMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyPayrollsCreateOffCycle(), mutationFn: function payrollsCreateOffCycleMutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(payrollsCreateOffCycle( client$, request, mergedOptions, )); }, }; }