[Client] add setPushers
Took 15 minutes
This commit is contained in:
parent
c3967419e6
commit
88be572170
|
@ -23,6 +23,7 @@
|
|||
|
||||
import 'dart:async';
|
||||
import 'dart:core';
|
||||
import 'requests/SetPushersRequest.dart';
|
||||
import 'responses/ErrorResponse.dart';
|
||||
import 'Connection.dart';
|
||||
import 'RoomList.dart';
|
||||
|
@ -246,4 +247,20 @@ class Client {
|
|||
|
||||
return PushrulesResponse.fromJson(resp);
|
||||
}
|
||||
|
||||
/// This endpoint allows the creation, modification and deletion of pushers for this user ID.
|
||||
Future setPushers(SetPushersRequest data) async {
|
||||
final dynamic resp = await connection.jsonRequest(
|
||||
type: "POST",
|
||||
action: "/client/r0/pushers/set",
|
||||
data: data,
|
||||
);
|
||||
|
||||
if (resp is ErrorResponse) {
|
||||
connection.onError.add(resp);
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
81
lib/src/requests/SetPushersRequest.dart
Normal file
81
lib/src/requests/SetPushersRequest.dart
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Zender & Kurtz GbR.
|
||||
*
|
||||
* Authors:
|
||||
* Christian Pauly <krille@famedly.com>
|
||||
* Marcel Radzio <mtrnord@famedly.com>
|
||||
*
|
||||
* This file is part of famedlysdk.
|
||||
*
|
||||
* famedlysdk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* famedlysdk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with famedly. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'SetPushersRequest.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true, nullable: false)
|
||||
class SetPushersRequest {
|
||||
// Required Keys
|
||||
@JsonKey(nullable: false)
|
||||
String lang;
|
||||
@JsonKey(nullable: false)
|
||||
String device_display_name;
|
||||
@JsonKey(nullable: false)
|
||||
String app_display_name;
|
||||
@JsonKey(nullable: false)
|
||||
String app_id;
|
||||
@JsonKey(nullable: false)
|
||||
String kind;
|
||||
@JsonKey(nullable: false)
|
||||
String pushkey;
|
||||
@JsonKey(nullable: false)
|
||||
PusherData data;
|
||||
|
||||
// Optional keys
|
||||
String profile_tag;
|
||||
bool append;
|
||||
|
||||
SetPushersRequest({
|
||||
this.lang,
|
||||
this.device_display_name,
|
||||
this.app_display_name,
|
||||
this.app_id,
|
||||
this.kind,
|
||||
this.pushkey,
|
||||
this.data,
|
||||
this.profile_tag,
|
||||
this.append,
|
||||
});
|
||||
|
||||
factory SetPushersRequest.fromJson(Map<String, dynamic> json) =>
|
||||
_$SetPushersRequestFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$SetPushersRequestToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true, nullable: false)
|
||||
class PusherData {
|
||||
String url;
|
||||
String format;
|
||||
|
||||
PusherData({
|
||||
this.url,
|
||||
this.format,
|
||||
});
|
||||
|
||||
factory PusherData.fromJson(Map<String, dynamic> json) =>
|
||||
_$PusherDataFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$PusherDataToJson(this);
|
||||
}
|
41
lib/src/requests/SetPushersRequest.g.dart
Normal file
41
lib/src/requests/SetPushersRequest.g.dart
Normal file
|
@ -0,0 +1,41 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'SetPushersRequest.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
SetPushersRequest _$SetPushersRequestFromJson(Map<String, dynamic> json) {
|
||||
return SetPushersRequest(
|
||||
lang: json['lang'] as String,
|
||||
device_display_name: json['device_display_name'] as String,
|
||||
app_display_name: json['app_display_name'] as String,
|
||||
app_id: json['app_id'] as String,
|
||||
kind: json['kind'] as String,
|
||||
pushkey: json['pushkey'] as String,
|
||||
data: PusherData.fromJson(json['data'] as Map<String, dynamic>),
|
||||
profile_tag: json['profile_tag'] as String,
|
||||
append: json['append'] as bool);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$SetPushersRequestToJson(SetPushersRequest instance) =>
|
||||
<String, dynamic>{
|
||||
'lang': instance.lang,
|
||||
'device_display_name': instance.device_display_name,
|
||||
'app_display_name': instance.app_display_name,
|
||||
'app_id': instance.app_id,
|
||||
'kind': instance.kind,
|
||||
'pushkey': instance.pushkey,
|
||||
'data': instance.data.toJson(),
|
||||
'profile_tag': instance.profile_tag,
|
||||
'append': instance.append
|
||||
};
|
||||
|
||||
PusherData _$PusherDataFromJson(Map<String, dynamic> json) {
|
||||
return PusherData(
|
||||
url: json['url'] as String, format: json['format'] as String);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$PusherDataToJson(PusherData instance) =>
|
||||
<String, dynamic>{'url': instance.url, 'format': instance.format};
|
Loading…
Reference in a new issue