/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { employeeFormsGenerateW2 } from "../funcs/employeeFormsGenerateW2.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 { PostV1SandboxGenerateW2Request, PostV1SandboxGenerateW2Response, } from "../models/operations/postv1sandboxgeneratew2.js"; import { unwrapAsync } from "../types/fp.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type EmployeeFormsGenerateW2MutationVariables = { request: PostV1SandboxGenerateW2Request; options?: RequestOptions; }; export type EmployeeFormsGenerateW2MutationData = PostV1SandboxGenerateW2Response; export type EmployeeFormsGenerateW2MutationError = | NotFoundErrorObject | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Generate a W2 form [DEMO] * * @remarks * > 🚧 Demo action * > * > This action is only available in the Demo environment * * Generates a W2 document for testing purposes. * * scope: `employees:write` */ export function useEmployeeFormsGenerateW2Mutation( options?: MutationHookOptions< EmployeeFormsGenerateW2MutationData, EmployeeFormsGenerateW2MutationError, EmployeeFormsGenerateW2MutationVariables >, ): UseMutationResult< EmployeeFormsGenerateW2MutationData, EmployeeFormsGenerateW2MutationError, EmployeeFormsGenerateW2MutationVariables > { const client = useGustoEmbeddedContext(); return useMutation({ ...buildEmployeeFormsGenerateW2Mutation(client, options), ...options, }); } export function mutationKeyEmployeeFormsGenerateW2(): MutationKey { return ["@gusto/embedded-api", "employeeForms", "generateW2"]; } export function buildEmployeeFormsGenerateW2Mutation( client$: GustoEmbeddedCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: EmployeeFormsGenerateW2MutationVariables, ) => Promise; } { return { mutationKey: mutationKeyEmployeeFormsGenerateW2(), mutationFn: function employeeFormsGenerateW2MutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(employeeFormsGenerateW2( client$, request, mergedOptions, )); }, }; }