/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { i9VerificationEmployerSign } from "../funcs/i9VerificationEmployerSign.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 { PutV1EmployeesEmployeeIdI9AuthorizationEmployerSignRequest, PutV1EmployeesEmployeeIdI9AuthorizationEmployerSignResponse, } from "../models/operations/putv1employeesemployeeidi9authorizationemployersign.js"; import { unwrapAsync } from "../types/fp.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type I9VerificationEmployerSignMutationVariables = { request: PutV1EmployeesEmployeeIdI9AuthorizationEmployerSignRequest; options?: RequestOptions; }; export type I9VerificationEmployerSignMutationData = PutV1EmployeesEmployeeIdI9AuthorizationEmployerSignResponse; export type I9VerificationEmployerSignMutationError = | NotFoundErrorObject | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Employer sign an employee's Form I-9 * * @remarks * Sign an employee's Form I-9 as an employer. Once the form is signed, the employee's I-9 authorization is considered complete and cannot be modified. * * ### Prerequisites * Before calling this endpoint: * 1. The employee must have a completed [I-9 authorization](ref:put-v1-employees-employee_id-i9_authorization) * 2. The employee must have signed the Form I-9 * 3. [I-9 verification documents](ref:put-v1-employees-employee_id-i9_authorization-documents) must be submitted * * ### Related guides * - [I-9 employment verification](doc:i-9-employment-verification) * * scope: `i9_authorizations:manage` */ export function useI9VerificationEmployerSignMutation( options?: MutationHookOptions< I9VerificationEmployerSignMutationData, I9VerificationEmployerSignMutationError, I9VerificationEmployerSignMutationVariables >, ): UseMutationResult< I9VerificationEmployerSignMutationData, I9VerificationEmployerSignMutationError, I9VerificationEmployerSignMutationVariables > { const client = useGustoEmbeddedContext(); return useMutation({ ...buildI9VerificationEmployerSignMutation(client, options), ...options, }); } export function mutationKeyI9VerificationEmployerSign(): MutationKey { return ["@gusto/embedded-api", "i9Verification", "employerSign"]; } export function buildI9VerificationEmployerSignMutation( client$: GustoEmbeddedCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: I9VerificationEmployerSignMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyI9VerificationEmployerSign(), mutationFn: function i9VerificationEmployerSignMutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(i9VerificationEmployerSign( client$, request, mergedOptions, )); }, }; }