/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { i9VerificationCreateDocuments } from "../funcs/i9VerificationCreateDocuments.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 { PutV1EmployeesEmployeeIdI9AuthorizationDocumentsRequest, PutV1EmployeesEmployeeIdI9AuthorizationDocumentsResponse, } from "../models/operations/putv1employeesemployeeidi9authorizationdocuments.js"; import { unwrapAsync } from "../types/fp.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type I9VerificationCreateDocumentsMutationVariables = { request: PutV1EmployeesEmployeeIdI9AuthorizationDocumentsRequest; options?: RequestOptions; }; export type I9VerificationCreateDocumentsMutationData = PutV1EmployeesEmployeeIdI9AuthorizationDocumentsResponse; export type I9VerificationCreateDocumentsMutationError = | NotFoundErrorObject | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Create an employee's I-9 authorization verification documents * * @remarks * An employee's I-9 verification documents are the documents an employee has provided the employer to verify their identity and authorization to work in the United States. * * Use the [document options endpoint](ref:get-v1-employees-employee_id-i9_authorization-document_options) to get the possible document types and titles, which can vary depending on the employee's authorization status. * * > 🚧 Every request must contain the complete list of documents for the Employee. * > * > Every request to this endpoint removes any previous verification document records for the employee. * * ### Related guides * - [I-9 employment verification](doc:i-9-employment-verification) * * scope: `i9_authorizations:manage` */ export function useI9VerificationCreateDocumentsMutation( options?: MutationHookOptions< I9VerificationCreateDocumentsMutationData, I9VerificationCreateDocumentsMutationError, I9VerificationCreateDocumentsMutationVariables >, ): UseMutationResult< I9VerificationCreateDocumentsMutationData, I9VerificationCreateDocumentsMutationError, I9VerificationCreateDocumentsMutationVariables > { const client = useGustoEmbeddedContext(); return useMutation({ ...buildI9VerificationCreateDocumentsMutation(client, options), ...options, }); } export function mutationKeyI9VerificationCreateDocuments(): MutationKey { return ["@gusto/embedded-api", "i9Verification", "createDocuments"]; } export function buildI9VerificationCreateDocumentsMutation( client$: GustoEmbeddedCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: I9VerificationCreateDocumentsMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyI9VerificationCreateDocuments(), mutationFn: function i9VerificationCreateDocumentsMutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(i9VerificationCreateDocuments( client$, request, mergedOptions, )); }, }; }