import 'package:tm_app/core/utils/result.dart';
import 'package:tm_app/data/services/api/your_tenders_api.dart';
import 'package:tm_app/data/services/model/tender_approvals_response/tender_approvals_response.dart';

import '../../../core/network/network_manager.dart';
import 'model/request_models/get_tenders_request_model/get_tenders_request_model.dart';

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

  final NetworkManager _networkManager;

  Future<Result<TenderApprovalsResponse>> getTenders({
    required GetTendersRequestModel requestModel,
  }) async {
    final result = await _networkManager.makeRequest(
      YourTendersApi.getTenders(
        limit: requestModel.limit,
        offset: requestModel.offset,
        createdFrom: requestModel.createdFrom,
        createdTo: requestModel.createdTo,
        status: requestModel.status,
      ),
      (json) => TenderApprovalsResponse.fromJson(json),
      method: 'GET',
    );
    return result;
  }
}
