
import 'package:mc_common_app/api/api_client.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/config/dependencies.dart';
import 'package:mc_common_app/models/user/cities.dart';
import 'package:mc_common_app/models/user/country.dart';
import 'package:mc_common_app/models/user/role.dart';

abstract class CommonRepo {
  Future<Country> getAllCountries();

  Future<Cities> getAllCites(String countryId);

  Future<Role> getRoles();
}

class CommonRepoImp implements CommonRepo {
  @override
  Future<Country> getAllCountries() async {
    return await injector.get<ApiClient>().getJsonForObject((json) => Country.fromJson(json), ApiConsts.GetAllCountry);
  }

  @override
  Future<Cities> getAllCites(String countryId) async {
    var postParams = {
      "CountryID": countryId,
    };
    return await injector.get<ApiClient>().getJsonForObject((json) => Cities.fromJson(json), ApiConsts.GetAllCities, queryParameters: postParams);
  }

  @override
  Future<Role> getRoles() async {
    return await injector.get<ApiClient>().getJsonForObject((json) => Role.fromJson(json), ApiConsts.GetProviderRoles);
  }
}