/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { reportsPostPayrollsPayrollUuidReportsGeneralLedger } from "../funcs/reportsPostPayrollsPayrollUuidReportsGeneralLedger.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 { PostPayrollsPayrollUuidReportsGeneralLedgerRequest, PostPayrollsPayrollUuidReportsGeneralLedgerResponse, } from "../models/operations/postpayrollspayrolluuidreportsgeneralledger.js"; import { unwrapAsync } from "../types/fp.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type ReportsPostPayrollsPayrollUuidReportsGeneralLedgerMutationVariables = { request: PostPayrollsPayrollUuidReportsGeneralLedgerRequest; options?: RequestOptions; }; export type ReportsPostPayrollsPayrollUuidReportsGeneralLedgerMutationData = PostPayrollsPayrollUuidReportsGeneralLedgerResponse; export type ReportsPostPayrollsPayrollUuidReportsGeneralLedgerMutationError = | NotFoundErrorObject | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Create a general ledger report * * @remarks * Create a general ledger report for a payroll. The report can be aggregated by different dimensions such as job or department. * * Use the `request_uuid` in the response with the [report GET endpoint](../reference/get-reports-request_uuid) to poll for the status and report URL upon completion. The retrieved report will be generated in a JSON format. * * scope: `company_reports:write` */ export function useReportsPostPayrollsPayrollUuidReportsGeneralLedgerMutation( options?: MutationHookOptions< ReportsPostPayrollsPayrollUuidReportsGeneralLedgerMutationData, ReportsPostPayrollsPayrollUuidReportsGeneralLedgerMutationError, ReportsPostPayrollsPayrollUuidReportsGeneralLedgerMutationVariables >, ): UseMutationResult< ReportsPostPayrollsPayrollUuidReportsGeneralLedgerMutationData, ReportsPostPayrollsPayrollUuidReportsGeneralLedgerMutationError, ReportsPostPayrollsPayrollUuidReportsGeneralLedgerMutationVariables > { const client = useGustoEmbeddedContext(); return useMutation({ ...buildReportsPostPayrollsPayrollUuidReportsGeneralLedgerMutation( client, options, ), ...options, }); } export function mutationKeyReportsPostPayrollsPayrollUuidReportsGeneralLedger(): MutationKey { return [ "@gusto/embedded-api", "Reports", "postPayrollsPayrollUuidReportsGeneralLedger", ]; } export function buildReportsPostPayrollsPayrollUuidReportsGeneralLedgerMutation( client$: GustoEmbeddedCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: ReportsPostPayrollsPayrollUuidReportsGeneralLedgerMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyReportsPostPayrollsPayrollUuidReportsGeneralLedger(), mutationFn: function reportsPostPayrollsPayrollUuidReportsGeneralLedgerMutationFn({ request, options, }): Promise< ReportsPostPayrollsPayrollUuidReportsGeneralLedgerMutationData > { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(reportsPostPayrollsPayrollUuidReportsGeneralLedger( client$, request, mergedOptions, )); }, }; }