/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { reimbursementsPostV1EmployeesEmployeeIdRecurringReimbursements } from "../funcs/reimbursementsPostV1EmployeesEmployeeIdRecurringReimbursements.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 { PostV1EmployeesEmployeeIdRecurringReimbursementsRequest, PostV1EmployeesEmployeeIdRecurringReimbursementsResponse, } from "../models/operations/postv1employeesemployeeidrecurringreimbursements.js"; import { unwrapAsync } from "../types/fp.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type ReimbursementsPostV1EmployeesEmployeeIdRecurringReimbursementsMutationVariables = { request: PostV1EmployeesEmployeeIdRecurringReimbursementsRequest; options?: RequestOptions; }; export type ReimbursementsPostV1EmployeesEmployeeIdRecurringReimbursementsMutationData = PostV1EmployeesEmployeeIdRecurringReimbursementsResponse; export type ReimbursementsPostV1EmployeesEmployeeIdRecurringReimbursementsMutationError = | NotFoundErrorObject | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Create a recurring reimbursement * * @remarks * Create a recurring reimbursement for an employee. * * scope: `reimbursements:write` */ export function useReimbursementsPostV1EmployeesEmployeeIdRecurringReimbursementsMutation( options?: MutationHookOptions< ReimbursementsPostV1EmployeesEmployeeIdRecurringReimbursementsMutationData, ReimbursementsPostV1EmployeesEmployeeIdRecurringReimbursementsMutationError, ReimbursementsPostV1EmployeesEmployeeIdRecurringReimbursementsMutationVariables >, ): UseMutationResult< ReimbursementsPostV1EmployeesEmployeeIdRecurringReimbursementsMutationData, ReimbursementsPostV1EmployeesEmployeeIdRecurringReimbursementsMutationError, ReimbursementsPostV1EmployeesEmployeeIdRecurringReimbursementsMutationVariables > { const client = useGustoEmbeddedContext(); return useMutation({ ...buildReimbursementsPostV1EmployeesEmployeeIdRecurringReimbursementsMutation( client, options, ), ...options, }); } export function mutationKeyReimbursementsPostV1EmployeesEmployeeIdRecurringReimbursements(): MutationKey { return [ "@gusto/embedded-api", "Reimbursements", "postV1EmployeesEmployeeIdRecurringReimbursements", ]; } export function buildReimbursementsPostV1EmployeesEmployeeIdRecurringReimbursementsMutation( client$: GustoEmbeddedCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: ReimbursementsPostV1EmployeesEmployeeIdRecurringReimbursementsMutationVariables, ) => Promise< ReimbursementsPostV1EmployeesEmployeeIdRecurringReimbursementsMutationData >; } { return { mutationKey: mutationKeyReimbursementsPostV1EmployeesEmployeeIdRecurringReimbursements(), mutationFn: function reimbursementsPostV1EmployeesEmployeeIdRecurringReimbursementsMutationFn( { request, options, }, ): Promise< ReimbursementsPostV1EmployeesEmployeeIdRecurringReimbursementsMutationData > { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync( reimbursementsPostV1EmployeesEmployeeIdRecurringReimbursements( client$, request, mergedOptions, ), ); }, }; }