/*
 * 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 AgentsApiV1ConversationsGetRequest = {
  /**
   * ID of the conversation from which we are fetching metadata.
   */
  conversationId: string;
};

/**
 * Successful Response
 */
export type AgentsApiV1ConversationsGetResponseV1ConversationsGet =
  | components.ModelConversation
  | components.AgentConversation;

/** @internal */
export type AgentsApiV1ConversationsGetRequest$Outbound = {
  conversation_id: string;
};

/** @internal */
export const AgentsApiV1ConversationsGetRequest$outboundSchema: z.ZodType<
  AgentsApiV1ConversationsGetRequest$Outbound,
  z.ZodTypeDef,
  AgentsApiV1ConversationsGetRequest
> = z.object({
  conversationId: z.string(),
}).transform((v) => {
  return remap$(v, {
    conversationId: "conversation_id",
  });
});

export function agentsApiV1ConversationsGetRequestToJSON(
  agentsApiV1ConversationsGetRequest: AgentsApiV1ConversationsGetRequest,
): string {
  return JSON.stringify(
    AgentsApiV1ConversationsGetRequest$outboundSchema.parse(
      agentsApiV1ConversationsGetRequest,
    ),
  );
}

/** @internal */
export const AgentsApiV1ConversationsGetResponseV1ConversationsGet$inboundSchema:
  z.ZodType<
    AgentsApiV1ConversationsGetResponseV1ConversationsGet,
    z.ZodTypeDef,
    unknown
  > = z.union([
    components.ModelConversation$inboundSchema,
    components.AgentConversation$inboundSchema,
  ]);

export function agentsApiV1ConversationsGetResponseV1ConversationsGetFromJSON(
  jsonString: string,
): SafeParseResult<
  AgentsApiV1ConversationsGetResponseV1ConversationsGet,
  SDKValidationError
> {
  return safeParse(
    jsonString,
    (x) =>
      AgentsApiV1ConversationsGetResponseV1ConversationsGet$inboundSchema.parse(
        JSON.parse(x),
      ),
    `Failed to parse 'AgentsApiV1ConversationsGetResponseV1ConversationsGet' from JSON`,
  );
}
