RealtimeTranslationSession.fromJson constructor

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

Creates from JSON.

Implementation

factory RealtimeTranslationSession.fromJson(Map<String, dynamic> json) {
  if (json['id'] == null ||
      json['type'] == null ||
      json['expires_at'] == null ||
      json['model'] == null ||
      json['audio'] == null) {
    throw const FormatException(
      'RealtimeTranslationSession.fromJson missing one or more required fields '
      '(id, type, expires_at, model, audio)',
    );
  }
  return RealtimeTranslationSession(
    id: json['id'] as String,
    type: json['type'] as String,
    expiresAt: json['expires_at'] as int,
    model: json['model'] as String,
    audio: RealtimeTranslationSessionAudio.fromJson(
      json['audio'] as Map<String, dynamic>,
    ),
  );
}