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']);
|
||||
}
|
||||
|
||||
}
|
30
lib/api/marianumcloud/autocomplete/autocompleteResponse.dart
Normal file
30
lib/api/marianumcloud/autocomplete/autocompleteResponse.dart
Normal file
@ -0,0 +1,30 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'autocompleteResponse.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class AutocompleteResponse {
|
||||
List<AutocompleteResponseObject> data;
|
||||
|
||||
AutocompleteResponse(this.data);
|
||||
|
||||
factory AutocompleteResponse.fromJson(Map<String, dynamic> json) => _$AutocompleteResponseFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$AutocompleteResponseToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class AutocompleteResponseObject {
|
||||
String id;
|
||||
String label;
|
||||
String? icon;
|
||||
String? source;
|
||||
List<String>? status;
|
||||
String? subline;
|
||||
String? shareWithDisplayNameUniqe;
|
||||
|
||||
AutocompleteResponseObject(this.id, this.label, this.icon, this.source, this.status,
|
||||
this.subline, this.shareWithDisplayNameUniqe);
|
||||
|
||||
factory AutocompleteResponseObject.fromJson(Map<String, dynamic> json) => _$AutocompleteResponseObjectFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$AutocompleteResponseObjectToJson(this);
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'autocompleteResponse.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
AutocompleteResponse _$AutocompleteResponseFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
AutocompleteResponse(
|
||||
(json['data'] as List<dynamic>)
|
||||
.map((e) =>
|
||||
AutocompleteResponseObject.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AutocompleteResponseToJson(
|
||||
AutocompleteResponse instance) =>
|
||||
<String, dynamic>{
|
||||
'data': instance.data.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
|
||||
AutocompleteResponseObject _$AutocompleteResponseObjectFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
AutocompleteResponseObject(
|
||||
json['id'] as String,
|
||||
json['label'] as String,
|
||||
json['icon'] as String?,
|
||||
json['source'] as String?,
|
||||
(json['status'] as List<dynamic>?)?.map((e) => e as String).toList(),
|
||||
json['subline'] as String?,
|
||||
json['shareWithDisplayNameUniqe'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AutocompleteResponseObjectToJson(
|
||||
AutocompleteResponseObject instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'label': instance.label,
|
||||
'icon': instance.icon,
|
||||
'source': instance.source,
|
||||
'status': instance.status,
|
||||
'subline': instance.subline,
|
||||
'shareWithDisplayNameUniqe': instance.shareWithDisplayNameUniqe,
|
||||
};
|
@ -1,9 +1,9 @@
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/http.dart';
|
||||
import 'package:marianum_mobile/api/marianumcloud/talk/setReadMarker/setReadMarkerParams.dart';
|
||||
|
||||
import '../talkApi.dart';
|
||||
import 'setReadMarkerParams.dart';
|
||||
|
||||
class SetReadMarker extends TalkApi<void> {
|
||||
String chatToken;
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:marianum_mobile/api/apiParams.dart';
|
||||
|
||||
import '../../../apiParams.dart';
|
||||
|
||||
part 'setReadMarkerParams.g.dart';
|
||||
|
||||
|
Reference in New Issue
Block a user