changed to new apis
parent
42028f14fd
commit
5201f5789e
@ -0,0 +1,27 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/api/api_client.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
|
||||
import '../models/department.dart';
|
||||
|
||||
class DepartmentsApiClient{
|
||||
|
||||
static final DepartmentsApiClient _instance = DepartmentsApiClient._internal();
|
||||
|
||||
DepartmentsApiClient._internal();
|
||||
|
||||
factory DepartmentsApiClient() => _instance;
|
||||
|
||||
Future getDepartment() async {
|
||||
Response response;
|
||||
response = await ApiClient().postJsonForResponse(
|
||||
URLs.host1 + URLs.getDepartments,
|
||||
{},
|
||||
isFormData: false
|
||||
);
|
||||
Map listJson = json.decode(utf8.decode(response.bodyBytes).replaceAll("\\", ""));
|
||||
return listJson['data'].map<Department>((department) => Department.fromJson(department)).toList();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
|
||||
import '../models/hospital.dart';
|
||||
import 'api_client.dart';
|
||||
|
||||
class HospitalsApiClient{
|
||||
|
||||
static final HospitalsApiClient _instance = HospitalsApiClient._internal();
|
||||
|
||||
HospitalsApiClient._internal();
|
||||
|
||||
factory HospitalsApiClient() => _instance;
|
||||
|
||||
Future getHospitals({
|
||||
required String title,
|
||||
required int pageSize
|
||||
}) async {
|
||||
|
||||
Response response = await ApiClient().postJsonForResponse(
|
||||
URLs.host1 + URLs.getHospitals,
|
||||
{
|
||||
"pageSize": pageSize.toString(),
|
||||
"name": title,
|
||||
},
|
||||
isFormData: false
|
||||
);
|
||||
|
||||
Map categoriesListJson = json.decode(utf8.decode(response.bodyBytes));
|
||||
print(categoriesListJson);
|
||||
return categoriesListJson['data'].map<Hospital>((category) => Hospital.fromJson(category)).toList();
|
||||
}
|
||||
|
||||
|
||||
Future<List<Hospital>> getHospitalsList({
|
||||
required String title,
|
||||
}) async {
|
||||
Response response;
|
||||
response = await ApiClient().postJsonForResponse(
|
||||
URLs.host1 + URLs.getHospitals,
|
||||
{"name" : title},
|
||||
isFormData: false
|
||||
);
|
||||
|
||||
List<Hospital> page = [];
|
||||
Map categoriesListJson = json.decode(utf8.decode(response.bodyBytes));
|
||||
page = categoriesListJson['data'].map<Hospital>((category) => Hospital.fromJson(category)).toList();
|
||||
return page;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue