/*
 * 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 * as components from "../components/index.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type CreateIterationRequest = {
  /**
   * The project key
   */
  projectKey: string;
  /**
   * The environment key
   */
  environmentKey: string;
  /**
   * The experiment key
   */
  experimentKey: string;
  iterationInput: components.IterationInput;
};

/** @internal */
export const CreateIterationRequest$inboundSchema: z.ZodType<
  CreateIterationRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  projectKey: z.string(),
  environmentKey: z.string(),
  experimentKey: z.string(),
  IterationInput: components.IterationInput$inboundSchema,
}).transform((v) => {
  return remap$(v, {
    "IterationInput": "iterationInput",
  });
});
/** @internal */
export type CreateIterationRequest$Outbound = {
  projectKey: string;
  environmentKey: string;
  experimentKey: string;
  IterationInput: components.IterationInput$Outbound;
};

/** @internal */
export const CreateIterationRequest$outboundSchema: z.ZodType<
  CreateIterationRequest$Outbound,
  z.ZodTypeDef,
  CreateIterationRequest
> = z.object({
  projectKey: z.string(),
  environmentKey: z.string(),
  experimentKey: z.string(),
  iterationInput: components.IterationInput$outboundSchema,
}).transform((v) => {
  return remap$(v, {
    iterationInput: "IterationInput",
  });
});

export function createIterationRequestToJSON(
  createIterationRequest: CreateIterationRequest,
): string {
  return JSON.stringify(
    CreateIterationRequest$outboundSchema.parse(createIterationRequest),
  );
}
export function createIterationRequestFromJSON(
  jsonString: string,
): SafeParseResult<CreateIterationRequest, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CreateIterationRequest$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CreateIterationRequest' from JSON`,
  );
}
