/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { contractorPaymentsDelete } from "../funcs/contractorPaymentsDelete.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 { DeleteV1CompaniesCompanyIdContractorPaymentContractorPaymentRequest, DeleteV1CompaniesCompanyIdContractorPaymentContractorPaymentResponse, } from "../models/operations/deletev1companiescompanyidcontractorpaymentcontractorpayment.js"; import { unwrapAsync } from "../types/fp.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type ContractorPaymentsDeleteMutationVariables = { request: DeleteV1CompaniesCompanyIdContractorPaymentContractorPaymentRequest; options?: RequestOptions; }; export type ContractorPaymentsDeleteMutationData = DeleteV1CompaniesCompanyIdContractorPaymentContractorPaymentResponse; export type ContractorPaymentsDeleteMutationError = | NotFoundErrorObject | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Cancel a contractor payment * * @remarks * Cancels and deletes a contractor payment. If the contractor payment has already started processing ("may_cancel": true), the payment cannot be cancelled. * * scope: `payrolls:run` */ export function useContractorPaymentsDeleteMutation( options?: MutationHookOptions< ContractorPaymentsDeleteMutationData, ContractorPaymentsDeleteMutationError, ContractorPaymentsDeleteMutationVariables >, ): UseMutationResult< ContractorPaymentsDeleteMutationData, ContractorPaymentsDeleteMutationError, ContractorPaymentsDeleteMutationVariables > { const client = useGustoEmbeddedContext(); return useMutation({ ...buildContractorPaymentsDeleteMutation(client, options), ...options, }); } export function mutationKeyContractorPaymentsDelete(): MutationKey { return ["@gusto/embedded-api", "contractorPayments", "delete"]; } export function buildContractorPaymentsDeleteMutation( client$: GustoEmbeddedCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: ContractorPaymentsDeleteMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyContractorPaymentsDelete(), mutationFn: function contractorPaymentsDeleteMutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(contractorPaymentsDelete( client$, request, mergedOptions, )); }, }; }