import 'package:didvan/models/ai/bots_model.dart'; class ChatsModel { int? id; int? userId; int? botId; String? title; String? createdAt; String? updatedAt; BotsModel? bot; List? prompts; ChatsModel( {this.id, this.userId, this.botId, this.title, this.createdAt, this.updatedAt, this.bot, this.prompts}); ChatsModel.fromJson(Map json) { id = json['id']; userId = json['userId']; botId = json['botId']; title = json['title']; createdAt = json['createdAt']; updatedAt = json['updatedAt']; bot = json['bot'] != null ? BotsModel.fromJson(json['bot']) : null; if (json['prompts'] != null) { prompts = []; json['prompts'].forEach((v) { prompts!.add(Prompts.fromJson(v)); }); } } Map toJson() { final Map data = {}; data['id'] = id; data['userId'] = userId; data['botId'] = botId; data['title'] = title; data['createdAt'] = createdAt; data['updatedAt'] = updatedAt; if (bot != null) { data['bot'] = bot!.toJson(); } if (prompts != null) { data['prompts'] = prompts!.map((v) => v.toJson()).toList(); } return data; } } class Prompts { int? id; int? chatId; String? text; String? role; String? createdAt; bool? finished; Prompts( {this.id, this.chatId, this.text, this.role, this.createdAt, this.finished}); Prompts.fromJson(Map json) { id = json['id']; chatId = json['chatId']; text = json['text']; role = json['role']; createdAt = json['createdAt']; } Map toJson() { final Map data = {}; data['id'] = id; data['chatId'] = chatId; data['text'] = text; data['role'] = role; data['createdAt'] = createdAt; return data; } Prompts copyWith({ int? id, int? chatId, String? text, String? role, String? createdAt, bool? finished, }) { return Prompts( id: id ?? this.id, chatId: chatId ?? this.chatId, text: text ?? this.text, role: role ?? this.role, createdAt: createdAt ?? this.createdAt, finished: finished ?? this.finished, ); } }