SyniServiceMessage.fromJson constructor
SyniServiceMessage.fromJson(
- Map<String, dynamic> json
)
Implementation
factory SyniServiceMessage.fromJson(Map<String, dynamic> json) {
final role = _string(json['role']);
final content = _string(json['content']) ?? _string(json['message']);
if (role == null || content == null) {
throw const FormatException('Syni message is missing role or content');
}
return SyniServiceMessage(
id: _string(json['id']) ?? _string(json['message_id']),
role: role,
content: content,
createdAt: _date(json['created_at']),
raw: Map.unmodifiable(json),
);
}