/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { safeParse } from "../../lib/schemas.js";
import { ClosedEnum } from "../../types/enums.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import { BatchJobOut, BatchJobOut$inboundSchema } from "./batchjobout.js";

export const BatchJobsOutObject = {
  List: "list",
} as const;
export type BatchJobsOutObject = ClosedEnum<typeof BatchJobsOutObject>;

export type BatchJobsOut = {
  data?: Array<BatchJobOut> | undefined;
  object: BatchJobsOutObject | undefined;
  total: number;
};

/** @internal */
export const BatchJobsOutObject$inboundSchema: z.ZodNativeEnum<
  typeof BatchJobsOutObject
> = z.nativeEnum(BatchJobsOutObject);

/** @internal */
export const BatchJobsOut$inboundSchema: z.ZodType<
  BatchJobsOut,
  z.ZodTypeDef,
  unknown
> = z.object({
  data: z.array(BatchJobOut$inboundSchema).optional(),
  object: BatchJobsOutObject$inboundSchema.default("list"),
  total: z.number().int(),
});

export function batchJobsOutFromJSON(
  jsonString: string,
): SafeParseResult<BatchJobsOut, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => BatchJobsOut$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'BatchJobsOut' from JSON`,
  );
}
