/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { paymentConfigsUpdate } from "../funcs/paymentConfigsUpdate.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 { PutV1CompanyPaymentConfigsRequest, PutV1CompanyPaymentConfigsResponse, } from "../models/operations/putv1companypaymentconfigs.js"; import { unwrapAsync } from "../types/fp.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type PaymentConfigsUpdateMutationVariables = { request: PutV1CompanyPaymentConfigsRequest; options?: RequestOptions; }; export type PaymentConfigsUpdateMutationData = PutV1CompanyPaymentConfigsResponse; export type PaymentConfigsUpdateMutationError = | NotFoundErrorObject | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Update a company's payment configs * * @remarks * Update payment speed, fast payment limit, and/or partner-owned disbursement for a company. * * At least one of `payment_speed`, `fast_payment_limit`, or `partner_owned_disbursement` is required. * 1-day payment speed is only applicable to partners that opt in. 1-day is not allowed when AutoPilot is enabled. * * ### Related guides * - [Payroll Processing Speeds](doc:2-day-vs-4-day) * * scope: `company_payment_configs:write` */ export function usePaymentConfigsUpdateMutation( options?: MutationHookOptions< PaymentConfigsUpdateMutationData, PaymentConfigsUpdateMutationError, PaymentConfigsUpdateMutationVariables >, ): UseMutationResult< PaymentConfigsUpdateMutationData, PaymentConfigsUpdateMutationError, PaymentConfigsUpdateMutationVariables > { const client = useGustoEmbeddedContext(); return useMutation({ ...buildPaymentConfigsUpdateMutation(client, options), ...options, }); } export function mutationKeyPaymentConfigsUpdate(): MutationKey { return ["@gusto/embedded-api", "paymentConfigs", "update"]; } export function buildPaymentConfigsUpdateMutation( client$: GustoEmbeddedCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: PaymentConfigsUpdateMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyPaymentConfigsUpdate(), mutationFn: function paymentConfigsUpdateMutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(paymentConfigsUpdate( client$, request, mergedOptions, )); }, }; }