24 lines
614 B
Dart
24 lines
614 B
Dart
import 'dart:convert';
|
|
|
|
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(utf8.decode(data.bodyBytes));
|
|
}
|
|
} |