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

66 lines
2.4 KiB
Dart

import 'package:equatable/equatable.dart';
class WhatsAppStatusModel extends Equatable {
// English: Unique session identifier in database.
// Arabic: معرف الجلسة الفريد في قاعدة البيانات.
final int id;
// English: Name of the session (e.g. support, sales).
// Arabic: اسم الجلسة (مثل الدعم، المبيعات).
final String name;
// English: Unique session key sent to Baileys Node.js gateway.
// Arabic: مفتاح الجلسة الفريد المرسل إلى بوابة الجيسون الخاصة بالواتساب.
final String sessionKey;
// English: Current connection status (waiting_qr, connected, disconnected).
// Arabic: حالة الاتصال الحالية (بانتظار رمز الاستجابة، متصل، غير متصل).
final String status;
// English: Base64 or text QR code from Baileys if waiting for scan.
// Arabic: رمز الاستجابة السريعة (QR) من البوابة إذا كان بانتظار المسح.
final String? qrCode;
// English: Linked phone number on success connection.
// Arabic: رقم الهاتف المرتبط بالجلسة عند الاتصال بنجاح.
final String? phone;
const WhatsAppStatusModel({
required this.id,
required this.name,
required this.sessionKey,
required this.status,
this.qrCode,
this.phone,
});
// English: Factory constructor to parse WhatsApp status session model from JSON.
// Arabic: منشئ المصنع لتحليل نموذج حالة جلسة الواتساب من استجابة جيسون.
factory WhatsAppStatusModel.fromJson(Map<String, dynamic> json) {
return WhatsAppStatusModel(
id: json['id'] as int? ?? 0,
name: json['name'] as String? ?? 'WhatsApp Team',
sessionKey: json['session_key'] as String? ?? '',
status: json['status'] as String? ?? 'disconnected',
qrCode: json['qr_code'] as String?,
phone: json['phone'] as String?,
);
}
// English: Convert model to JSON payload.
// Arabic: تحويل النموذج إلى حمولة جيسون.
Map<String, dynamic> toJson() {
return {
'id': id,
'name': name,
'session_key': sessionKey,
'status': status,
'qr_code': qrCode,
'phone': phone,
};
}
@override
List<Object?> get props => [id, name, sessionKey, status, qrCode, phone];
}