/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { employeeBenefitsDelete } from "../funcs/employeeBenefitsDelete.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 { DeleteV1EmployeeBenefitsEmployeeBenefitIdRequest, DeleteV1EmployeeBenefitsEmployeeBenefitIdResponse, } from "../models/operations/deletev1employeebenefitsemployeebenefitid.js"; import { unwrapAsync } from "../types/fp.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type EmployeeBenefitsDeleteMutationVariables = { request: DeleteV1EmployeeBenefitsEmployeeBenefitIdRequest; options?: RequestOptions; }; export type EmployeeBenefitsDeleteMutationData = DeleteV1EmployeeBenefitsEmployeeBenefitIdResponse; export type EmployeeBenefitsDeleteMutationError = | NotFoundErrorObject | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Delete an employee benefit * * @remarks * Employee benefits represent an employee enrolled in a particular company benefit. It includes information specific to that employee's enrollment. * * When the application has the `employee_benefits:write:benefit_type_limited` data scope, the application can only delete employee benefits for benefit types that are permitted for the application. * * scope: `employee_benefits:write` */ export function useEmployeeBenefitsDeleteMutation( options?: MutationHookOptions< EmployeeBenefitsDeleteMutationData, EmployeeBenefitsDeleteMutationError, EmployeeBenefitsDeleteMutationVariables >, ): UseMutationResult< EmployeeBenefitsDeleteMutationData, EmployeeBenefitsDeleteMutationError, EmployeeBenefitsDeleteMutationVariables > { const client = useGustoEmbeddedContext(); return useMutation({ ...buildEmployeeBenefitsDeleteMutation(client, options), ...options, }); } export function mutationKeyEmployeeBenefitsDelete(): MutationKey { return ["@gusto/embedded-api", "employeeBenefits", "delete"]; } export function buildEmployeeBenefitsDeleteMutation( client$: GustoEmbeddedCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: EmployeeBenefitsDeleteMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyEmployeeBenefitsDelete(), mutationFn: function employeeBenefitsDeleteMutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(employeeBenefitsDelete( client$, request, mergedOptions, )); }, }; }