/*
 * 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";

export type AiConfigsMetricEventDefaultRep = {
  /**
   * Whether to disable defaulting missing unit events when calculating results. Defaults to false
   */
  disabled?: boolean | undefined;
  /**
   * The default value applied to missing unit events. Set to 0 when <code>disabled</code> is false. No other values are currently supported.
   */
  value?: number | undefined;
};

/** @internal */
export const AiConfigsMetricEventDefaultRep$inboundSchema: z.ZodType<
  AiConfigsMetricEventDefaultRep,
  z.ZodTypeDef,
  unknown
> = z.object({
  disabled: z.boolean().optional(),
  value: z.number().optional(),
});
/** @internal */
export type AiConfigsMetricEventDefaultRep$Outbound = {
  disabled?: boolean | undefined;
  value?: number | undefined;
};

/** @internal */
export const AiConfigsMetricEventDefaultRep$outboundSchema: z.ZodType<
  AiConfigsMetricEventDefaultRep$Outbound,
  z.ZodTypeDef,
  AiConfigsMetricEventDefaultRep
> = z.object({
  disabled: z.boolean().optional(),
  value: z.number().optional(),
});

export function aiConfigsMetricEventDefaultRepToJSON(
  aiConfigsMetricEventDefaultRep: AiConfigsMetricEventDefaultRep,
): string {
  return JSON.stringify(
    AiConfigsMetricEventDefaultRep$outboundSchema.parse(
      aiConfigsMetricEventDefaultRep,
    ),
  );
}
export function aiConfigsMetricEventDefaultRepFromJSON(
  jsonString: string,
): SafeParseResult<AiConfigsMetricEventDefaultRep, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => AiConfigsMetricEventDefaultRep$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'AiConfigsMetricEventDefaultRep' from JSON`,
  );
}
