/*
 * 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 ParameterRep = {
  variationId?: string | undefined;
  flagKey?: string | undefined;
};

/** @internal */
export const ParameterRep$inboundSchema: z.ZodType<
  ParameterRep,
  z.ZodTypeDef,
  unknown
> = z.object({
  variationId: z.string().optional(),
  flagKey: z.string().optional(),
});
/** @internal */
export type ParameterRep$Outbound = {
  variationId?: string | undefined;
  flagKey?: string | undefined;
};

/** @internal */
export const ParameterRep$outboundSchema: z.ZodType<
  ParameterRep$Outbound,
  z.ZodTypeDef,
  ParameterRep
> = z.object({
  variationId: z.string().optional(),
  flagKey: z.string().optional(),
});

export function parameterRepToJSON(parameterRep: ParameterRep): string {
  return JSON.stringify(ParameterRep$outboundSchema.parse(parameterRep));
}
export function parameterRepFromJSON(
  jsonString: string,
): SafeParseResult<ParameterRep, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ParameterRep$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ParameterRep' from JSON`,
  );
}
