Deploy: 2026-05-25 00:29:42
This commit is contained in:
@@ -6,6 +6,7 @@ import 'models/contact_model.dart';
|
||||
import 'models/plan_model.dart';
|
||||
import 'models/super_admin_stats_model.dart';
|
||||
import 'models/whatsapp_status_model.dart';
|
||||
import 'models/meta_session_model.dart';
|
||||
|
||||
class DashboardRepository {
|
||||
final ApiService _apiService = ApiService();
|
||||
@@ -157,4 +158,42 @@ class DashboardRepository {
|
||||
throw Exception(error);
|
||||
}
|
||||
}
|
||||
|
||||
// English: Load connected Meta sessions.
|
||||
Future<List<MetaSessionModel>> getMetaSessions() async {
|
||||
final token = await _getToken();
|
||||
final response = await _apiService.getMetaSessions(token);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final decoded = jsonDecode(response.body) as Map<String, dynamic>;
|
||||
final list = decoded['data'] as List<dynamic>? ?? [];
|
||||
return list.map((item) => MetaSessionModel.fromJson(item as Map<String, dynamic>)).toList();
|
||||
} else {
|
||||
throw Exception('فشل في جلب جلسات ميتا المتصلة');
|
||||
}
|
||||
}
|
||||
|
||||
// English: Connect a new Facebook Page or Instagram channel.
|
||||
Future<void> connectMetaSession(String channelType, String pageId, String pageName, String pageAccessToken) async {
|
||||
final token = await _getToken();
|
||||
final response = await _apiService.connectMetaSession(token, channelType, pageId, pageName, pageAccessToken);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
final decoded = jsonDecode(response.body) as Map<String, dynamic>;
|
||||
final error = decoded['message'] as String? ?? 'فشل في ربط القناة';
|
||||
throw Exception(error);
|
||||
}
|
||||
}
|
||||
|
||||
// English: Disconnect a Meta page or Instagram channel.
|
||||
Future<void> disconnectMetaSession(int sessionId) async {
|
||||
final token = await _getToken();
|
||||
final response = await _apiService.disconnectMetaSession(token, sessionId);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
final decoded = jsonDecode(response.body) as Map<String, dynamic>;
|
||||
final error = decoded['message'] as String? ?? 'فشل في قطع اتصال القناة';
|
||||
throw Exception(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user