Merge branch 'majd_development' into 'master'
Majd development See merge request haroon6138/cloudsolutions-atoms!18merge-requests/20/merge
commit
c79ac5e5b3
@ -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,25 @@
|
||||
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/lookup.dart';
|
||||
|
||||
class GasTypesApiClient{
|
||||
|
||||
static final GasTypesApiClient _instance = GasTypesApiClient._internal();
|
||||
|
||||
GasTypesApiClient._internal();
|
||||
|
||||
factory GasTypesApiClient() => _instance;
|
||||
|
||||
Future <List<Lookup>> getData() async {
|
||||
Response response;
|
||||
response = await ApiClient().getJsonForResponse("${URLs.host1}${URLs.getGasTypes}");
|
||||
Map categoriesListJson = json.decode(utf8.decode(response.bodyBytes));
|
||||
return categoriesListJson["data"].map<Lookup>((item) => Lookup.fromJson(item)).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;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue