/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 378b7105180c
 */

import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { smartUnion } from "../../types/smartUnion.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

/**
 * Human-readable error message.
 */
export type RealtimeTranscriptionErrorDetailMessage = string | {
  [k: string]: any;
};

export type RealtimeTranscriptionErrorDetail = {
  /**
   * Human-readable error message.
   */
  message: string | { [k: string]: any };
  /**
   * Internal error code for debugging.
   */
  code: number;
};

/** @internal */
export const RealtimeTranscriptionErrorDetailMessage$inboundSchema: z.ZodType<
  RealtimeTranscriptionErrorDetailMessage,
  unknown
> = smartUnion([z.string(), z.record(z.string(), z.any())]);
/** @internal */
export type RealtimeTranscriptionErrorDetailMessage$Outbound = string | {
  [k: string]: any;
};

/** @internal */
export const RealtimeTranscriptionErrorDetailMessage$outboundSchema: z.ZodType<
  RealtimeTranscriptionErrorDetailMessage$Outbound,
  RealtimeTranscriptionErrorDetailMessage
> = smartUnion([z.string(), z.record(z.string(), z.any())]);

export function realtimeTranscriptionErrorDetailMessageToJSON(
  realtimeTranscriptionErrorDetailMessage:
    RealtimeTranscriptionErrorDetailMessage,
): string {
  return JSON.stringify(
    RealtimeTranscriptionErrorDetailMessage$outboundSchema.parse(
      realtimeTranscriptionErrorDetailMessage,
    ),
  );
}
export function realtimeTranscriptionErrorDetailMessageFromJSON(
  jsonString: string,
): SafeParseResult<
  RealtimeTranscriptionErrorDetailMessage,
  SDKValidationError
> {
  return safeParse(
    jsonString,
    (x) =>
      RealtimeTranscriptionErrorDetailMessage$inboundSchema.parse(
        JSON.parse(x),
      ),
    `Failed to parse 'RealtimeTranscriptionErrorDetailMessage' from JSON`,
  );
}

/** @internal */
export const RealtimeTranscriptionErrorDetail$inboundSchema: z.ZodType<
  RealtimeTranscriptionErrorDetail,
  unknown
> = z.object({
  message: smartUnion([z.string(), z.record(z.string(), z.any())]),
  code: z.int(),
});
/** @internal */
export type RealtimeTranscriptionErrorDetail$Outbound = {
  message: string | { [k: string]: any };
  code: number;
};

/** @internal */
export const RealtimeTranscriptionErrorDetail$outboundSchema: z.ZodType<
  RealtimeTranscriptionErrorDetail$Outbound,
  RealtimeTranscriptionErrorDetail
> = z.object({
  message: smartUnion([z.string(), z.record(z.string(), z.any())]),
  code: z.int(),
});

export function realtimeTranscriptionErrorDetailToJSON(
  realtimeTranscriptionErrorDetail: RealtimeTranscriptionErrorDetail,
): string {
  return JSON.stringify(
    RealtimeTranscriptionErrorDetail$outboundSchema.parse(
      realtimeTranscriptionErrorDetail,
    ),
  );
}
export function realtimeTranscriptionErrorDetailFromJSON(
  jsonString: string,
): SafeParseResult<RealtimeTranscriptionErrorDetail, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => RealtimeTranscriptionErrorDetail$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'RealtimeTranscriptionErrorDetail' from JSON`,
  );
}
