/*
 * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  Link,
  Link$inboundSchema,
  Link$Outbound,
  Link$outboundSchema,
} from "./link.js";

export type DependentExperimentRep = {
  /**
   * The experiment key
   */
  key: string;
  /**
   * The experiment name
   */
  name: string;
  /**
   * The environment ID
   */
  environmentId: string;
  /**
   * The environment key
   */
  environmentKey: string;
  creationDate: number;
  archivedDate?: number | undefined;
  /**
   * The location and content type of related resources
   */
  links: { [k: string]: Link };
};

/** @internal */
export const DependentExperimentRep$inboundSchema: z.ZodType<
  DependentExperimentRep,
  z.ZodTypeDef,
  unknown
> = z.object({
  key: z.string(),
  name: z.string(),
  environmentId: z.string(),
  environmentKey: z.string(),
  creationDate: z.number().int(),
  archivedDate: z.number().int().optional(),
  _links: z.record(Link$inboundSchema),
}).transform((v) => {
  return remap$(v, {
    "_links": "links",
  });
});
/** @internal */
export type DependentExperimentRep$Outbound = {
  key: string;
  name: string;
  environmentId: string;
  environmentKey: string;
  creationDate: number;
  archivedDate?: number | undefined;
  _links: { [k: string]: Link$Outbound };
};

/** @internal */
export const DependentExperimentRep$outboundSchema: z.ZodType<
  DependentExperimentRep$Outbound,
  z.ZodTypeDef,
  DependentExperimentRep
> = z.object({
  key: z.string(),
  name: z.string(),
  environmentId: z.string(),
  environmentKey: z.string(),
  creationDate: z.number().int(),
  archivedDate: z.number().int().optional(),
  links: z.record(Link$outboundSchema),
}).transform((v) => {
  return remap$(v, {
    links: "_links",
  });
});

export function dependentExperimentRepToJSON(
  dependentExperimentRep: DependentExperimentRep,
): string {
  return JSON.stringify(
    DependentExperimentRep$outboundSchema.parse(dependentExperimentRep),
  );
}
export function dependentExperimentRepFromJSON(
  jsonString: string,
): SafeParseResult<DependentExperimentRep, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => DependentExperimentRep$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'DependentExperimentRep' from JSON`,
  );
}
