/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { companyAttachmentsCreate } from "../funcs/companyAttachmentsCreate.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 { PostV1CompaniesAttachmentRequest, PostV1CompaniesAttachmentResponse, } from "../models/operations/postv1companiesattachment.js"; import { unwrapAsync } from "../types/fp.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type CompanyAttachmentsCreateMutationVariables = { request: PostV1CompaniesAttachmentRequest; options?: RequestOptions; }; export type CompanyAttachmentsCreateMutationData = PostV1CompaniesAttachmentResponse; export type CompanyAttachmentsCreateMutationError = | NotFoundErrorObject | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Create Company Attachment and Upload File * * @remarks * Upload a file and create a company attachment. We recommend uploading PDF files for optimal compatibility. However, the following file types are allowed: .qbb, .qbm, .gif, .jpg, .png, .pdf, .xls, .xlsx, .doc and .docx. * * ### Related guides * - [Manage company attachments](doc:manage-company-attachments) * * scope: `company_attachments:write` */ export function useCompanyAttachmentsCreateMutation( options?: MutationHookOptions< CompanyAttachmentsCreateMutationData, CompanyAttachmentsCreateMutationError, CompanyAttachmentsCreateMutationVariables >, ): UseMutationResult< CompanyAttachmentsCreateMutationData, CompanyAttachmentsCreateMutationError, CompanyAttachmentsCreateMutationVariables > { const client = useGustoEmbeddedContext(); return useMutation({ ...buildCompanyAttachmentsCreateMutation(client, options), ...options, }); } export function mutationKeyCompanyAttachmentsCreate(): MutationKey { return ["@gusto/embedded-api", "companyAttachments", "create"]; } export function buildCompanyAttachmentsCreateMutation( client$: GustoEmbeddedCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: CompanyAttachmentsCreateMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyCompanyAttachmentsCreate(), mutationFn: function companyAttachmentsCreateMutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(companyAttachmentsCreate( client$, request, mergedOptions, )); }, }; }