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

import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  RealtimeTranscriptionSessionUpdatePayload,
  RealtimeTranscriptionSessionUpdatePayload$inboundSchema,
  RealtimeTranscriptionSessionUpdatePayload$Outbound,
  RealtimeTranscriptionSessionUpdatePayload$outboundSchema,
} from "./realtimetranscriptionsessionupdatepayload.js";

export type RealtimeTranscriptionSessionUpdateMessage = {
  type?: "session.update" | undefined;
  session: RealtimeTranscriptionSessionUpdatePayload;
};

/** @internal */
export const RealtimeTranscriptionSessionUpdateMessage$inboundSchema: z.ZodType<
  RealtimeTranscriptionSessionUpdateMessage,
  unknown
> = z.object({
  type: z.literal("session.update").default("session.update"),
  session: RealtimeTranscriptionSessionUpdatePayload$inboundSchema,
});
/** @internal */
export type RealtimeTranscriptionSessionUpdateMessage$Outbound = {
  type: "session.update";
  session: RealtimeTranscriptionSessionUpdatePayload$Outbound;
};

/** @internal */
export const RealtimeTranscriptionSessionUpdateMessage$outboundSchema:
  z.ZodType<
    RealtimeTranscriptionSessionUpdateMessage$Outbound,
    RealtimeTranscriptionSessionUpdateMessage
  > = z.object({
    type: z.literal("session.update").default("session.update" as const),
    session: RealtimeTranscriptionSessionUpdatePayload$outboundSchema,
  });

export function realtimeTranscriptionSessionUpdateMessageToJSON(
  realtimeTranscriptionSessionUpdateMessage:
    RealtimeTranscriptionSessionUpdateMessage,
): string {
  return JSON.stringify(
    RealtimeTranscriptionSessionUpdateMessage$outboundSchema.parse(
      realtimeTranscriptionSessionUpdateMessage,
    ),
  );
}
export function realtimeTranscriptionSessionUpdateMessageFromJSON(
  jsonString: string,
): SafeParseResult<
  RealtimeTranscriptionSessionUpdateMessage,
  SDKValidationError
> {
  return safeParse(
    jsonString,
    (x) =>
      RealtimeTranscriptionSessionUpdateMessage$inboundSchema.parse(
        JSON.parse(x),
      ),
    `Failed to parse 'RealtimeTranscriptionSessionUpdateMessage' from JSON`,
  );
}
