Skip to content

Commit cc676ac

Browse files
committed
api: Add route unsubscribeFromChannels
1 parent 96836fc commit cc676ac

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

Diff for: lib/api/route/channels.dart

+22
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,25 @@ class SubscribeToChannelsResult {
6363

6464
Map<String, dynamic> toJson() => _$SubscribeToChannelsResultToJson(this);
6565
}
66+
67+
/// https://zulip.com/api/usubscribe
68+
Future<UnsubscribeFromChannelsResult> unsubscribeFromChannels(ApiConnection connection, List<ZulipStream> streams) {
69+
return connection.delete('unsubscribe', UnsubscribeFromChannelsResult.fromJson,
70+
'users/me/subscriptions', {'subscriptions': streams.map((e) => e.name).toList()});
71+
}
72+
73+
@JsonSerializable(fieldRename: FieldRename.snake)
74+
class UnsubscribeFromChannelsResult {
75+
final List<String> removed;
76+
final List<String> notRemoved;
77+
78+
UnsubscribeFromChannelsResult({
79+
required this.removed,
80+
required this.notRemoved,
81+
});
82+
83+
factory UnsubscribeFromChannelsResult.fromJson(Map<String, dynamic> json) =>
84+
_$UnsubscribeFromChannelsResultFromJson(json);
85+
86+
Map<String, dynamic> toJson() => _$UnsubscribeFromChannelsResultToJson(this);
87+
}

Diff for: lib/api/route/channels.g.dart

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)