forked from yaso_meth/mih-project
get notification sevice
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/notification.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_success_message.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
@@ -11,6 +12,23 @@ class MihNotificationApis {
|
||||
final baseAPI = AppEnviroment.baseApiUrl;
|
||||
//================== Notifications ==========================================================================
|
||||
|
||||
Future<List<MIHNotification>> getNotificationByUser(
|
||||
String app_id,
|
||||
int notificationAmount,
|
||||
) async {
|
||||
var responseNotification = await http.get(
|
||||
Uri.parse("$baseAPI/notifications/$app_id?amount=$notificationAmount"));
|
||||
if (responseNotification.statusCode == 200) {
|
||||
String body = responseNotification.body;
|
||||
Iterable l = jsonDecode(body);
|
||||
List<MIHNotification> notifications = List<MIHNotification>.from(
|
||||
l.map((model) => MIHNotification.fromJson(model)));
|
||||
return notifications;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/// This function is used to create notification to patient for access reviews
|
||||
///
|
||||
/// Patameters:-
|
||||
|
||||
@@ -96,21 +96,10 @@ class MIHApiCalls {
|
||||
}
|
||||
|
||||
//Get Notifications
|
||||
var responseNotification = await http.get(
|
||||
Uri.parse("$baseAPI/notifications/$uid?amount=$notificationAmount"));
|
||||
if (responseNotification.statusCode == 200) {
|
||||
String body = responseNotification.body;
|
||||
// var decodedData = jsonDecode(body);
|
||||
// MIHNotification notifications = MIHNotification.fromJson(decodedData);
|
||||
|
||||
Iterable l = jsonDecode(body);
|
||||
//print("Here2");
|
||||
List<MIHNotification> notifications = List<MIHNotification>.from(
|
||||
l.map((model) => MIHNotification.fromJson(model)));
|
||||
notifi = notifications;
|
||||
} else {
|
||||
notifi = [];
|
||||
}
|
||||
notifi = await MihNotificationApis().getNotificationByUser(
|
||||
uid,
|
||||
notificationAmount,
|
||||
);
|
||||
|
||||
//get patient profile
|
||||
Patient? patient = await MihPatientServices().getPatientDetails(
|
||||
@@ -122,26 +111,6 @@ class MIHApiCalls {
|
||||
patientData = null;
|
||||
}
|
||||
|
||||
// print("Here");
|
||||
// print("Body: ${response.body}");
|
||||
// print("Code: ${response.statusCode}");
|
||||
// var errorCode = response.statusCode.toString();
|
||||
// var errorBody = response.body;
|
||||
|
||||
// final response = await http.get(
|
||||
// Uri.parse("${AppEnviroment.baseApiUrl}/patients/${userData.app_id}"));
|
||||
// if (response.statusCode == 200) {
|
||||
// // print("Here1");
|
||||
// var decodedData = jsonDecode(response.body);
|
||||
// // print("Here2");
|
||||
// Patient patients = Patient.fromJson(decodedData as Map<String, dynamic>);
|
||||
// // print("Here3");
|
||||
// // print(patients);
|
||||
// patientData = patients;
|
||||
// } else {
|
||||
// patientData = null;
|
||||
// }
|
||||
//print(userPic);
|
||||
return HomeArguments(
|
||||
userData, bUserData, busData, patientData, notifi, userPic);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user