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

import * as z from "zod/v4";
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 {
  AudioFormat,
  AudioFormat$inboundSchema,
  AudioFormat$Outbound,
  AudioFormat$outboundSchema,
} from "./audioformat.js";

export type RealtimeTranscriptionSessionUpdatePayload = {
  /**
   * Set before sending audio. Audio format updates are rejected after audio starts.
   */
  audioFormat?: AudioFormat | null | undefined;
  /**
   * Set before sending audio. Streaming delay updates are rejected after audio starts.
   */
  targetStreamingDelayMs?: number | null | undefined;
};

/** @internal */
export const RealtimeTranscriptionSessionUpdatePayload$inboundSchema: z.ZodType<
  RealtimeTranscriptionSessionUpdatePayload,
  unknown
> = z.object({
  audio_format: z.nullable(AudioFormat$inboundSchema).optional(),
  target_streaming_delay_ms: z.nullable(z.int()).optional(),
}).transform((v) => {
  return remap$(v, {
    "audio_format": "audioFormat",
    "target_streaming_delay_ms": "targetStreamingDelayMs",
  });
});
/** @internal */
export type RealtimeTranscriptionSessionUpdatePayload$Outbound = {
  audio_format?: AudioFormat$Outbound | null | undefined;
  target_streaming_delay_ms?: number | null | undefined;
};

/** @internal */
export const RealtimeTranscriptionSessionUpdatePayload$outboundSchema:
  z.ZodType<
    RealtimeTranscriptionSessionUpdatePayload$Outbound,
    RealtimeTranscriptionSessionUpdatePayload
  > = z.object({
    audioFormat: z.nullable(AudioFormat$outboundSchema).optional(),
    targetStreamingDelayMs: z.nullable(z.int()).optional(),
  }).transform((v) => {
    return remap$(v, {
      audioFormat: "audio_format",
      targetStreamingDelayMs: "target_streaming_delay_ms",
    });
  });

export function realtimeTranscriptionSessionUpdatePayloadToJSON(
  realtimeTranscriptionSessionUpdatePayload:
    RealtimeTranscriptionSessionUpdatePayload,
): string {
  return JSON.stringify(
    RealtimeTranscriptionSessionUpdatePayload$outboundSchema.parse(
      realtimeTranscriptionSessionUpdatePayload,
    ),
  );
}
export function realtimeTranscriptionSessionUpdatePayloadFromJSON(
  jsonString: string,
): SafeParseResult<
  RealtimeTranscriptionSessionUpdatePayload,
  SDKValidationError
> {
  return safeParse(
    jsonString,
    (x) =>
      RealtimeTranscriptionSessionUpdatePayload$inboundSchema.parse(
        JSON.parse(x),
      ),
    `Failed to parse 'RealtimeTranscriptionSessionUpdatePayload' from JSON`,
  );
}
