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

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

export type ModerationObject = {
  /**
   * Moderation result thresholds
   */
  categories?: { [k: string]: boolean } | undefined;
  /**
   * Moderation result
   */
  categoryScores?: { [k: string]: number } | undefined;
};

/** @internal */
export const ModerationObject$inboundSchema: z.ZodType<
  ModerationObject,
  z.ZodTypeDef,
  unknown
> = z.object({
  categories: z.record(z.boolean()).optional(),
  category_scores: z.record(z.number()).optional(),
}).transform((v) => {
  return remap$(v, {
    "category_scores": "categoryScores",
  });
});

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