toJson method
Converts to JSON.
The /realtime/client_secrets endpoint requires a type discriminator
on the embedded session ('realtime' vs 'transcription'). If the
caller didn't set it explicitly, default it to 'realtime' here so the
bare /realtime/sessions payload (which rejects type) stays
untouched.
Implementation
Map<String, dynamic> toJson() {
final sessionJson = session.toJson();
sessionJson['type'] ??= 'realtime';
return {
if (expiresAfter != null) 'expires_after': expiresAfter!.toJson(),
'session': sessionJson,
};
}