RealtimeTranslationClientEvent.fromJson constructor

RealtimeTranslationClientEvent.fromJson(
  1. Map<String, dynamic> json
)

Creates from JSON.

Implementation

factory RealtimeTranslationClientEvent.fromJson(Map<String, dynamic> json) {
  final type = json['type'];
  return switch (type) {
    'session.update' => RealtimeTranslationSessionUpdateEvent.fromJson(json),
    'session.input_audio_buffer.append' =>
      RealtimeTranslationInputAudioBufferAppendEvent.fromJson(json),
    'session.close' => RealtimeTranslationSessionCloseEvent.fromJson(json),
    _ => UnknownRealtimeTranslationClientEvent(
      Map<String, dynamic>.from(json),
    ),
  };
}