Files
nabeh/mobile/lib/features/dashboard/data/models/chatbot_rule_model.dart
2026-05-24 23:27:32 +03:00

73 lines
2.5 KiB
Dart

import 'package:equatable/equatable.dart';
class ChatbotRuleModel extends Equatable {
// English: Unique identifier for the rule.
// Arabic: المعرف الفريد للقاعدة.
final int id;
// English: The ID of the company this rule belongs to.
// Arabic: معرف الشركة التي تنتمي إليها هذه القاعدة.
final int companyId;
// English: The session ID this rule is bound to.
// Arabic: معرف الجلسة المرتبطة بها هذه القاعدة.
final int? sessionId;
// English: Trigger type (keyword, gemini_ai).
// Arabic: نوع المشغل (كلمة مفتاحية، ذكاء اصطناعي).
final String triggerType;
// English: The comma-separated static reply keywords.
// Arabic: الكلمات المفتاحية للردود الثابتة مفصولة بفاصلة.
final String? keyword;
// English: Predefined reply content or Gemini prompt instructions.
// Arabic: محتوى الرد المحدد مسبقاً أو تعليمات موجه الذكاء الاصطناعي.
final String? aiPrompt;
// English: Active state flag.
// Arabic: علم الحالة النشطة.
final bool isActive;
const ChatbotRuleModel({
required this.id,
required this.companyId,
this.sessionId,
required this.triggerType,
this.keyword,
this.aiPrompt,
required this.isActive,
});
// English: Factory constructor to parse ChatbotRuleModel from JSON data map.
// Arabic: منشئ المصنع لتحليل نموذج قاعدة الرد الآلي من خريطة بيانات جيسون.
factory ChatbotRuleModel.fromJson(Map<String, dynamic> json) {
return ChatbotRuleModel(
id: json['id'] as int? ?? 0,
companyId: json['company_id'] as int? ?? 0,
sessionId: json['session_id'] as int?,
triggerType: json['trigger_type'] as String? ?? 'keyword',
keyword: json['keyword'] as String?,
aiPrompt: json['ai_prompt'] as String?,
isActive: (json['is_active'] as int? ?? 0) == 1,
);
}
// English: Convert model to JSON map.
// Arabic: تحويل النموذج إلى خريطة جيسون.
Map<String, dynamic> toJson() {
return {
'id': id,
'company_id': companyId,
'session_id': sessionId,
'trigger_type': triggerType,
'keyword': keyword,
'ai_prompt': aiPrompt,
'is_active': isActive ? 1 : 0,
};
}
@override
List<Object?> get props => [id, companyId, sessionId, triggerType, keyword, aiPrompt, isActive];
}