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

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

export type ListFilesOut = {
  data: Array<FileSchema>;
  object: string;
  total?: number | null | undefined;
};

/** @internal */
export const ListFilesOut$inboundSchema: z.ZodType<
  ListFilesOut,
  z.ZodTypeDef,
  unknown
> = z.object({
  data: z.array(FileSchema$inboundSchema),
  object: z.string(),
  total: z.nullable(z.number().int()).optional(),
});

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