/*
 * 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 ExperimentAllocationRep = {
  defaultVariation: number;
  canReshuffle: boolean;
};

/** @internal */
export const ExperimentAllocationRep$inboundSchema: z.ZodType<
  ExperimentAllocationRep,
  z.ZodTypeDef,
  unknown
> = z.object({
  defaultVariation: z.number().int(),
  canReshuffle: z.boolean(),
});
/** @internal */
export type ExperimentAllocationRep$Outbound = {
  defaultVariation: number;
  canReshuffle: boolean;
};

/** @internal */
export const ExperimentAllocationRep$outboundSchema: z.ZodType<
  ExperimentAllocationRep$Outbound,
  z.ZodTypeDef,
  ExperimentAllocationRep
> = z.object({
  defaultVariation: z.number().int(),
  canReshuffle: z.boolean(),
});

export function experimentAllocationRepToJSON(
  experimentAllocationRep: ExperimentAllocationRep,
): string {
  return JSON.stringify(
    ExperimentAllocationRep$outboundSchema.parse(experimentAllocationRep),
  );
}
export function experimentAllocationRepFromJSON(
  jsonString: string,
): SafeParseResult<ExperimentAllocationRep, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ExperimentAllocationRep$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ExperimentAllocationRep' from JSON`,
  );
}
