@@ -4,6 +4,42 @@ import '../core.dart';
44import '../model/model.dart' ;
55part 'channels.g.dart' ;
66
7+ /// https://zulip.com/api/subscribe
8+ ///
9+ /// [subscriptions] is a list of channel names.
10+ /// (This is one of the few remaining areas where the Zulip API hasn't migrated
11+ /// to using IDs.)
12+ Future <void > subscribeToChannel (ApiConnection connection, {
13+ // TODO(server-future): This should use a stream ID, not stream name.
14+ // (Keep dartdoc up to date.)
15+ // Server issue: https://github.com/zulip/zulip/issues/10744
16+ required List <String > subscriptions,
17+ List <int >? principals,
18+ }) {
19+ return connection.post ('subscribeToChannel' , (_) {}, 'users/me/subscriptions' , {
20+ 'subscriptions' : subscriptions.map ((name) => {'name' : name}).toList (),
21+ if (principals != null ) 'principals' : principals,
22+ });
23+ }
24+
25+ /// https://zulip.com/api/unsubscribe
26+ ///
27+ /// [subscriptions] is a list of channel names.
28+ /// (This is one of the few remaining areas where the Zulip API hasn't migrated
29+ /// to using IDs.)
30+ Future <void > unsubscribeFromChannel (ApiConnection connection, {
31+ // TODO(server-future): This should use a stream ID, not stream name.
32+ // (Keep dartdoc up to date.)
33+ // Server issue: https://github.com/zulip/zulip/issues/10744
34+ required List <String > subscriptions,
35+ List <int >? principals,
36+ }) {
37+ return connection.delete ('unsubscribeFromChannel' , (_) {}, 'users/me/subscriptions' , {
38+ 'subscriptions' : subscriptions,
39+ if (principals != null ) 'principals' : principals,
40+ });
41+ }
42+
743/// https://zulip.com/api/get-stream-topics
844Future <GetStreamTopicsResult > getStreamTopics (ApiConnection connection, {
945 required int streamId,
0 commit comments