Implement getPushers
This commit is contained in:
parent
4b2d4913b3
commit
4253f0ce9a
|
@ -54,6 +54,7 @@ import 'sync/user_update.dart';
|
|||
import 'user.dart';
|
||||
import 'utils/matrix_exception.dart';
|
||||
import 'utils/profile.dart';
|
||||
import 'utils/pusher.dart';
|
||||
|
||||
typedef RoomSorter = int Function(Room a, Room b);
|
||||
|
||||
|
@ -523,6 +524,17 @@ class Client {
|
|||
? PushRules.fromJson(accountData['m.push_rules'].content)
|
||||
: null;
|
||||
|
||||
/// Gets all currently active pushers for the authenticated user.
|
||||
Future<List<Pusher>> getPushers() async {
|
||||
final response =
|
||||
await jsonRequest(type: HTTPType.GET, action: '/client/r0/pushers');
|
||||
var list = <Pusher>[];
|
||||
for (final pusherJson in response['pushers']) {
|
||||
list.add(Pusher.fromJson(pusherJson));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// This endpoint allows the creation, modification and deletion of pushers for this user ID.
|
||||
Future<void> setPushers(String pushKey, String kind, String appId,
|
||||
String appDisplayName, String deviceDisplayName, String lang, String url,
|
||||
|
|
62
lib/src/utils/pusher.dart
Normal file
62
lib/src/utils/pusher.dart
Normal file
|
@ -0,0 +1,62 @@
|
|||
class Pusher {
|
||||
String pushkey;
|
||||
String kind;
|
||||
String appId;
|
||||
String appDisplayName;
|
||||
String deviceDisplayName;
|
||||
String profileTag;
|
||||
String lang;
|
||||
PusherData data;
|
||||
|
||||
Pusher(
|
||||
{this.pushkey,
|
||||
this.kind,
|
||||
this.appId,
|
||||
this.appDisplayName,
|
||||
this.deviceDisplayName,
|
||||
this.profileTag,
|
||||
this.lang,
|
||||
this.data});
|
||||
|
||||
Pusher.fromJson(Map<String, dynamic> json) {
|
||||
pushkey = json['pushkey'];
|
||||
kind = json['kind'];
|
||||
appId = json['app_id'];
|
||||
appDisplayName = json['app_display_name'];
|
||||
deviceDisplayName = json['device_display_name'];
|
||||
profileTag = json['profile_tag'];
|
||||
lang = json['lang'];
|
||||
data = json['data'] != null ? PusherData.fromJson(json['data']) : null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['pushkey'] = pushkey;
|
||||
data['kind'] = kind;
|
||||
data['app_id'] = appId;
|
||||
data['app_display_name'] = appDisplayName;
|
||||
data['device_display_name'] = deviceDisplayName;
|
||||
data['profile_tag'] = profileTag;
|
||||
data['lang'] = lang;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class PusherData {
|
||||
String url;
|
||||
|
||||
PusherData({this.url});
|
||||
|
||||
PusherData.fromJson(Map<String, dynamic> json) {
|
||||
url = json['url'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['url'] = url;
|
||||
return data;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue