Migrate from BitBucket
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
import 'dart:io';
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:school_management_system/components/default_values.dart';
|
||||
|
||||
Authorise authoriseFromJson(String str) => Authorise.fromJson(json.decode(str));
|
||||
String authoriseToJson(Authorise data) => json.encode(data.toJson());
|
||||
|
||||
class Authorise {
|
||||
DateTime? validUntil;
|
||||
String? token;
|
||||
String? status;
|
||||
String? message;
|
||||
|
||||
Authorise({
|
||||
this.validUntil,
|
||||
this.token,
|
||||
this.status,
|
||||
this.message,
|
||||
});
|
||||
|
||||
factory Authorise.fromJson(Map<String, dynamic> json) => Authorise(
|
||||
validUntil: DateTime.parse(json["validUntil"]),
|
||||
token: json["token"],
|
||||
status: json["status"],
|
||||
message: json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"validUntil": validUntil!.toIso8601String(),
|
||||
"token": token,
|
||||
"status": status,
|
||||
"message": message,
|
||||
};
|
||||
}
|
||||
|
||||
Future<String> login(String username, String password) async {
|
||||
try {
|
||||
print("$baseUrl/auth/generateToken");
|
||||
final response = await client
|
||||
.post(
|
||||
Uri.parse("$baseUrl/auth/generateToken"),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: json.encode({
|
||||
'username': username,
|
||||
'password': password,
|
||||
}),
|
||||
)
|
||||
.timeout(
|
||||
const Duration(seconds: timeout),
|
||||
onTimeout: () {
|
||||
return Response('', 400);
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
var status = authoriseFromJson(response.body)
|
||||
.status!; //Authorise.fromJson(json.decode(response.body)).status!;
|
||||
loginId = username;
|
||||
if (status.isEmpty || status.contains('failed')) {
|
||||
return authoriseFromJson(response.body).message!;
|
||||
} else {
|
||||
setSharedPref('authkey', authoriseFromJson(response.body).token!);
|
||||
setSharedPref('tokenValidity',
|
||||
authoriseFromJson(response.body).validUntil.toString());
|
||||
setSharedPref('isLogin', true);
|
||||
|
||||
header = {
|
||||
"Authorization": "Bearer ${authoriseFromJson(response.body).token!}",
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
|
||||
return "Successfully Logged In";
|
||||
}
|
||||
} else if (response.statusCode == 400) {
|
||||
return "Cannot Reach Server";
|
||||
} else if (response.statusCode == 404) {
|
||||
print(response.body);
|
||||
return "Not Found";
|
||||
} else {
|
||||
return "failed";
|
||||
}
|
||||
} on SocketException {
|
||||
return "Can not reach server";
|
||||
} on HttpException {
|
||||
return "Couldnt find the post";
|
||||
} on FormatException {
|
||||
return "Bad response format";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
import 'dart:io';
|
||||
import 'package:school_management_system/components/default_values.dart';
|
||||
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final calendar = calendarFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
Calendar calendarFromJson(String str) => Calendar.fromJson(json.decode(str));
|
||||
|
||||
String calendarToJson(Calendar data) => json.encode(data.toJson());
|
||||
|
||||
class Calendar {
|
||||
final String? calenderid;
|
||||
final String? session;
|
||||
final String? semester;
|
||||
final List<Calenderrdetail>? calenderrdetails;
|
||||
|
||||
Calendar({
|
||||
this.calenderid,
|
||||
this.session,
|
||||
this.semester,
|
||||
this.calenderrdetails,
|
||||
});
|
||||
|
||||
factory Calendar.fromJson(Map<String, dynamic> json) => Calendar(
|
||||
calenderid: json["calenderid"],
|
||||
session: json["session"],
|
||||
semester: json["semester"],
|
||||
calenderrdetails: json["calenderrdetails"] == null
|
||||
? []
|
||||
: List<Calenderrdetail>.from(json["calenderrdetails"]!
|
||||
.map((x) => Calenderrdetail.fromJson(x))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"calenderid": calenderid,
|
||||
"session": session,
|
||||
"semester": semester,
|
||||
"calenderrdetails": calenderrdetails == null
|
||||
? []
|
||||
: List<dynamic>.from(calenderrdetails!.map((x) => x.toJson())),
|
||||
};
|
||||
}
|
||||
|
||||
class Calenderrdetail {
|
||||
final String? note;
|
||||
final String? event;
|
||||
final bool? allday;
|
||||
final DateTime? startdate;
|
||||
final DateTime? enddate;
|
||||
final String? endtime;
|
||||
final String? starttime;
|
||||
final String? frequency;
|
||||
final String? interval;
|
||||
final String? dayofweek;
|
||||
|
||||
Calenderrdetail({
|
||||
this.note,
|
||||
this.event,
|
||||
this.allday,
|
||||
this.startdate,
|
||||
this.enddate,
|
||||
this.endtime,
|
||||
this.starttime,
|
||||
this.frequency,
|
||||
this.interval,
|
||||
this.dayofweek,
|
||||
});
|
||||
|
||||
factory Calenderrdetail.fromJson(Map<String, dynamic> json) =>
|
||||
Calenderrdetail(
|
||||
note: json["note"],
|
||||
event: json["event"],
|
||||
allday: json["allday"],
|
||||
startdate: json["startdate"] == null
|
||||
? null
|
||||
: DateTime.parse(json["startdate"]),
|
||||
enddate:
|
||||
json["enddate"] == null ? null : DateTime.parse(json["enddate"]),
|
||||
endtime: json["endtime"],
|
||||
starttime: json["starttime"],
|
||||
frequency: json["frequency"],
|
||||
interval: json["interval"],
|
||||
dayofweek: json["dayofweek"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"note": note,
|
||||
"event": event,
|
||||
"allday": allday,
|
||||
"startdate":
|
||||
"${startdate!.year.toString().padLeft(4, '0')}-${startdate!.month.toString().padLeft(2, '0')}-${startdate!.day.toString().padLeft(2, '0')}",
|
||||
"enddate":
|
||||
"${enddate!.year.toString().padLeft(4, '0')}-${enddate!.month.toString().padLeft(2, '0')}-${enddate!.day.toString().padLeft(2, '0')}",
|
||||
"endtime": endtime,
|
||||
"starttime": starttime,
|
||||
"frequency": frequency,
|
||||
"interval": interval,
|
||||
"dayofweek": dayofweek,
|
||||
};
|
||||
}
|
||||
|
||||
Future<Calendar> getStudentCalender(
|
||||
String calenderid, String session, String semester) async {
|
||||
try {
|
||||
final response = await client
|
||||
.get(
|
||||
Uri.parse(
|
||||
"$baseUrl/calender/getCalender/$calenderid?session=$session&semester=$semester"),
|
||||
headers: header,
|
||||
)
|
||||
.timeout(
|
||||
const Duration(seconds: timeout),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return calendarFromJson(response.body);
|
||||
} else {
|
||||
return calendarFromJson("");
|
||||
}
|
||||
} on SocketException {
|
||||
return throw Exception();
|
||||
} on HttpException {
|
||||
return throw Exception();
|
||||
} on FormatException {
|
||||
return throw Exception();
|
||||
}
|
||||
}
|
||||
|
||||
Future<Calendar> getSchoolCalender(
|
||||
String calenderid, String session, String semester) async {
|
||||
try {
|
||||
final response = await client
|
||||
.get(
|
||||
Uri.parse(
|
||||
"$baseUrl/calender/getCalender/$calenderid?session=$session&semester=$semester"),
|
||||
headers: header,
|
||||
)
|
||||
.timeout(
|
||||
const Duration(seconds: timeout),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return calendarFromJson(response.body);
|
||||
} else {
|
||||
return calendarFromJson(response.body);
|
||||
}
|
||||
} on SocketException {
|
||||
return throw Exception();
|
||||
} on HttpException {
|
||||
return throw Exception();
|
||||
} on FormatException {
|
||||
return throw Exception();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:school_management_system/components/default_values.dart';
|
||||
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final result = resultFromJson(jsonString);
|
||||
|
||||
Result resultFromJson(String str) => Result.fromJson(json.decode(str));
|
||||
|
||||
String resultToJson(Result data) => json.encode(data.toJson());
|
||||
|
||||
class Result {
|
||||
final String? studentid;
|
||||
final String? session;
|
||||
final String? comments;
|
||||
final bool? resit;
|
||||
final String? semester;
|
||||
final List<Score>? scores;
|
||||
|
||||
Result({
|
||||
this.studentid,
|
||||
this.session,
|
||||
this.comments,
|
||||
this.resit,
|
||||
this.semester,
|
||||
this.scores,
|
||||
});
|
||||
|
||||
factory Result.fromJson(Map<String, dynamic> json) => Result(
|
||||
studentid: json["studentid"],
|
||||
session: json["session"],
|
||||
comments: json["comments"],
|
||||
resit: json["resit"],
|
||||
semester: json["semester"],
|
||||
scores: json["scores"] == null
|
||||
? []
|
||||
: List<Score>.from(json["scores"]!.map((x) => Score.fromJson(x))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"studentid": studentid,
|
||||
"session": session,
|
||||
"comments": comments,
|
||||
"resit": resit,
|
||||
"semester": semester,
|
||||
"scores": scores == null
|
||||
? []
|
||||
: List<dynamic>.from(scores!.map((x) => x.toJson())),
|
||||
};
|
||||
}
|
||||
|
||||
class Score {
|
||||
final String? module;
|
||||
final double? score;
|
||||
|
||||
Score({
|
||||
this.module,
|
||||
this.score,
|
||||
});
|
||||
|
||||
factory Score.fromJson(Map<String, dynamic> json) => Score(
|
||||
module: json["module"],
|
||||
score: json["score"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"module": module,
|
||||
"score": score,
|
||||
};
|
||||
}
|
||||
|
||||
Map<String, List<String>> sessionFromJson(String str) =>
|
||||
Map.from(json.decode(str)).map((k, v) =>
|
||||
MapEntry<String, List<String>>(k, List<String>.from(v.map((x) => x))));
|
||||
|
||||
String sessionToJson(Map<String, List<String>> data) =>
|
||||
json.encode(Map.from(data).map((k, v) =>
|
||||
MapEntry<String, dynamic>(k, List<dynamic>.from(v.map((x) => x)))));
|
||||
|
||||
Future<Map<String, List<String>>> getStudentSemester(String session) async {
|
||||
try {
|
||||
final response = await client
|
||||
.get(
|
||||
Uri.parse("$baseUrl/results/getSemester/$loginId?session=$session"),
|
||||
headers: header)
|
||||
.timeout(
|
||||
const Duration(seconds: timeout),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
if (response.body.isNotEmpty) {
|
||||
return sessionFromJson(response.body);
|
||||
} else {
|
||||
return sessionFromJson("");
|
||||
}
|
||||
} else {
|
||||
return sessionFromJson("");
|
||||
}
|
||||
} on SocketException {
|
||||
return throw Exception();
|
||||
} on HttpException {
|
||||
return throw Exception();
|
||||
} on FormatException {
|
||||
return throw Exception();
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, List<String>>> getStudentSession() async {
|
||||
try {
|
||||
final response = await client
|
||||
.get(
|
||||
Uri.parse("$baseUrl/results/getSession/$loginId"),
|
||||
headers: header,
|
||||
)
|
||||
.timeout(
|
||||
const Duration(seconds: timeout),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
if (response.body.isNotEmpty) {
|
||||
return sessionFromJson(response.body);
|
||||
} else {
|
||||
return sessionFromJson("");
|
||||
}
|
||||
} else {
|
||||
return sessionFromJson("");
|
||||
}
|
||||
} on SocketException {
|
||||
return throw Exception();
|
||||
} on HttpException {
|
||||
return throw Exception();
|
||||
} on FormatException {
|
||||
return throw Exception();
|
||||
}
|
||||
}
|
||||
|
||||
Future<Result> getStudentResult(String session, String semester) async {
|
||||
try {
|
||||
final response = await client
|
||||
.get(
|
||||
Uri.parse(
|
||||
"$baseUrl/results/list/$loginId?session=$session&semester=$semester"),
|
||||
headers: header,
|
||||
)
|
||||
.timeout(
|
||||
const Duration(seconds: timeout),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
if (response.body.isNotEmpty) {
|
||||
return resultFromJson(response.body);
|
||||
} else {
|
||||
return resultFromJson("");
|
||||
}
|
||||
} else {
|
||||
return resultFromJson("");
|
||||
}
|
||||
} on SocketException {
|
||||
return throw Exception();
|
||||
} on HttpException {
|
||||
return throw Exception();
|
||||
} on FormatException {
|
||||
return throw Exception();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import 'dart:io';
|
||||
import 'package:school_management_system/components/default_values.dart';
|
||||
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final session = sessionFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
Session sessionFromJson(String str) => Session.fromJson(json.decode(str));
|
||||
|
||||
String sessionToJson(Session data) => json.encode(data.toJson());
|
||||
|
||||
class Session {
|
||||
final String? session;
|
||||
final String? semester;
|
||||
final DateTime? startdate;
|
||||
final DateTime? enddate;
|
||||
final String? status;
|
||||
|
||||
Session({
|
||||
this.session,
|
||||
this.semester,
|
||||
this.startdate,
|
||||
this.enddate,
|
||||
this.status,
|
||||
});
|
||||
|
||||
factory Session.fromJson(Map<String, dynamic> json) => Session(
|
||||
session: json["session"],
|
||||
semester: json["semester"],
|
||||
startdate: json["startdate"] == null
|
||||
? null
|
||||
: DateTime.parse(json["startdate"]),
|
||||
enddate:
|
||||
json["enddate"] == null ? null : DateTime.parse(json["enddate"]),
|
||||
status: json["status"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"session": session,
|
||||
"semester": semester,
|
||||
"startdate":
|
||||
"${startdate!.year.toString().padLeft(4, '0')}-${startdate!.month.toString().padLeft(2, '0')}-${startdate!.day.toString().padLeft(2, '0')}",
|
||||
"enddate":
|
||||
"${enddate!.year.toString().padLeft(4, '0')}-${enddate!.month.toString().padLeft(2, '0')}-${enddate!.day.toString().padLeft(2, '0')}",
|
||||
"status": status,
|
||||
};
|
||||
}
|
||||
|
||||
Future getCurrentSession() async {
|
||||
try {
|
||||
final response = await client
|
||||
.get(
|
||||
Uri.parse("$baseUrl/session/getCurrentSession"),
|
||||
headers: header,
|
||||
)
|
||||
.timeout(
|
||||
const Duration(seconds: timeout),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
session = sessionFromJson(response.body).session!;
|
||||
semester = sessionFromJson(response.body).semester!;
|
||||
//return sessionFromJson(response.body);
|
||||
} else {
|
||||
return sessionFromJson("");
|
||||
}
|
||||
} on SocketException {
|
||||
throw Exception();
|
||||
} on HttpException {
|
||||
throw Exception();
|
||||
} on FormatException {
|
||||
throw Exception();
|
||||
}
|
||||
}
|
||||
|
||||
// Future<List<String>> getSession() async {
|
||||
// try {
|
||||
// final response = await client.get(
|
||||
// Uri.parse("$baseUrl/session/getSessionsList"),
|
||||
// headers: header,
|
||||
// );
|
||||
|
||||
// if (response.statusCode == 200) {
|
||||
// if (response.body.isNotEmpty) {
|
||||
// return sessionFromJson(response.body);
|
||||
// } else {
|
||||
// return sessionFromJson("");
|
||||
// }
|
||||
// } else {
|
||||
// return sessionFromJson("");
|
||||
// }
|
||||
// } on SocketException {
|
||||
// return throw Exception();
|
||||
// } on HttpException {
|
||||
// return throw Exception();
|
||||
// } on FormatException {
|
||||
// return throw Exception();
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,311 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:school_management_system/components/default_values.dart';
|
||||
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final student = studentFromJson(jsonString);
|
||||
|
||||
Student studentFromJson(String str) => Student.fromJson(json.decode(str));
|
||||
|
||||
String studentToJson(Student data) => json.encode(data.toJson());
|
||||
|
||||
class Student {
|
||||
final String? studentid;
|
||||
final String? title;
|
||||
final String? firstname;
|
||||
final String? lastname;
|
||||
final String? schoolemail;
|
||||
final DateTime? dateofbirth;
|
||||
final String? currentyear;
|
||||
final String? currentsession;
|
||||
final String? homeaddress;
|
||||
final String? mobilenumber;
|
||||
final String? emailaddress;
|
||||
final List<Nextofkindetail>? nextofkindetails;
|
||||
final List<Guardiandetail>? guardiandetails;
|
||||
final List<Medicaldetail>? medicaldetails;
|
||||
final List<Coursedetail>? coursedetails;
|
||||
final String? gender;
|
||||
final Map<String, List<String>>? sessiondetails;
|
||||
final Map<String, List<ModuleDetail>>? moduledetails;
|
||||
|
||||
Student({
|
||||
this.studentid,
|
||||
this.title,
|
||||
this.firstname,
|
||||
this.lastname,
|
||||
this.schoolemail,
|
||||
this.dateofbirth,
|
||||
this.currentyear,
|
||||
this.currentsession,
|
||||
this.homeaddress,
|
||||
this.mobilenumber,
|
||||
this.emailaddress,
|
||||
this.nextofkindetails,
|
||||
this.guardiandetails,
|
||||
this.medicaldetails,
|
||||
this.coursedetails,
|
||||
this.gender,
|
||||
this.sessiondetails,
|
||||
this.moduledetails,
|
||||
});
|
||||
|
||||
factory Student.fromJson(Map<String, dynamic> json) => Student(
|
||||
studentid: json["studentid"],
|
||||
title: json["title"],
|
||||
firstname: json["firstname"],
|
||||
lastname: json["lastname"],
|
||||
schoolemail: json["schoolemail"],
|
||||
dateofbirth: json["dateofbirth"] == null
|
||||
? null
|
||||
: DateTime.parse(json["dateofbirth"]),
|
||||
currentyear: json["currentyear"],
|
||||
currentsession: json["currentsession"],
|
||||
homeaddress: json["homeaddress"],
|
||||
mobilenumber: json["mobilenumber"],
|
||||
emailaddress: json["emailaddress"],
|
||||
nextofkindetails: json["nextofkindetails"] == null
|
||||
? []
|
||||
: List<Nextofkindetail>.from(json["nextofkindetails"]!
|
||||
.map((x) => Nextofkindetail.fromJson(x))),
|
||||
guardiandetails: json["guardiandetails"] == null
|
||||
? []
|
||||
: List<Guardiandetail>.from(json["guardiandetails"]!
|
||||
.map((x) => Guardiandetail.fromJson(x))),
|
||||
medicaldetails: json["medicaldetails"] == null
|
||||
? []
|
||||
: List<Medicaldetail>.from(
|
||||
json["medicaldetails"]!.map((x) => Medicaldetail.fromJson(x))),
|
||||
coursedetails: json["coursedetails"] == null
|
||||
? []
|
||||
: List<Coursedetail>.from(
|
||||
json["coursedetails"]!.map((x) => Coursedetail.fromJson(x))),
|
||||
gender: json["gender"],
|
||||
sessiondetails: Map.from(json["sessiondetails"]!).map((k, v) =>
|
||||
MapEntry<String, List<String>>(
|
||||
k, List<String>.from(v.map((x) => x)))),
|
||||
moduledetails: Map.from(json["moduledetails"]!).map((k, v) => MapEntry<
|
||||
String, List<ModuleDetail>>(k,
|
||||
List<ModuleDetail>.from(v.map((x) => ModuleDetail.fromJson(x))))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"studentid": studentid,
|
||||
"title": title,
|
||||
"firstname": firstname,
|
||||
"lastname": lastname,
|
||||
"schoolemail": schoolemail,
|
||||
"dateofbirth":
|
||||
"${dateofbirth!.year.toString().padLeft(4, '0')}-${dateofbirth!.month.toString().padLeft(2, '0')}-${dateofbirth!.day.toString().padLeft(2, '0')}",
|
||||
"currentyear": currentyear,
|
||||
"currentsession": currentsession,
|
||||
"homeaddress": homeaddress,
|
||||
"mobilenumber": mobilenumber,
|
||||
"emailaddress": emailaddress,
|
||||
"nextofkindetails": nextofkindetails == null
|
||||
? []
|
||||
: List<dynamic>.from(nextofkindetails!.map((x) => x.toJson())),
|
||||
"guardiandetails": guardiandetails == null
|
||||
? []
|
||||
: List<dynamic>.from(guardiandetails!.map((x) => x.toJson())),
|
||||
"medicaldetails": medicaldetails == null
|
||||
? []
|
||||
: List<dynamic>.from(medicaldetails!.map((x) => x.toJson())),
|
||||
"coursedetails": coursedetails == null
|
||||
? []
|
||||
: List<dynamic>.from(coursedetails!.map((x) => x.toJson())),
|
||||
"gender": gender,
|
||||
"sessiondetails": Map.from(sessiondetails!).map((k, v) =>
|
||||
MapEntry<String, dynamic>(k, List<dynamic>.from(v.map((x) => x)))),
|
||||
"moduledetails": Map.from(moduledetails!).map((k, v) =>
|
||||
MapEntry<String, dynamic>(
|
||||
k, List<dynamic>.from(v.map((x) => x.toJson())))),
|
||||
};
|
||||
}
|
||||
|
||||
class Coursedetail {
|
||||
final String? courseofstudy;
|
||||
final String? coursetype;
|
||||
final String? coursequalification;
|
||||
final String? coursemode;
|
||||
|
||||
Coursedetail({
|
||||
this.courseofstudy,
|
||||
this.coursetype,
|
||||
this.coursequalification,
|
||||
this.coursemode,
|
||||
});
|
||||
|
||||
factory Coursedetail.fromJson(Map<String, dynamic> json) => Coursedetail(
|
||||
courseofstudy: json["courseofstudy"],
|
||||
coursetype: json["coursetype"],
|
||||
coursequalification: json["coursequalification"],
|
||||
coursemode: json["coursemode"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"courseofstudy": courseofstudy,
|
||||
"coursetype": coursetype,
|
||||
"coursequalification": coursequalification,
|
||||
"coursemode": coursemode,
|
||||
};
|
||||
}
|
||||
|
||||
class Guardiandetail {
|
||||
final String? guardianname;
|
||||
final String? guardiancontact;
|
||||
final String? guardianaddress;
|
||||
final String? guardianrelationship;
|
||||
|
||||
Guardiandetail({
|
||||
this.guardianname,
|
||||
this.guardiancontact,
|
||||
this.guardianaddress,
|
||||
this.guardianrelationship,
|
||||
});
|
||||
|
||||
factory Guardiandetail.fromJson(Map<String, dynamic> json) => Guardiandetail(
|
||||
guardianname: json["guardianname"],
|
||||
guardiancontact: json["guardiancontact"],
|
||||
guardianaddress: json["guardianaddress"],
|
||||
guardianrelationship: json["guardianrelationship"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"guardianname": guardianname,
|
||||
"guardiancontact": guardiancontact,
|
||||
"guardianaddress": guardianaddress,
|
||||
"guardianrelationship": guardianrelationship,
|
||||
};
|
||||
}
|
||||
|
||||
class Medicaldetail {
|
||||
final String? weight;
|
||||
final String? height;
|
||||
final String? genotype;
|
||||
final String? bloodgroup;
|
||||
final String? medicalcondition;
|
||||
final String? allergies;
|
||||
final bool? dnr;
|
||||
final String? emergencycontactname;
|
||||
final String? emergencycontactnumber;
|
||||
final String? emergencycontractrelationship;
|
||||
|
||||
Medicaldetail({
|
||||
this.weight,
|
||||
this.height,
|
||||
this.genotype,
|
||||
this.bloodgroup,
|
||||
this.medicalcondition,
|
||||
this.allergies,
|
||||
this.dnr,
|
||||
this.emergencycontactname,
|
||||
this.emergencycontactnumber,
|
||||
this.emergencycontractrelationship,
|
||||
});
|
||||
|
||||
factory Medicaldetail.fromJson(Map<String, dynamic> json) => Medicaldetail(
|
||||
weight: json["weight"],
|
||||
height: json["height"],
|
||||
genotype: json["genotype"],
|
||||
bloodgroup: json["bloodgroup"],
|
||||
medicalcondition: json["medicalcondition"],
|
||||
allergies: json["allergies"],
|
||||
dnr: json["dnr"],
|
||||
emergencycontactname: json["emergencycontactname"],
|
||||
emergencycontactnumber: json["emergencycontactnumber"],
|
||||
emergencycontractrelationship: json["emergencycontractrelationship"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"weight": weight,
|
||||
"height": height,
|
||||
"genotype": genotype,
|
||||
"bloodgroup": bloodgroup,
|
||||
"medicalcondition": medicalcondition,
|
||||
"allergies": allergies,
|
||||
"dnr": dnr,
|
||||
"emergencycontactname": emergencycontactname,
|
||||
"emergencycontactnumber": emergencycontactnumber,
|
||||
"emergencycontractrelationship": emergencycontractrelationship,
|
||||
};
|
||||
}
|
||||
|
||||
class ModuleDetail {
|
||||
final String? modulecode;
|
||||
final String? modulename;
|
||||
|
||||
ModuleDetail({
|
||||
this.modulecode,
|
||||
this.modulename,
|
||||
});
|
||||
|
||||
factory ModuleDetail.fromJson(Map<String, dynamic> json) => ModuleDetail(
|
||||
modulecode: json["modulecode"],
|
||||
modulename: json["modulename"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"modulecode": modulecode,
|
||||
"modulename": modulename,
|
||||
};
|
||||
}
|
||||
|
||||
class Nextofkindetail {
|
||||
final String? nextofkinname;
|
||||
final String? nextofkincontact;
|
||||
final String? nextofkinaddress;
|
||||
final String? nextofkinrelationship;
|
||||
|
||||
Nextofkindetail({
|
||||
this.nextofkinname,
|
||||
this.nextofkincontact,
|
||||
this.nextofkinaddress,
|
||||
this.nextofkinrelationship,
|
||||
});
|
||||
|
||||
factory Nextofkindetail.fromJson(Map<String, dynamic> json) =>
|
||||
Nextofkindetail(
|
||||
nextofkinname: json["nextofkinname"],
|
||||
nextofkincontact: json["nextofkincontact"],
|
||||
nextofkinaddress: json["nextofkinaddress"],
|
||||
nextofkinrelationship: json["nextofkinrelationship"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"nextofkinname": nextofkinname,
|
||||
"nextofkincontact": nextofkincontact,
|
||||
"nextofkinaddress": nextofkinaddress,
|
||||
"nextofkinrelationship": nextofkinrelationship,
|
||||
};
|
||||
}
|
||||
|
||||
Future<Student> getStudentDetail(String studentId) async {
|
||||
try {
|
||||
final response = await client
|
||||
.get(
|
||||
Uri.parse("$baseUrl/student/$studentId"),
|
||||
headers: header,
|
||||
)
|
||||
.timeout(
|
||||
const Duration(seconds: timeout),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
if (response.body.isNotEmpty) {
|
||||
return studentFromJson(response.body);
|
||||
} else {
|
||||
return studentFromJson("");
|
||||
}
|
||||
} else {
|
||||
return studentFromJson("");
|
||||
}
|
||||
} on SocketException {
|
||||
return throw Exception();
|
||||
} on HttpException {
|
||||
return throw Exception();
|
||||
} on FormatException {
|
||||
return throw Exception();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user