/*
 * 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 PostAIConfigRequest = {
  /**
   * The project key
   */
  projectKey: string;
  /**
   * AI Config object to create
   */
  aiConfigPost: components.AIConfigPost;
};

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

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

export function postAIConfigRequestToJSON(
  postAIConfigRequest: PostAIConfigRequest,
): string {
  return JSON.stringify(
    PostAIConfigRequest$outboundSchema.parse(postAIConfigRequest),
  );
}
export function postAIConfigRequestFromJSON(
  jsonString: string,
): SafeParseResult<PostAIConfigRequest, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => PostAIConfigRequest$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'PostAIConfigRequest' from JSON`,
  );
}
