Conversation.fromJson constructor

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

Creates a Conversation from a JSON map.

Automatically handles the mapping of snake_case backend keys (like is_running) to camelCase Dart properties.

Implementation

factory Conversation.fromJson(Map<String, dynamic> json) {
  return Conversation(
    id: json['id'] as String?,
    name: json['name'] as String,
    type: json['type'] as String,
    instanceName: json['instanceName'] as String,
    isConversationning: json['is_running'] as bool? ?? false,
    sessionId: json['session_id'] as String?,
    isDefault: json['default'] as bool? ?? false,
    stats: json['stats'] as Map<String, dynamic>?,
    conversationId: json['conversationId'] as String?,
    errorLogs: (json['error_logs'] as List<dynamic>?)
        ?.map((e) => ConversationError.fromJson(e as Map<String, dynamic>))
        .toList(),
    createdAt: DateTime.parse(json['created_at'] as String),
    updatedAt: DateTime.parse(json['updated_at'] as String),
  );
}