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.
PatientApp-KKUMC/lib/core/service/geofencing/GeofencingServices.dart

51 lines
2.0 KiB
Dart

import 'dart:convert';
import 'package:diplomaticquarterapp/config/config.dart';
5 years ago
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/model/geofencing/requests/GeoZonesRequestModel.dart';
import 'package:diplomaticquarterapp/core/model/geofencing/requests/LogGeoZoneRequestModel.dart';
import 'package:diplomaticquarterapp/core/model/geofencing/responses/GeoZonesResponseModel.dart';
import 'package:diplomaticquarterapp/core/model/geofencing/responses/LogGeoZoneResponseModel.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart';
5 years ago
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:flutter/foundation.dart';
class GeofencingServices extends BaseService {
List<GeoZonesResponseModel> geoZones = List();
bool testZones = true;
Future<List<GeoZonesResponseModel>> getAllGeoZones(GeoZonesRequestModel request) async {
hasError = false;
var _zonesJsonString;
await baseAppClient.post(GET_GEO_ZONES, onSuccess: (dynamic response, int statusCode) {
5 years ago
var zones = response['GeoF_PointsList'];
zones.forEach((json) {
geoZones.add(GeoZonesResponseModel().fromJson(json));
});
5 years ago
_zonesJsonString = json.encode(zones);
}, onFailure: (String error, int statusCode) {
hasError = true;
return Future.error(error);
}, body: request.toFlatMap());
AppSharedPreferences pref = AppSharedPreferences();
await pref.setString(HMG_GEOFENCES, _zonesJsonString);
return geoZones;
}
LogGeoZoneResponseModel logResponse;
4 years ago
5 years ago
Future<LogGeoZoneResponseModel> logGeoZone(LogGeoZoneRequestModel request) async {
hasError = false;
await baseAppClient.post(LOG_GEO_ZONES, onSuccess: (dynamic response, int statusCode) {
logResponse = LogGeoZoneResponseModel().fromJson(response);
}, onFailure: (String error, int statusCode) {
hasError = true;
return Future.error(error);
}, body: request.toFlatMap());
return logResponse;
}
}