Added user search in talk, currently with no further functionality
This commit is contained in:
37
lib/api/marianumcloud/autocomplete/autocompleteApi.dart
Normal file
37
lib/api/marianumcloud/autocomplete/autocompleteApi.dart
Normal file
@ -0,0 +1,37 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/http.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'autocompleteResponse.dart';
|
||||
|
||||
class AutocompleteApi {
|
||||
Future<AutocompleteResponse> find(String query) async {
|
||||
log("query starting");
|
||||
var preferences = await SharedPreferences.getInstance();
|
||||
Map<String, dynamic> getParameters = {
|
||||
"search": query,
|
||||
"itemType": " ",
|
||||
"itemId": " ",
|
||||
"shareTypes[]": ["0"],
|
||||
"limit": "10",
|
||||
};
|
||||
|
||||
Map<String, String> headers = {};
|
||||
headers.putIfAbsent("Accept", () => "application/json");
|
||||
headers.putIfAbsent("OCS-APIRequest", () => "true");
|
||||
|
||||
Uri endpoint = Uri.https("${preferences.getString("username")!}:${preferences.getString("password")!}@cloud.marianum-fulda.de", "/ocs/v2.php/core/autocomplete/get", getParameters);
|
||||
log(endpoint.query);
|
||||
|
||||
Response response = await http.get(endpoint, headers: headers);
|
||||
log(response.statusCode.toString());
|
||||
String result = response.body;
|
||||
log(result);
|
||||
|
||||
return AutocompleteResponse.fromJson(jsonDecode(result)['ocs']);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user