/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { externalPayrollsCreate } from "../funcs/externalPayrollsCreate.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 { PostV1ExternalPayrollRequest, PostV1ExternalPayrollResponse, } from "../models/operations/postv1externalpayroll.js"; import { unwrapAsync } from "../types/fp.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type ExternalPayrollsCreateMutationVariables = { request: PostV1ExternalPayrollRequest; options?: RequestOptions; }; export type ExternalPayrollsCreateMutationData = PostV1ExternalPayrollResponse; export type ExternalPayrollsCreateMutationError = | NotFoundErrorObject | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Create an external payroll for a company * * @remarks * Creates a new external payroll for a company. * * scope: `external_payrolls:write` */ export function useExternalPayrollsCreateMutation( options?: MutationHookOptions< ExternalPayrollsCreateMutationData, ExternalPayrollsCreateMutationError, ExternalPayrollsCreateMutationVariables >, ): UseMutationResult< ExternalPayrollsCreateMutationData, ExternalPayrollsCreateMutationError, ExternalPayrollsCreateMutationVariables > { const client = useGustoEmbeddedContext(); return useMutation({ ...buildExternalPayrollsCreateMutation(client, options), ...options, }); } export function mutationKeyExternalPayrollsCreate(): MutationKey { return ["@gusto/embedded-api", "externalPayrolls", "create"]; } export function buildExternalPayrollsCreateMutation( client$: GustoEmbeddedCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: ExternalPayrollsCreateMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyExternalPayrollsCreate(), mutationFn: function externalPayrollsCreateMutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(externalPayrollsCreate( client$, request, mergedOptions, )); }, }; }