Skip to content

Commit 6481e5b

Browse files
committed
api: Add route unsubscribeFromChannels
1 parent 2250014 commit 6481e5b

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

lib/api/route/channel.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,24 @@ class SubscribeToChannelsResult {
2929
Map<String, dynamic> toJson() => _$SubscribeToChannelsResultToJson(this);
3030
}
3131

32+
// https://zulip.com/api/usubscribe
33+
Future<UnsubscribeFromChannelsResult> unsubscribeFromChannels(ApiConnection connection, List<ZulipStream> streams) {
34+
return connection.delete('unsubscribe', UnsubscribeFromChannelsResult.fromJson,
35+
'users/me/subscriptions', {'subscriptions': streams.map((e) => e.name).toList()});
36+
}
37+
38+
@JsonSerializable(fieldRename: FieldRename.snake)
39+
class UnsubscribeFromChannelsResult {
40+
final List<String> removed;
41+
final List<String> notRemoved;
42+
43+
UnsubscribeFromChannelsResult({
44+
required this.removed,
45+
required this.notRemoved,
46+
});
47+
48+
factory UnsubscribeFromChannelsResult.fromJson(Map<String, dynamic> json) =>
49+
_$UnsubscribeFromChannelsResultFromJson(json);
50+
51+
Map<String, dynamic> toJson() => _$UnsubscribeFromChannelsResultToJson(this);
52+
}

lib/api/route/channel.g.dart

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)