You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.3 KiB
Dart
53 lines
1.3 KiB
Dart
|
|
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;
|
|
}
|
|
} |