import '../models/analytics.dart';
import '../models/report.dart';
import 'api_client.dart';

class AnalyticsService {
  final _client = ApiClient.instance;

  Future<DashboardMetrics> getDashboard() async {
    final res = await _client.get('/analytics/dashboard');
    return DashboardMetrics.fromJson(res.data as Map<String, dynamic>);
  }

  Future<ReportSummary> getReport({
    required String startDate,
    required String endDate,
    String? status,
  }) async {
    final res = await _client.get('/analytics/report', params: {
      'startDate': startDate,
      'endDate': endDate,
      'status': ?status,
      'format': 'JSON',
    });
    return ReportSummary.fromJson(res.data as Map<String, dynamic>);
  }
}
