import 'package:tm_app/core/utils/result.dart';
import 'package:tm_app/data/services/api/home_api.dart';
import 'package:tm_app/data/services/model/feedback_stats_response/feedback_stat_response.dart';
import 'package:tm_app/data/services/model/recommended_tenders_response/recommended_tenders_response.dart';
import 'package:tm_app/data/services/model/tender_approvals_stats_response/tender_approvals_stats_response.dart';

import '../../core/network/network_manager.dart';

class HomeService {
  HomeService({required NetworkManager networkManager})
    : _networkManager = networkManager;
  final NetworkManager _networkManager;

  Future<Result<RecommendedTendersResponse>> getRecommendedTenders({
    required int limit,
    required int offset,
  }) async {
    final result = await _networkManager.makeRequest(
      HomeApi.getRecommendedTenders(limit: limit, offset: offset),
      method: 'GET',
      (json) => RecommendedTendersResponse.fromJson(json),
    );
    return result;
  }

  Future<Result<TenderApprovalsStatsResponse>>
  getTendersApprovalsStats() async {
    final result = await _networkManager.makeRequest(
      HomeApi.tenderApprovalStats,
      (json) => TenderApprovalsStatsResponse.fromJson(json),
      method: 'GET',
    );
    return result;
  }

  Future<Result<FeedbackStatResponse>> getFeedbackStats() async {
    final result = await _networkManager.makeRequest(
      HomeApi.statsCompany,
      (json) => FeedbackStatResponse.fromJson(json),
      method: 'GET',
    );
    return result;
  }

  Future<Result<Map<String, dynamic>>> checkUnreadNotifications() async {
    final result = await _networkManager.makeRequest(
            HomeApi.checkUnreadNotifications,
      (json) => json,
      method: 'GET',
    );
    return result;
  }
}
