/*
 * 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 {
  ModerationObject,
  ModerationObject$inboundSchema,
} from "./moderationobject.js";

export type ModerationResponse = {
  id: string;
  model: string;
  results: Array<ModerationObject>;
};

/** @internal */
export const ModerationResponse$inboundSchema: z.ZodType<
  ModerationResponse,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: z.string(),
  model: z.string(),
  results: z.array(ModerationObject$inboundSchema),
});

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