/*
 * 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 PatchExperimentRequest = {
  /**
   * The project key
   */
  projectKey: string;
  /**
   * The environment key
   */
  environmentKey: string;
  /**
   * The experiment key
   */
  experimentKey: string;
  experimentPatchInput: components.ExperimentPatchInput;
};

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

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

export function patchExperimentRequestToJSON(
  patchExperimentRequest: PatchExperimentRequest,
): string {
  return JSON.stringify(
    PatchExperimentRequest$outboundSchema.parse(patchExperimentRequest),
  );
}
export function patchExperimentRequestFromJSON(
  jsonString: string,
): SafeParseResult<PatchExperimentRequest, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => PatchExperimentRequest$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'PatchExperimentRequest' from JSON`,
  );
}
