import 'package:didvan/models/ai/bots_model.dart'; import 'package:didvan/models/ai/files_model.dart'; class ChatsModel { int? id; int? userId; int? botId; String? title; String? placeholder; String? createdAt; String? updatedAt; BotsModel? bot; List? prompts; bool? isEditing; ChatsModel({ this.id, this.userId, this.botId, this.title, this.placeholder, this.createdAt, this.updatedAt, this.bot, this.prompts, this.isEditing = false, }); ChatsModel.fromJson(Map json) { id = json['id']; userId = json['userId']; botId = json['botId']; title = json['title']; placeholder = json['placeholder']; 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['placeholder'] = placeholder; 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; } ChatsModel copyWith( {int? id, int? userId, int? botId, String? title, String? placeholder, String? createdAt, String? updatedAt, BotsModel? bot, List? prompts, bool? isEditing}) { return ChatsModel( id: id ?? this.id, userId: userId ?? this.userId, botId: botId ?? this.botId, title: title ?? this.title, placeholder: placeholder ?? this.placeholder, bot: bot ?? this.bot, createdAt: createdAt ?? this.createdAt, updatedAt: updatedAt ?? this.updatedAt, prompts: prompts ?? this.prompts, isEditing: isEditing ?? this.isEditing, ); } } class Prompts { int? id; int? chatId; String? text; String? file; String? fileName; String? role; String? createdAt; bool? finished; bool? error; bool? audio; FilesModel? fileLocal; Prompts({ this.id, this.chatId, this.text, this.file, this.fileName, this.role, this.createdAt, this.finished, this.error, this.fileLocal, this.audio, }); Prompts.fromJson(Map json) { id = json['id']; chatId = json['chatId']; text = json['text']; file = json['file']; fileName = json['fileName']; role = json['role']; createdAt = json['createdAt']; audio = json['audio']; } Map toJson() { final Map data = {}; data['id'] = id; data['chatId'] = chatId; data['text'] = text; data['file'] = file; data['fileName'] = fileName; data['role'] = role; data['createdAt'] = createdAt; data['audio'] = audio; return data; } Prompts copyWith( {int? id, int? chatId, String? text, String? file, String? fileName, FilesModel? fileLocal, String? role, String? createdAt, bool? finished, bool? error, bool? audio}) { return Prompts( id: id ?? this.id, chatId: chatId ?? this.chatId, text: text ?? this.text, file: file ?? this.file, fileName: fileName ?? this.fileName, fileLocal: fileLocal ?? this.fileLocal, role: role ?? this.role, createdAt: createdAt ?? this.createdAt, finished: finished ?? this.finished, error: error ?? this.error, audio: audio ?? this.audio, ); } }