@@ -4,6 +4,42 @@ import '../core.dart';
4
4
import '../model/model.dart' ;
5
5
part 'channels.g.dart' ;
6
6
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
+
7
43
/// https://zulip.com/api/get-stream-topics
8
44
Future <GetStreamTopicsResult > getStreamTopics (ApiConnection connection, {
9
45
required int streamId,
0 commit comments