/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { payrollCancellationsGetV1PayrollBatchesPayrollBatchUuid } from "../funcs/payrollCancellationsGetV1PayrollBatchesPayrollBatchUuid.js"; import { payrollCancellationsPostV1PayrollBatches } from "../funcs/payrollCancellationsPostV1PayrollBatches.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; import { GetV1PayrollBatchesPayrollBatchUuidRequest, GetV1PayrollBatchesPayrollBatchUuidResponse, GetV1PayrollBatchesPayrollBatchUuidSecurity, } from "../models/operations/getv1payrollbatchespayrollbatchuuid.js"; import { PostV1PayrollBatchesRequest, PostV1PayrollBatchesResponse, PostV1PayrollBatchesSecurity, } from "../models/operations/postv1payrollbatches.js"; import { unwrapAsync } from "../types/fp.js"; export class PayrollCancellations extends ClientSDK { /** * Create a payroll cancellation batch * * @remarks * Cancels up to 100 payrolls across one or more companies the partner is mapped to, asynchronously. * * The batch is processed asynchronously. Use the returned batch UUID to poll `GET /v1/payroll_batches/{payroll_batch_uuid}` for status and per-payroll results. * * Each item carries the payroll `uuid` and the `company_uuid` that owns it. A payroll whose company is not mapped to the partner — or that doesn't exist — is recorded as a `not_found` exclusion rather than a hard error, so every requested UUID lands in either `results` or `exclusions`. * * Idempotency is scoped per `(partner, idempotency_key)`. A duplicate POST with the same `idempotency_key` returns a 409 Conflict referencing the existing batch UUID — no duplicate processing occurs. * * 📘 System Access Authentication * * This endpoint uses the [Bearer Auth scheme with the system-level access token in the HTTP Authorization header](https://docs.gusto.com/embedded-payroll/docs/system-access) * * scope: `payroll_batches:write` */ async postV1PayrollBatches( security: PostV1PayrollBatchesSecurity, request: PostV1PayrollBatchesRequest, options?: RequestOptions, ): Promise { return unwrapAsync(payrollCancellationsPostV1PayrollBatches( this, security, request, options, )); } /** * Get a payroll cancellation batch * * @remarks * Returns the status and per-payroll results of a payroll cancellation batch. * * Poll this endpoint until the batch `status` reaches a terminal value (`completed` or `failed`). Once terminal, the response includes the `results` array (one entry per authorized payroll, each with its own per-payroll `status` — `success` or `failed`) and the `exclusions` array (one entry per payroll that could not be processed). A cancel is atomic, so a per-payroll result is only ever `success` or `failed` — never `partial_success`. * * Note that the top-level batch `status` (`pending` / `processing` / `completed` / `failed`) is the request lifecycle, distinct from the per-payroll `status` inside `results[]`. A `completed` batch does not imply every payroll was cancelled — inspect the array for per-payroll outcomes. * * Results are stored in Redis with a limited TTL after completion. If the partner polls after results have expired, this endpoint returns 410 Gone — partners should re-submit a new batch. * * 📘 System Access Authentication * * This endpoint uses the [Bearer Auth scheme with the system-level access token in the HTTP Authorization header](https://docs.gusto.com/embedded-payroll/docs/system-access) * * scope: `payroll_batches:read` */ async getV1PayrollBatchesPayrollBatchUuid( security: GetV1PayrollBatchesPayrollBatchUuidSecurity, request: GetV1PayrollBatchesPayrollBatchUuidRequest, options?: RequestOptions, ): Promise { return unwrapAsync(payrollCancellationsGetV1PayrollBatchesPayrollBatchUuid( this, security, request, options, )); } }