Added basic Text sending

This commit is contained in:
2023-02-22 19:22:55 +01:00
parent 0cac5d702e
commit 693b226bdc
6 changed files with 91 additions and 5 deletions

View File

@ -1,4 +1,5 @@
import 'package:http/http.dart' as http;
import 'package:marianum_mobile/api/apiError.dart';
import 'package:marianum_mobile/api/apiRequest.dart';
import 'package:shared_preferences/shared_preferences.dart';
@ -21,7 +22,7 @@ abstract class TalkApi<T> extends ApiRequest {
TalkApi(this.path, this.body, {this.headers, this.getParameters});
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers);
Future<http.Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers);
T assemble(String raw);
Future<T> run() async {
@ -37,7 +38,10 @@ abstract class TalkApi<T> extends ApiRequest {
headers?.putIfAbsent("Accept", () => "application/json");
headers?.putIfAbsent("OCS-APIRequest", () => "true");
http.Response data = await request(endpoint, body, headers);
http.Response? data = await request(endpoint, body, headers);
if(data == null) {
throw ApiError("Request could not be dispatched!");
}
//dynamic jsonData = jsonDecode(data.body);