Merge branch 'develop' into feature-highEduGraduationCalculator
# Conflicts: # lib/view/pages/overhang.dart
This commit is contained in:
@ -5,6 +5,6 @@ class ApiError {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "ApiError: $message";
|
||||
return 'ApiError: $message';
|
||||
}
|
||||
}
|
@ -6,11 +6,11 @@ import 'getHolidaysResponse.dart';
|
||||
|
||||
class GetHolidays {
|
||||
Future<GetHolidaysResponse> query() async {
|
||||
String response = (await http.get(Uri.parse("https://ferien-api.de/api/v1/holidays/HE"))).body;
|
||||
String response = (await http.get(Uri.parse('https://ferien-api.de/api/v1/holidays/HE'))).body;
|
||||
return GetHolidaysResponse(
|
||||
List<GetHolidaysResponseObject>.from(
|
||||
jsonDecode(response).map<GetHolidaysResponseObject>(
|
||||
(dynamic i) => GetHolidaysResponseObject.fromJson(i)
|
||||
GetHolidaysResponseObject.fromJson
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -6,7 +6,7 @@ import 'getHolidaysResponse.dart';
|
||||
|
||||
class GetHolidaysCache extends RequestCache<GetHolidaysResponse> {
|
||||
GetHolidaysCache({onUpdate, renew}) : super(RequestCache.cacheDay, onUpdate, renew: renew) {
|
||||
start("MarianumMobile", "state-holidays");
|
||||
start('MarianumMobile', 'state-holidays');
|
||||
}
|
||||
|
||||
@override
|
||||
@ -15,6 +15,7 @@ class GetHolidaysCache extends RequestCache<GetHolidaysResponse> {
|
||||
return GetHolidaysResponse(
|
||||
List<GetHolidaysResponseObject>.from(
|
||||
parsedListJson.map<GetHolidaysResponseObject>(
|
||||
// ignore: unnecessary_lambdas
|
||||
(dynamic i) => GetHolidaysResponseObject.fromJson(i)
|
||||
)
|
||||
)
|
||||
|
@ -11,21 +11,21 @@ import 'autocompleteResponse.dart';
|
||||
class AutocompleteApi {
|
||||
Future<AutocompleteResponse> find(String query) async {
|
||||
Map<String, dynamic> getParameters = {
|
||||
"search": query,
|
||||
"itemType": " ",
|
||||
"itemId": " ",
|
||||
"shareTypes[]": ["0"],
|
||||
"limit": "10",
|
||||
'search': query,
|
||||
'itemType': ' ',
|
||||
'itemId': ' ',
|
||||
'shareTypes[]': ['0'],
|
||||
'limit': '10',
|
||||
};
|
||||
|
||||
Map<String, String> headers = {};
|
||||
headers.putIfAbsent("Accept", () => "application/json");
|
||||
headers.putIfAbsent("OCS-APIRequest", () => "true");
|
||||
headers.putIfAbsent('Accept', () => 'application/json');
|
||||
headers.putIfAbsent('OCS-APIRequest', () => 'true');
|
||||
|
||||
Uri endpoint = Uri.https("${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}", "${EndpointData().nextcloud().path}/ocs/v2.php/core/autocomplete/get", getParameters);
|
||||
Uri endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/core/autocomplete/get', getParameters);
|
||||
|
||||
Response response = await http.get(endpoint, headers: headers);
|
||||
if(response.statusCode != HttpStatus.ok) throw Exception("Api call failed with ${response.statusCode}: ${response.body}");
|
||||
if(response.statusCode != HttpStatus.ok) throw Exception('Api call failed with ${response.statusCode}: ${response.body}');
|
||||
String result = response.body;
|
||||
return AutocompleteResponse.fromJson(jsonDecode(result)['ocs']);
|
||||
}
|
||||
|
@ -10,14 +10,14 @@ import 'fileSharingApiParams.dart';
|
||||
class FileSharingApi {
|
||||
Future<void> share(FileSharingApiParams query) async {
|
||||
Map<String, String> headers = {};
|
||||
headers.putIfAbsent("Accept", () => "application/json");
|
||||
headers.putIfAbsent("OCS-APIRequest", () => "true");
|
||||
headers.putIfAbsent('Accept', () => 'application/json');
|
||||
headers.putIfAbsent('OCS-APIRequest', () => 'true');
|
||||
|
||||
Uri endpoint = Uri.https("${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}", "${EndpointData().nextcloud().path}/ocs/v2.php/apps/files_sharing/api/v1/shares", query.toJson().map((key, value) => MapEntry(key, value.toString())));
|
||||
Uri endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/apps/files_sharing/api/v1/shares', query.toJson().map((key, value) => MapEntry(key, value.toString())));
|
||||
Response response = await http.post(endpoint, headers: headers);
|
||||
|
||||
if(response.statusCode != HttpStatus.ok) {
|
||||
throw Exception("Api call failed with ${response.statusCode}: ${response.body}");
|
||||
throw Exception('Api call failed with ${response.statusCode}: ${response.body}');
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ class GetChat extends TalkApi<GetChatResponse> {
|
||||
String chatToken;
|
||||
|
||||
GetChatParams params;
|
||||
GetChat(this.chatToken, this.params) : super("v1/chat/$chatToken", null, getParameters: params.toJson());
|
||||
GetChat(this.chatToken, this.params) : super('v1/chat/$chatToken', null, getParameters: params.toJson());
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -9,7 +9,7 @@ class GetChatCache extends RequestCache<GetChatResponse> {
|
||||
String chatToken;
|
||||
|
||||
GetChatCache({required onUpdate, required this.chatToken}) : super(RequestCache.cacheNothing, onUpdate) {
|
||||
start("MarianumMobile", "nc-chat-$chatToken");
|
||||
start('MarianumMobile', 'nc-chat-$chatToken');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -61,21 +61,21 @@ class GetChatResponseObject {
|
||||
|
||||
static GetChatResponseObject getDateDummy(int timestamp) {
|
||||
DateTime elementDate = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
|
||||
return getTextDummy(Jiffy.parseFromDateTime(elementDate).format(pattern: "dd.MM.yyyy"));
|
||||
return getTextDummy(Jiffy.parseFromDateTime(elementDate).format(pattern: 'dd.MM.yyyy'));
|
||||
}
|
||||
|
||||
static GetChatResponseObject getTextDummy(String text) {
|
||||
return GetChatResponseObject(
|
||||
0,
|
||||
"",
|
||||
'',
|
||||
GetRoomResponseObjectMessageActorType.user,
|
||||
"",
|
||||
"",
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
"",
|
||||
'',
|
||||
GetRoomResponseObjectMessageType.system,
|
||||
false,
|
||||
"",
|
||||
'',
|
||||
text,
|
||||
null,
|
||||
null,
|
||||
@ -113,10 +113,10 @@ class RichObjectString {
|
||||
}
|
||||
|
||||
enum RichObjectStringObjectType {
|
||||
@JsonValue("user") user,
|
||||
@JsonValue("group") group,
|
||||
@JsonValue("file") file,
|
||||
@JsonValue("guest") guest,
|
||||
@JsonValue("highlight") highlight,
|
||||
@JsonValue("talk-poll") talkPoll,
|
||||
@JsonValue('user') user,
|
||||
@JsonValue('group') group,
|
||||
@JsonValue('file') file,
|
||||
@JsonValue('guest') guest,
|
||||
@JsonValue('highlight') highlight,
|
||||
@JsonValue('talk-poll') talkPoll,
|
||||
}
|
@ -6,7 +6,7 @@ class RichObjectStringProcessor {
|
||||
if(data == null) return message;
|
||||
|
||||
data.forEach((key, value) {
|
||||
message = message.replaceAll(RegExp("{$key}"), value.name);
|
||||
message = message.replaceAll(RegExp('{$key}'), value.name);
|
||||
});
|
||||
|
||||
return message;
|
||||
|
@ -7,7 +7,7 @@ import 'createRoomParams.dart';
|
||||
class CreateRoom extends TalkApi {
|
||||
CreateRoomParams params;
|
||||
|
||||
CreateRoom(this.params) : super("v4/room", params);
|
||||
CreateRoom(this.params) : super('v4/room', params);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -7,7 +7,7 @@ import '../talkApi.dart';
|
||||
class DeleteMessage extends TalkApi {
|
||||
String chatToken;
|
||||
int messageId;
|
||||
DeleteMessage(this.chatToken, this.messageId) : super("v1/chat/$chatToken/$messageId", null);
|
||||
DeleteMessage(this.chatToken, this.messageId) : super('v1/chat/$chatToken/$messageId', null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -8,7 +8,7 @@ import 'deleteReactMessageParams.dart';
|
||||
class DeleteReactMessage extends TalkApi {
|
||||
String chatToken;
|
||||
int messageId;
|
||||
DeleteReactMessage({required this.chatToken, required this.messageId, required DeleteReactMessageParams params}) : super("v1/reaction/$chatToken/$messageId", params);
|
||||
DeleteReactMessage({required this.chatToken, required this.messageId, required DeleteReactMessageParams params}) : super('v1/reaction/$chatToken/$messageId', params);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -7,7 +7,7 @@ import 'getParticipantsResponse.dart';
|
||||
|
||||
class GetParticipants extends TalkApi<GetParticipantsResponse> {
|
||||
String token;
|
||||
GetParticipants(this.token) : super("v4/room/$token/participants", null);
|
||||
GetParticipants(this.token) : super('v4/room/$token/participants', null);
|
||||
|
||||
@override
|
||||
GetParticipantsResponse assemble(String raw) {
|
||||
|
@ -8,7 +8,7 @@ class GetParticipantsCache extends RequestCache<GetParticipantsResponse> {
|
||||
String chatToken;
|
||||
|
||||
GetParticipantsCache({required onUpdate, required this.chatToken}) : super(RequestCache.cacheNothing, onUpdate) {
|
||||
start("MarianumMobile", "nc-chat-participants-$chatToken");
|
||||
start('MarianumMobile', 'nc-chat-participants-$chatToken');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -10,7 +10,7 @@ import 'getReactionsResponse.dart';
|
||||
class GetReactions extends TalkApi<GetReactionsResponse> {
|
||||
String chatToken;
|
||||
int messageId;
|
||||
GetReactions({required this.chatToken, required this.messageId}) : super("v1/reaction/$chatToken/$messageId", null);
|
||||
GetReactions({required this.chatToken, required this.messageId}) : super('v1/reaction/$chatToken/$messageId', null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -28,6 +28,6 @@ class GetReactionsResponseObject {
|
||||
}
|
||||
|
||||
enum GetReactionsResponseObjectActorType {
|
||||
@JsonValue("guests") guests,
|
||||
@JsonValue("users") users,
|
||||
@JsonValue('guests') guests,
|
||||
@JsonValue('users') users,
|
||||
}
|
@ -6,7 +6,7 @@ import '../talkApi.dart';
|
||||
class LeaveRoom extends TalkApi {
|
||||
String chatToken;
|
||||
|
||||
LeaveRoom(this.chatToken) : super("v4/room/$chatToken/participants/self", null);
|
||||
LeaveRoom(this.chatToken) : super('v4/room/$chatToken/participants/self', null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -8,7 +8,7 @@ import 'reactMessageParams.dart';
|
||||
class ReactMessage extends TalkApi {
|
||||
String chatToken;
|
||||
int messageId;
|
||||
ReactMessage({required this.chatToken, required this.messageId, required ReactMessageParams params}) : super("v1/reaction/$chatToken/$messageId", params);
|
||||
ReactMessage({required this.chatToken, required this.messageId, required ReactMessageParams params}) : super('v1/reaction/$chatToken/$messageId', params);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -9,7 +9,7 @@ import 'getRoomResponse.dart';
|
||||
|
||||
class GetRoom extends TalkApi<GetRoomResponse> {
|
||||
GetRoomParams params;
|
||||
GetRoom(this.params) : super("v4/room", null, getParameters: params.toJson());
|
||||
GetRoom(this.params) : super('v4/room', null, getParameters: params.toJson());
|
||||
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@ import 'getRoomResponse.dart';
|
||||
|
||||
class GetRoomCache extends RequestCache<GetRoomResponse> {
|
||||
GetRoomCache({onUpdate, renew}) : super(RequestCache.cacheMinute, onUpdate, renew: renew) {
|
||||
start("MarianumMobile", "nc-rooms");
|
||||
start('MarianumMobile', 'nc-rooms');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -19,10 +19,10 @@ class GetRoomResponse extends ApiResponse {
|
||||
final buffer = StringBuffer();
|
||||
|
||||
if(favoritesToTop) {
|
||||
buffer.write(chat.isFavorite ? "b" : "a");
|
||||
buffer.write(chat.isFavorite ? 'b' : 'a');
|
||||
}
|
||||
if(unreadToTop) {
|
||||
buffer.write(chat.unreadMessages > 0 ? "b" : "a");
|
||||
buffer.write(chat.unreadMessages > 0 ? 'b' : 'a');
|
||||
}
|
||||
|
||||
buffer.write(chat.lastActivity);
|
||||
@ -152,16 +152,16 @@ enum GetRoomResponseObjectParticipantNotificationLevel {
|
||||
// }
|
||||
|
||||
enum GetRoomResponseObjectMessageActorType {
|
||||
@JsonValue("deleted_users") deletedUsers,
|
||||
@JsonValue("users") user,
|
||||
@JsonValue("guests") guest,
|
||||
@JsonValue("bots") bot,
|
||||
@JsonValue("bridged") bridge,
|
||||
@JsonValue('deleted_users') deletedUsers,
|
||||
@JsonValue('users') user,
|
||||
@JsonValue('guests') guest,
|
||||
@JsonValue('bots') bot,
|
||||
@JsonValue('bridged') bridge,
|
||||
}
|
||||
|
||||
enum GetRoomResponseObjectMessageType {
|
||||
@JsonValue("comment") comment,
|
||||
@JsonValue("comment_deleted") deletedComment,
|
||||
@JsonValue("system") system,
|
||||
@JsonValue("command") command,
|
||||
@JsonValue('comment') comment,
|
||||
@JsonValue('comment_deleted') deletedComment,
|
||||
@JsonValue('system') system,
|
||||
@JsonValue('command') command,
|
||||
}
|
@ -7,7 +7,7 @@ import 'sendMessageParams.dart';
|
||||
|
||||
class SendMessage extends TalkApi {
|
||||
String chatToken;
|
||||
SendMessage(this.chatToken, SendMessageParams params) : super("v1/chat/$chatToken", params);
|
||||
SendMessage(this.chatToken, SendMessageParams params) : super('v1/chat/$chatToken', params);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -8,7 +8,7 @@ class SetFavorite extends TalkApi {
|
||||
String chatToken;
|
||||
bool favoriteState;
|
||||
|
||||
SetFavorite(this.chatToken, this.favoriteState) : super("v4/room/$chatToken/favorite", null);
|
||||
SetFavorite(this.chatToken, this.favoriteState) : super('v4/room/$chatToken/favorite', null);
|
||||
|
||||
@override
|
||||
assemble(String raw) {
|
||||
|
@ -10,7 +10,7 @@ class SetReadMarker extends TalkApi {
|
||||
bool readState;
|
||||
SetReadMarkerParams? setReadMarkerParams;
|
||||
|
||||
SetReadMarker(this.chatToken, this.readState, {this.setReadMarkerParams}) : super("v1/chat/$chatToken/read", null, getParameters: setReadMarkerParams?.toJson()) {
|
||||
SetReadMarker(this.chatToken, this.readState, {this.setReadMarkerParams}) : super('v1/chat/$chatToken/read', null, getParameters: setReadMarkerParams?.toJson()) {
|
||||
if(readState) assert(setReadMarkerParams?.lastReadMessage != null);
|
||||
}
|
||||
|
||||
|
@ -34,21 +34,21 @@ abstract class TalkApi<T extends ApiResponse?> extends ApiRequest {
|
||||
getParameters?.update(key, (value) => value.toString());
|
||||
});
|
||||
|
||||
Uri endpoint = Uri.https("${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}", "${EndpointData().nextcloud().path}/ocs/v2.php/apps/spreed/api/$path", getParameters);
|
||||
Uri endpoint = Uri.https('${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().domain}', '${EndpointData().nextcloud().path}/ocs/v2.php/apps/spreed/api/$path', getParameters);
|
||||
|
||||
headers ??= {};
|
||||
headers?.putIfAbsent("Accept", () => "application/json");
|
||||
headers?.putIfAbsent("OCS-APIRequest", () => "true");
|
||||
headers?.putIfAbsent('Accept', () => 'application/json');
|
||||
headers?.putIfAbsent('OCS-APIRequest', () => 'true');
|
||||
|
||||
http.Response? data;
|
||||
|
||||
try {
|
||||
data = await request(endpoint, body, headers);
|
||||
if(data == null) throw Exception("No response Data");
|
||||
if(data == null) throw Exception('No response Data');
|
||||
if(data.statusCode >= 400 || data.statusCode < 200) throw Exception("Response status code '${data.statusCode}' might indicate an error");
|
||||
} catch(e) {
|
||||
log(e.toString());
|
||||
throw ApiError("Request $endpoint could not be dispatched: ${e.toString()}");
|
||||
throw ApiError('Request $endpoint could not be dispatched: ${e.toString()}');
|
||||
}
|
||||
//dynamic jsonData = jsonDecode(data.body);
|
||||
|
||||
@ -59,10 +59,10 @@ abstract class TalkApi<T extends ApiResponse?> extends ApiRequest {
|
||||
return assembled;
|
||||
} catch (e) {
|
||||
// TODO report error
|
||||
log("Error assembling Talk API ${T.toString()} message: ${e.toString()} response on ${endpoint.path} with request body: $body and request headers: ${headers.toString()}");
|
||||
log('Error assembling Talk API ${T.toString()} message: ${e.toString()} response on ${endpoint.path} with request body: $body and request headers: ${headers.toString()}');
|
||||
}
|
||||
|
||||
throw Exception("Error assembling Talk API response");
|
||||
throw Exception('Error assembling Talk API response');
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,6 @@ class TalkError {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Talk - $status - ($code): $message";
|
||||
return 'Talk - $status - ($code): $message';
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ class CacheableFile {
|
||||
CacheableFile.fromDavFile(WebDavFile file) {
|
||||
path = file.path.path;
|
||||
isDirectory = file.isDirectory;
|
||||
name = file.isDirectory ? file.name : file.path.path.split("/").last;
|
||||
name = file.isDirectory ? file.name : file.path.path.split('/').last;
|
||||
mimeType = file.mimeType;
|
||||
size = file.size;
|
||||
eTag = file.etag;
|
||||
|
@ -14,7 +14,7 @@ class ListFiles extends WebdavApi<ListFilesParams> {
|
||||
@override
|
||||
Future<ListFilesResponse> run() async {
|
||||
List<WebDavFile> davFiles = (await (await WebdavApi.webdav).propfind(PathUri.parse(params.path))).toWebDavFiles();
|
||||
Set<CacheableFile> files = davFiles.map((e) => CacheableFile.fromDavFile(e)).toSet();
|
||||
Set<CacheableFile> files = davFiles.map(CacheableFile.fromDavFile).toSet();
|
||||
|
||||
// webdav handles subdirectories wrong, this is a fix
|
||||
// currently this fix is not needed anymore
|
||||
@ -26,7 +26,7 @@ class ListFiles extends WebdavApi<ListFilesParams> {
|
||||
// }
|
||||
|
||||
// somehow the current working folder is also listed, it is filtered here.
|
||||
files.removeWhere((element) => element.path == "/${params.path}/" || element.path == "/");
|
||||
files.removeWhere((element) => element.path == '/${params.path}/' || element.path == '/');
|
||||
|
||||
return ListFilesResponse(files);
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ class ListFilesCache extends RequestCache<ListFilesResponse> {
|
||||
String path;
|
||||
|
||||
ListFilesCache({required onUpdate, required this.path}) : super(RequestCache.cacheNothing, onUpdate) {
|
||||
var bytes = utf8.encode("MarianumMobile-$path");
|
||||
var bytes = utf8.encode('MarianumMobile-$path');
|
||||
String cacheName = md5.convert(bytes).toString();
|
||||
start("MarianumMobile", "wd-folder-$cacheName");
|
||||
start('MarianumMobile', 'wd-folder-$cacheName');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -35,7 +35,7 @@ class ListFilesResponse extends ApiResponse {
|
||||
|
||||
switch(sortOption) {
|
||||
case SortOption.date:
|
||||
buffer.write(Jiffy.parseFromMillisecondsSinceEpoch(file.modifiedAt?.millisecondsSinceEpoch ?? 0).format(pattern: "yyyyMMddhhmmss"));
|
||||
buffer.write(Jiffy.parseFromMillisecondsSinceEpoch(file.modifiedAt?.millisecondsSinceEpoch ?? 0).format(pattern: 'yyyyMMddhhmmss'));
|
||||
break;
|
||||
|
||||
case SortOption.name:
|
||||
|
@ -18,10 +18,10 @@ abstract class WebdavApi<T> extends ApiRequest {
|
||||
static Future<String> webdavConnectString = buildWebdavConnectString();
|
||||
|
||||
static Future<WebDavClient> establishWebdavConnection() async {
|
||||
return NextcloudClient(Uri.parse("https://${EndpointData().nextcloud().full()}"), password: AccountData().getPassword(), loginName: AccountData().getUsername()).webdav;
|
||||
return NextcloudClient(Uri.parse('https://${EndpointData().nextcloud().full()}'), password: AccountData().getPassword(), loginName: AccountData().getUsername()).webdav;
|
||||
}
|
||||
|
||||
static Future<String> buildWebdavConnectString() async {
|
||||
return "https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/remote.php/dav/files/${AccountData().getUsername()}/";
|
||||
return 'https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/remote.php/dav/files/${AccountData().getUsername()}/';
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ import '../../mhslApi.dart';
|
||||
import 'getBreakersResponse.dart';
|
||||
|
||||
class GetBreakers extends MhslApi<GetBreakersResponse> {
|
||||
GetBreakers() : super("breaker/");
|
||||
GetBreakers() : super('breaker/');
|
||||
|
||||
@override
|
||||
GetBreakersResponse assemble(String raw) {
|
||||
|
@ -6,7 +6,7 @@ import 'getBreakersResponse.dart';
|
||||
|
||||
class GetBreakersCache extends RequestCache<GetBreakersResponse> {
|
||||
GetBreakersCache({onUpdate, renew}) : super(RequestCache.cacheMinute, onUpdate, renew: renew) {
|
||||
start("MarianumMobile", "breakers");
|
||||
start('MarianumMobile', 'breakers');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -28,9 +28,9 @@ class GetBreakersReponseObject {
|
||||
}
|
||||
|
||||
enum BreakerArea {
|
||||
@JsonValue("GLOBAL") global,
|
||||
@JsonValue("TIMETABLE") timetable,
|
||||
@JsonValue("TALK") talk,
|
||||
@JsonValue("FILES") files,
|
||||
@JsonValue("MORE") more,
|
||||
@JsonValue('GLOBAL') global,
|
||||
@JsonValue('TIMETABLE') timetable,
|
||||
@JsonValue('TALK') talk,
|
||||
@JsonValue('FILES') files,
|
||||
@JsonValue('MORE') more,
|
||||
}
|
@ -9,11 +9,11 @@ import 'getCustomTimetableEventResponse.dart';
|
||||
|
||||
class GetCustomTimetableEvent extends MhslApi<GetCustomTimetableEventResponse> {
|
||||
GetCustomTimetableEventParams params;
|
||||
GetCustomTimetableEvent(this.params) : super("server/timetable/customEvents?user=${params.user}");
|
||||
GetCustomTimetableEvent(this.params) : super('server/timetable/customEvents?user=${params.user}');
|
||||
|
||||
@override
|
||||
GetCustomTimetableEventResponse assemble(String raw) {
|
||||
return GetCustomTimetableEventResponse.fromJson({"events": jsonDecode(raw)});
|
||||
return GetCustomTimetableEventResponse.fromJson({'events': jsonDecode(raw)});
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -9,7 +9,7 @@ class GetCustomTimetableEventCache extends RequestCache<GetCustomTimetableEventR
|
||||
GetCustomTimetableEventParams params;
|
||||
|
||||
GetCustomTimetableEventCache(this.params, {onUpdate, renew}) : super(RequestCache.cacheMinute, onUpdate, renew: renew) {
|
||||
start("MarianumMobile", "customTimetableEvents");
|
||||
start('MarianumMobile', 'customTimetableEvents');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -6,7 +6,7 @@ import '../../mhslApi.dart';
|
||||
import 'getMessagesResponse.dart';
|
||||
|
||||
class GetMessages extends MhslApi<GetMessagesResponse> {
|
||||
GetMessages() : super("message/messages.json");
|
||||
GetMessages() : super('message/messages.json');
|
||||
|
||||
|
||||
@override
|
||||
|
@ -6,7 +6,7 @@ import 'getMessagesResponse.dart';
|
||||
|
||||
class GetMessagesCache extends RequestCache<GetMessagesResponse> {
|
||||
GetMessagesCache({onUpdate, renew}) : super(RequestCache.cacheMinute, onUpdate, renew: renew) {
|
||||
start("MarianumMobile", "message");
|
||||
start('MarianumMobile', 'message');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -15,21 +15,21 @@ abstract class MhslApi<T> extends ApiRequest {
|
||||
T assemble(String raw);
|
||||
|
||||
Future<T> run() async {
|
||||
Uri endpoint = Uri.parse("https://mhsl.eu/marianum/marianummobile/$subpath");
|
||||
Uri endpoint = Uri.parse('https://mhsl.eu/marianum/marianummobile/$subpath');
|
||||
|
||||
http.Response? data = await request(endpoint);
|
||||
if(data == null) {
|
||||
throw ApiError("Request could not be dispatched!");
|
||||
throw ApiError('Request could not be dispatched!');
|
||||
}
|
||||
|
||||
if(data.statusCode > 299) {
|
||||
throw ApiError("Non 200 Status code from mhsl services: $subpath: ${data.statusCode}");
|
||||
throw ApiError('Non 200 Status code from mhsl services: $subpath: ${data.statusCode}');
|
||||
}
|
||||
|
||||
return assemble(utf8.decode(data.bodyBytes));
|
||||
}
|
||||
|
||||
static String dateTimeToJson(DateTime time) => Jiffy.parseFromDateTime(time).format(pattern: "yyyy-MM-dd HH:mm:ss");
|
||||
static String dateTimeToJson(DateTime time) => Jiffy.parseFromDateTime(time).format(pattern: 'yyyy-MM-dd HH:mm:ss');
|
||||
static DateTime dateTimeFromJson(String time) => DateTime.parse(time);
|
||||
|
||||
}
|
@ -9,7 +9,7 @@ import 'notifyRegisterParams.dart';
|
||||
|
||||
class NotifyRegister extends MhslApi<void> {
|
||||
NotifyRegisterParams params;
|
||||
NotifyRegister(this.params) : super("notify/register/");
|
||||
NotifyRegister(this.params) : super('notify/register/');
|
||||
|
||||
|
||||
@override
|
||||
|
@ -12,7 +12,7 @@ import 'updateUserIndexParams.dart';
|
||||
|
||||
class UpdateUserIndex extends MhslApi<void> {
|
||||
UpdateUserIndexParams params;
|
||||
UpdateUserIndex(this.params) : super("server/userIndex/update");
|
||||
UpdateUserIndex(this.params) : super('server/userIndex/update');
|
||||
|
||||
@override
|
||||
void assemble(String raw) {}
|
||||
@ -20,7 +20,7 @@ class UpdateUserIndex extends MhslApi<void> {
|
||||
@override
|
||||
Future<http.Response> request(Uri uri) {
|
||||
String data = jsonEncode(params.toJson());
|
||||
log("Updating userindex:\n $data");
|
||||
log('Updating userindex:\n $data');
|
||||
return http.post(uri, body: data);
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,8 @@ abstract class RequestCache<T extends ApiResponse?> {
|
||||
onUpdate(newValue as T);
|
||||
|
||||
Localstore.instance.collection(file).doc(document).set({
|
||||
"json": jsonEncode(newValue),
|
||||
"lastupdate": DateTime.now().millisecondsSinceEpoch
|
||||
'json': jsonEncode(newValue),
|
||||
'lastupdate': DateTime.now().millisecondsSinceEpoch
|
||||
});
|
||||
} catch(e) {
|
||||
log("Error while fetching/ parsing. Raw server response: ${newValue?.rawResponse.body ?? "no response"}");
|
||||
|
@ -9,7 +9,7 @@ import 'authenticateResponse.dart';
|
||||
class Authenticate extends WebuntisApi {
|
||||
AuthenticateParams param;
|
||||
|
||||
Authenticate(this.param) : super("authenticate", param, authenticatedResponse: false);
|
||||
Authenticate(this.param) : super('authenticate', param, authenticatedResponse: false);
|
||||
|
||||
@override
|
||||
Future<AuthenticateResponse> run() async {
|
||||
|
@ -4,7 +4,7 @@ import '../../webuntisApi.dart';
|
||||
import 'getHolidaysResponse.dart';
|
||||
|
||||
class GetHolidays extends WebuntisApi {
|
||||
GetHolidays() : super("getHolidays", null);
|
||||
GetHolidays() : super('getHolidays', null);
|
||||
|
||||
@override
|
||||
Future<GetHolidaysResponse> run() async {
|
||||
|
@ -6,7 +6,7 @@ import 'getHolidaysResponse.dart';
|
||||
|
||||
class GetHolidaysCache extends RequestCache<GetHolidaysResponse> {
|
||||
GetHolidaysCache({onUpdate}) : super(RequestCache.cacheDay, onUpdate) {
|
||||
start("MarianumMobile", "wu-holidays");
|
||||
start('MarianumMobile', 'wu-holidays');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -5,7 +5,7 @@ import '../../webuntisApi.dart';
|
||||
import 'getRoomsResponse.dart';
|
||||
|
||||
class GetRooms extends WebuntisApi {
|
||||
GetRooms() : super("getRooms", null);
|
||||
GetRooms() : super('getRooms', null);
|
||||
|
||||
@override
|
||||
Future<GetRoomsResponse> run() async {
|
||||
@ -14,10 +14,10 @@ class GetRooms extends WebuntisApi {
|
||||
return finalize(GetRoomsResponse.fromJson(jsonDecode(rawAnswer)));
|
||||
} catch(e, trace) {
|
||||
log(trace.toString());
|
||||
log("Failed to parse getRoom data with server response: $rawAnswer");
|
||||
log('Failed to parse getRoom data with server response: $rawAnswer');
|
||||
}
|
||||
|
||||
throw Exception("Failed to parse getRoom server response: $rawAnswer");
|
||||
throw Exception('Failed to parse getRoom server response: $rawAnswer');
|
||||
}
|
||||
|
||||
}
|
@ -6,7 +6,7 @@ import 'getRoomsResponse.dart';
|
||||
|
||||
class GetRoomsCache extends RequestCache<GetRoomsResponse> {
|
||||
GetRoomsCache({onUpdate}) : super(RequestCache.cacheHour, onUpdate) {
|
||||
start("MarianumMobile", "wu-rooms");
|
||||
start('MarianumMobile', 'wu-rooms');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -4,7 +4,7 @@ import '../../webuntisApi.dart';
|
||||
import 'getSubjectsResponse.dart';
|
||||
|
||||
class GetSubjects extends WebuntisApi {
|
||||
GetSubjects() : super("getSubjects", null);
|
||||
GetSubjects() : super('getSubjects', null);
|
||||
|
||||
@override
|
||||
Future<GetSubjectsResponse> run() async {
|
||||
|
@ -6,7 +6,7 @@ import 'getSubjectsResponse.dart';
|
||||
|
||||
class GetSubjectsCache extends RequestCache<GetSubjectsResponse> {
|
||||
GetSubjectsCache({onUpdate}) : super(RequestCache.cacheHour, onUpdate) {
|
||||
start("MarianumMobile", "wu-subjects");
|
||||
start('MarianumMobile', 'wu-subjects');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -7,7 +7,7 @@ import 'getTimetableResponse.dart';
|
||||
class GetTimetable extends WebuntisApi {
|
||||
GetTimetableParams params;
|
||||
|
||||
GetTimetable(this.params) : super("getTimetable", params);
|
||||
GetTimetable(this.params) : super('getTimetable', params);
|
||||
|
||||
@override
|
||||
Future<GetTimetableResponse> run() async {
|
||||
|
@ -11,7 +11,7 @@ class GetTimetableCache extends RequestCache<GetTimetableResponse> {
|
||||
int enddate;
|
||||
|
||||
GetTimetableCache({required onUpdate, onError, required this.startdate, required this.enddate}) : super(RequestCache.cacheMinute, onUpdate, onError: onError) {
|
||||
start("MarianumMobile", "wu-timetable-$startdate-$enddate");
|
||||
start('MarianumMobile', 'wu-timetable-$startdate-$enddate');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -67,10 +67,10 @@ class GetTimetableParamsOptions {
|
||||
}
|
||||
|
||||
enum GetTimetableParamsOptionsFields {
|
||||
@JsonValue("id") id,
|
||||
@JsonValue("name") name,
|
||||
@JsonValue("longname") longname,
|
||||
@JsonValue("externalkey") externalkey;
|
||||
@JsonValue('id') id,
|
||||
@JsonValue('name') name,
|
||||
@JsonValue('longname') longname,
|
||||
@JsonValue('externalkey') externalkey;
|
||||
|
||||
static List<GetTimetableParamsOptionsFields> all = [id, name, longname, externalkey];
|
||||
}
|
||||
@ -88,7 +88,7 @@ class GetTimetableParamsOptionsElement {
|
||||
}
|
||||
|
||||
enum GetTimetableParamsOptionsElementKeyType {
|
||||
@JsonValue("id") id,
|
||||
@JsonValue("name") name,
|
||||
@JsonValue("externalkey") externalkey
|
||||
@JsonValue('id') id,
|
||||
@JsonValue('name') name,
|
||||
@JsonValue('externalkey') externalkey
|
||||
}
|
@ -9,7 +9,7 @@ import 'queries/authenticate/authenticate.dart';
|
||||
import 'webuntisError.dart';
|
||||
|
||||
abstract class WebuntisApi extends ApiRequest {
|
||||
Uri endpoint = Uri.parse("https://${EndpointData().webuntis().full()}/WebUntis/jsonrpc.do?school=marianum-fulda");
|
||||
Uri endpoint = Uri.parse('https://${EndpointData().webuntis().full()}/WebUntis/jsonrpc.do?school=marianum-fulda');
|
||||
String method;
|
||||
ApiParams? genericParam;
|
||||
http.Response? response;
|
||||
@ -22,11 +22,11 @@ abstract class WebuntisApi extends ApiRequest {
|
||||
Future<String> query(WebuntisApi untis) async {
|
||||
String query = '{"id":"ID","method":"$method","params":${untis._body()},"jsonrpc":"2.0"}';
|
||||
|
||||
String sessionId = "0";
|
||||
String sessionId = '0';
|
||||
if(authenticatedResponse) {
|
||||
sessionId = (await Authenticate.getSession()).sessionId;
|
||||
}
|
||||
http.Response data = await post(query, {"Cookie": "JSESSIONID=$sessionId"});
|
||||
http.Response data = await post(query, {'Cookie': 'JSESSIONID=$sessionId'});
|
||||
response = data;
|
||||
|
||||
dynamic jsonData = jsonDecode(data.body);
|
||||
@ -49,7 +49,7 @@ abstract class WebuntisApi extends ApiRequest {
|
||||
Future<ApiResponse> run();
|
||||
|
||||
String _body() {
|
||||
return genericParam == null ? "{}" : jsonEncode(genericParam);
|
||||
return genericParam == null ? '{}' : jsonEncode(genericParam);
|
||||
}
|
||||
|
||||
Future<http.Response> post(String data, Map<String, String>? headers) async {
|
||||
@ -57,7 +57,7 @@ abstract class WebuntisApi extends ApiRequest {
|
||||
.post(endpoint, body: data, headers: headers)
|
||||
.timeout(
|
||||
const Duration(seconds: 10),
|
||||
onTimeout: () => throw WebuntisError("Timeout", 1)
|
||||
onTimeout: () => throw WebuntisError('Timeout', 1)
|
||||
);
|
||||
}
|
||||
}
|
@ -6,6 +6,6 @@ class WebuntisError implements Exception {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "WebUntis ($code): $message";
|
||||
return 'WebUntis ($code): $message';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user