selfprivacy.org.app/lib/logic/models/server_status.dart

51 lines
1.2 KiB
Dart
Raw Normal View History

2021-01-21 21:01:42 +00:00
class ServerStatus {
ServerStatus({
2021-03-15 15:39:44 +00:00
required this.http,
2021-01-21 21:01:42 +00:00
this.imap = StatusTypes.nodata,
this.smtp = StatusTypes.nodata,
});
2022-06-05 19:36:32 +00:00
final StatusTypes http;
final StatusTypes imap;
final StatusTypes smtp;
2021-01-21 21:01:42 +00:00
2022-06-05 19:36:32 +00:00
ServerStatus fromJson(final Map<String, dynamic> json) => ServerStatus(
2022-06-09 21:13:06 +00:00
http: statusTypeFromNumber(json['http']),
imap: statusTypeFromNumber(json['imap']),
smtp: statusTypeFromNumber(json['smtp']),
);
2021-01-21 21:01:42 +00:00
}
2022-06-05 19:36:32 +00:00
StatusTypes statusTypeFromNumber(final int? number) {
2021-01-21 21:01:42 +00:00
if (number == 0) {
return StatusTypes.ok;
} else if (number == 1) {
return StatusTypes.error;
} else if (number == 2) {
return StatusTypes.wrongArgument;
} else if (number == 3) {
return StatusTypes.wrongFunction;
} else if (number == 4) {
return StatusTypes.noRights;
} else if (number == 5) {
return StatusTypes.notInstalled;
} else if (number == 6) {
return StatusTypes.notConfigured;
} else if (number == 7) {
return StatusTypes.off;
} else {
throw Exception('wrong status');
}
}
enum StatusTypes {
ok,
error,
wrongArgument,
wrongFunction,
noRights,
notInstalled,
notConfigured,
off,
nodata,
}