/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { peopleBatchesPostV1CompaniesCompanyIdPeopleBatches } from "../funcs/peopleBatchesPostV1CompaniesCompanyIdPeopleBatches.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 { PeopleBatchConflictError } from "../models/errors/peoplebatchconflicterror.js"; import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import { UnprocessableEntityError } from "../models/errors/unprocessableentityerror.js"; import { PostV1CompaniesCompanyIdPeopleBatchesRequest, PostV1CompaniesCompanyIdPeopleBatchesResponse, } from "../models/operations/postv1companiescompanyidpeoplebatches.js"; import { unwrapAsync } from "../types/fp.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type PeopleBatchesPostV1CompaniesCompanyIdPeopleBatchesMutationVariables = { request: PostV1CompaniesCompanyIdPeopleBatchesRequest; options?: RequestOptions; }; export type PeopleBatchesPostV1CompaniesCompanyIdPeopleBatchesMutationData = PostV1CompaniesCompanyIdPeopleBatchesResponse; export type PeopleBatchesPostV1CompaniesCompanyIdPeopleBatchesMutationError = | NotFoundErrorObject | PeopleBatchConflictError | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Create a people batch * * @remarks * Creates a batch for bulk employee creation. * * The batch is processed asynchronously. Use the returned batch UUID to poll for status and results. * * scope: `people_batches:write` */ export function usePeopleBatchesPostV1CompaniesCompanyIdPeopleBatchesMutation( options?: MutationHookOptions< PeopleBatchesPostV1CompaniesCompanyIdPeopleBatchesMutationData, PeopleBatchesPostV1CompaniesCompanyIdPeopleBatchesMutationError, PeopleBatchesPostV1CompaniesCompanyIdPeopleBatchesMutationVariables >, ): UseMutationResult< PeopleBatchesPostV1CompaniesCompanyIdPeopleBatchesMutationData, PeopleBatchesPostV1CompaniesCompanyIdPeopleBatchesMutationError, PeopleBatchesPostV1CompaniesCompanyIdPeopleBatchesMutationVariables > { const client = useGustoEmbeddedContext(); return useMutation({ ...buildPeopleBatchesPostV1CompaniesCompanyIdPeopleBatchesMutation( client, options, ), ...options, }); } export function mutationKeyPeopleBatchesPostV1CompaniesCompanyIdPeopleBatches(): MutationKey { return [ "@gusto/embedded-api", "People Batches", "postV1CompaniesCompanyIdPeopleBatches", ]; } export function buildPeopleBatchesPostV1CompaniesCompanyIdPeopleBatchesMutation( client$: GustoEmbeddedCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: PeopleBatchesPostV1CompaniesCompanyIdPeopleBatchesMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyPeopleBatchesPostV1CompaniesCompanyIdPeopleBatches(), mutationFn: function peopleBatchesPostV1CompaniesCompanyIdPeopleBatchesMutationFn({ request, options, }): Promise< PeopleBatchesPostV1CompaniesCompanyIdPeopleBatchesMutationData > { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(peopleBatchesPostV1CompaniesCompanyIdPeopleBatches( client$, request, mergedOptions, )); }, }; }