Added emergency remote breakers
This commit is contained in:
26
lib/api/mhsl/mhslApi.dart
Normal file
26
lib/api/mhsl/mhslApi.dart
Normal file
@ -0,0 +1,26 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../apiError.dart';
|
||||
import '../apiRequest.dart';
|
||||
|
||||
abstract class MhslApi<T> extends ApiRequest {
|
||||
String subpath;
|
||||
MhslApi(this.subpath);
|
||||
|
||||
http.Response? response;
|
||||
|
||||
Future<http.Response>? request(Uri uri);
|
||||
T assemble(String raw);
|
||||
|
||||
Future<T> run() async {
|
||||
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!");
|
||||
}
|
||||
|
||||
return assemble(utf8.decode(data.bodyBytes));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user