import 'package:base_project/data/network/base_network_service.dart';
import 'package:base_project/data/network/network_api_service.dart';
import 'package:base_project/resources/api_constants.dart';

class SystemParamsRepo {
  final BaseNetworkService _networkService = NetworkApiService();

  Future<dynamic> getProfileImgApi() async {
    try {
      final response = _networkService
          .getGetApiResponse(ApiConstants.getUserProfileImgEndpoint);
      return response;
    } catch (e) {
      rethrow;
    }
  }

  Future<dynamic> getProfileApi() async {
    try {
      final response = _networkService
          .getGetApiResponse(ApiConstants.getUserProfileEndpoint);
      return response;
    } catch (e) {
      rethrow;
    }
  }

  Future<dynamic> updateProfileApi(dynamic data, dynamic uId) async {
    final uri = Uri.parse("${ApiConstants.updateUserProfileEndpoint}/$uId");

    try {
      final response =
          await _networkService.getPutApiResponse(uri.toString(), data);
      return response;
    } catch (e) {
      rethrow;
    }
  }

  Future<dynamic> updateProfileImg(dynamic data) async {
    try {
      final response = await _networkService.getPostApiResponse(
          ApiConstants.updateUserProfileImgEndpoint, data);
      return response;
    } catch (e) {
      rethrow;
    }
  }

  Future<dynamic> getSystemParameters() async {
    final uri = Uri.parse("${ApiConstants.getSystemParameters}");
    try {
      final response = _networkService.getGetApiResponse(uri.toString());
      return response;
    } catch (e) {
      rethrow;
    }
  }

  Future<dynamic> updateSystemParameters(dynamic body) async {
    try {
      final uri = Uri.parse("${ApiConstants.updateSystemParams}");
      final response = _networkService.getPutApiResponse(uri.toString(), body);
      return response;
    } catch (e) {
      rethrow;
    }
  }

  Future<dynamic> uploadSystemParamLogo(dynamic data) async {
    try {
      final uri = Uri.parse("${ApiConstants.uploadSystemParamImg}");
      final response =
          await _networkService.getPostApiResponse(uri.toString(), data);
      return response;
    } catch (e) {
      rethrow;
    }
  }
}
