get notification sevice
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
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_error_message.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_success_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';
|
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||||
@@ -11,6 +12,23 @@ class MihNotificationApis {
|
|||||||
final baseAPI = AppEnviroment.baseApiUrl;
|
final baseAPI = AppEnviroment.baseApiUrl;
|
||||||
//================== Notifications ==========================================================================
|
//================== 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
|
/// This function is used to create notification to patient for access reviews
|
||||||
///
|
///
|
||||||
/// Patameters:-
|
/// Patameters:-
|
||||||
|
|||||||
@@ -96,21 +96,10 @@ class MIHApiCalls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Get Notifications
|
//Get Notifications
|
||||||
var responseNotification = await http.get(
|
notifi = await MihNotificationApis().getNotificationByUser(
|
||||||
Uri.parse("$baseAPI/notifications/$uid?amount=$notificationAmount"));
|
uid,
|
||||||
if (responseNotification.statusCode == 200) {
|
notificationAmount,
|
||||||
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 = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
//get patient profile
|
//get patient profile
|
||||||
Patient? patient = await MihPatientServices().getPatientDetails(
|
Patient? patient = await MihPatientServices().getPatientDetails(
|
||||||
@@ -122,26 +111,6 @@ class MIHApiCalls {
|
|||||||
patientData = null;
|
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(
|
return HomeArguments(
|
||||||
userData, bUserData, busData, patientData, notifi, userPic);
|
userData, bUserData, busData, patientData, notifi, userPic);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user