Added Marianum Message pdf reader and backend
This commit is contained in:
22
lib/api/mhsl/message/messageApi.dart
Normal file
22
lib/api/mhsl/message/messageApi.dart
Normal file
@ -0,0 +1,22 @@
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../../apiError.dart';
|
||||
import '../../apiRequest.dart';
|
||||
|
||||
abstract class MessageApi<T> extends ApiRequest {
|
||||
String path = "https://mhsl.eu/marianum/marianummobile/message/messages.json";
|
||||
http.Response? response;
|
||||
|
||||
Future<http.Response>? request(Uri uri);
|
||||
T assemble(String raw);
|
||||
|
||||
Future<T> run() async {
|
||||
Uri endpoint = Uri.parse(path);
|
||||
|
||||
http.Response? data = await request(endpoint);
|
||||
if(data == null) {
|
||||
throw ApiError("Request could not be dispatched!");
|
||||
}
|
||||
|
||||
return assemble(data.body);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user