2023-02-15 08:48:34 +00:00
|
|
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'package:unit2/model/location/country.dart';
|
|
|
|
import 'package:http/http.dart' as http;
|
|
|
|
import 'package:unit2/model/location/region.dart';
|
2023-02-20 07:48:24 +00:00
|
|
|
import 'package:unit2/model/utils/eligibility.dart';
|
2023-02-15 08:48:34 +00:00
|
|
|
import 'package:unit2/utils/request.dart';
|
|
|
|
import 'package:unit2/utils/urls.dart';
|
|
|
|
class ProfileUtilities {
|
|
|
|
static final ProfileUtilities _instance = ProfileUtilities();
|
|
|
|
static ProfileUtilities get instance => _instance;
|
|
|
|
|
2023-02-20 07:48:24 +00:00
|
|
|
Future<List<Eligibility>>getEligibilities()async{
|
|
|
|
List<Eligibility> eligibilities=[];
|
2023-02-15 08:48:34 +00:00
|
|
|
String path = Url.instance.eligibilities();
|
|
|
|
|
|
|
|
Map<String, String> headers = {
|
|
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
|
|
};
|
|
|
|
// try{
|
|
|
|
http.Response response = await Request.instance.getRequest(path: path, param: {},headers: headers);
|
|
|
|
if(response.statusCode == 200){
|
|
|
|
Map data = jsonDecode(response.body);
|
|
|
|
if(data['data'] != null){
|
|
|
|
data['data'].forEach((var eligibility){
|
2023-02-20 07:48:24 +00:00
|
|
|
Eligibility newEligibilities = Eligibility.fromJson(eligibility);
|
2023-02-15 08:48:34 +00:00
|
|
|
eligibilities.add(newEligibilities);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// }catch(e){
|
|
|
|
// throw(e.toString());
|
|
|
|
// }
|
|
|
|
return eligibilities;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|