/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { bankAccountsVerify } from "../funcs/bankAccountsVerify.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 { PutV1CompaniesCompanyIdBankAccountsVerifyRequest, PutV1CompaniesCompanyIdBankAccountsVerifyResponse, } from "../models/operations/putv1companiescompanyidbankaccountsverify.js"; import { unwrapAsync } from "../types/fp.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type BankAccountsVerifyMutationVariables = { request: PutV1CompaniesCompanyIdBankAccountsVerifyRequest; options?: RequestOptions; }; export type BankAccountsVerifyMutationData = PutV1CompaniesCompanyIdBankAccountsVerifyResponse; export type BankAccountsVerifyMutationError = | NotFoundErrorObject | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Verify a company bank account * * @remarks * Verify a company bank account by confirming the two micro-deposits sent to the bank account. * * Note that the order of the two deposits specified in request parameters does not matter. * There's a maximum of 5 verification attempts, after which we will automatically initiate a new set of micro-deposits and require the bank account to be verified with the new micro-deposits. * * ### Bank account verification in demo * In the demo environment, use the `POST /v1/companies/{company_id}/bank_accounts/{bank_account_uuid}/send_test_deposits` endpoint to simulate the micro-deposits transfer and return the two amounts in the response. You can call this endpoint as many times as you wish to retrieve the values of the two micro-deposits. * * ### Webhooks * - `company.bank_account.verified`: Fires when the company bank account is successfully verified. * * ### Related guides * - [Manage company bank accounts](doc:manage-company-bank-accounts) * - [Bank Account Events](doc:bank-account-events) * * scope: `company_bank_accounts:write` */ export function useBankAccountsVerifyMutation( options?: MutationHookOptions< BankAccountsVerifyMutationData, BankAccountsVerifyMutationError, BankAccountsVerifyMutationVariables >, ): UseMutationResult< BankAccountsVerifyMutationData, BankAccountsVerifyMutationError, BankAccountsVerifyMutationVariables > { const client = useGustoEmbeddedContext(); return useMutation({ ...buildBankAccountsVerifyMutation(client, options), ...options, }); } export function mutationKeyBankAccountsVerify(): MutationKey { return ["@gusto/embedded-api", "bankAccounts", "verify"]; } export function buildBankAccountsVerifyMutation( client$: GustoEmbeddedCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: BankAccountsVerifyMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyBankAccountsVerify(), mutationFn: function bankAccountsVerifyMutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(bankAccountsVerify( client$, request, mergedOptions, )); }, }; }