/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { bankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountId } from "../funcs/bankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountId.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 { DeleteV1CompaniesCompanyIdBankAccountsBankAccountIdRequest, DeleteV1CompaniesCompanyIdBankAccountsBankAccountIdResponse, } from "../models/operations/deletev1companiescompanyidbankaccountsbankaccountid.js"; import { unwrapAsync } from "../types/fp.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type BankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountIdMutationVariables = { request: DeleteV1CompaniesCompanyIdBankAccountsBankAccountIdRequest; options?: RequestOptions; }; export type BankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountIdMutationData = DeleteV1CompaniesCompanyIdBankAccountsBankAccountIdResponse; export type BankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountIdMutationError = | NotFoundErrorObject | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Delete a company bank account * * @remarks * This endpoint disables a company bank account. * * A bank account cannot be disabled if it is used for any unprocessed payments. * * scope: `company_bank_accounts:write` */ export function useBankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountIdMutation( options?: MutationHookOptions< BankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountIdMutationData, BankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountIdMutationError, BankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountIdMutationVariables >, ): UseMutationResult< BankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountIdMutationData, BankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountIdMutationError, BankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountIdMutationVariables > { const client = useGustoEmbeddedContext(); return useMutation({ ...buildBankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountIdMutation( client, options, ), ...options, }); } export function mutationKeyBankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountId(): MutationKey { return [ "@gusto/embedded-api", "bankAccounts", "deleteV1CompaniesCompanyIdBankAccountsBankAccountId", ]; } export function buildBankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountIdMutation( client$: GustoEmbeddedCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: BankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountIdMutationVariables, ) => Promise< BankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountIdMutationData >; } { return { mutationKey: mutationKeyBankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountId(), mutationFn: function bankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountIdMutationFn( { request, options, }, ): Promise< BankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountIdMutationData > { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync( bankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountId( client$, request, mergedOptions, ), ); }, }; }