@@ -252,7 +252,17 @@ class ZulipStream {
252252 final StreamPostPolicy streamPostPolicy;
253253 // final bool isAnnouncementOnly; // deprecated for `streamPostPolicy`; ignore
254254
255- final int ? canRemoveSubscribersGroupId; // TODO(server-6)
255+ // TODO(server-6): `canRemoveSubscribersGroupId` added in FL 142
256+ // TODO(server-8): in FL 197 renamed to `canRemoveSubscribersGroup`
257+ @JsonKey (readValue: _readCanRemoveSubscribersGroup)
258+ final int ? canRemoveSubscribersGroup;
259+
260+ // TODO(server-8): added in FL 199, was previously only on [Subscription] objects
261+ final int ? streamWeeklyTraffic;
262+
263+ static int _readCanRemoveSubscribersGroup (Map json, String key) {
264+ return json[key] ?? json['can_remove_subscribers_group_id' ];
265+ }
256266
257267 ZulipStream ({
258268 required this .streamId,
@@ -266,7 +276,8 @@ class ZulipStream {
266276 required this .historyPublicToSubscribers,
267277 required this .messageRetentionDays,
268278 required this .streamPostPolicy,
269- required this .canRemoveSubscribersGroupId,
279+ required this .canRemoveSubscribersGroup,
280+ required this .streamWeeklyTraffic,
270281 });
271282
272283 factory ZulipStream .fromJson (Map <String , dynamic > json) =>
@@ -301,75 +312,54 @@ enum StreamPostPolicy{
301312/// For docs, search for "subscriptions:"
302313/// in <https://zulip.com/api/register-queue>.
303314@JsonSerializable (fieldRename: FieldRename .snake)
304- class Subscription {
305- // First, fields that are about the stream and not the user's relation to it.
306- // These are largely the same as in [ZulipStream].
307-
308- final int streamId;
309- final String name;
310- final String description;
311- final String renderedDescription;
312-
313- final int dateCreated;
314- final int ? firstMessageId;
315- final int ? streamWeeklyTraffic;
316-
317- final bool inviteOnly;
318- final bool ? isWebPublic; // TODO(server-??): doc doesn't say when added
319- final bool historyPublicToSubscribers;
320- final int ? messageRetentionDays;
321- // final List<int> subscribers; // we register with includeSubscribers false
315+ class Subscription extends ZulipStream {
316+ List <int >? subscribers;
322317
323- final int streamPostPolicy; // TODO enum
324- // final bool? isAnnouncementOnly; // deprecated; ignore
325- final String emailAddress;
318+ bool ? desktopNotifications;
319+ bool ? emailNotifications;
320+ bool ? wildcardMentionsNotify;
321+ bool ? pushNotifications;
322+ bool ? audibleNotifications;
326323
327- final int ? canRemoveSubscribersGroupId; // TODO(server-6)
324+ bool pinToTop;
328325
329- // Then, fields that are specific to the subscription,
330- // i.e. the user's relationship to the stream.
331-
332- final bool ? desktopNotifications;
333- final bool ? emailNotifications;
334- final bool ? wildcardMentionsNotify;
335- final bool ? pushNotifications;
336- final bool ? audibleNotifications;
337-
338- final bool pinToTop;
339-
340- final bool isMuted;
326+ bool isMuted;
341327 // final bool? inHomeView; // deprecated; ignore
342328
343- final String color;
329+ String color;
330+ String emailAddress;
344331
345332 Subscription ({
346- required this .streamId,
347- required this .name,
348- required this .description,
349- required this .renderedDescription,
350- required this .dateCreated,
351- required this .inviteOnly,
333+ required super .streamId,
334+ required super .name,
335+ required super .description,
336+ required super .renderedDescription,
337+ required super .dateCreated,
338+ required super .firstMessageId,
339+ required super .inviteOnly,
340+ required super .isWebPublic,
341+ required super .historyPublicToSubscribers,
342+ required super .messageRetentionDays,
343+ required super .streamPostPolicy,
344+ required super .canRemoveSubscribersGroup,
345+ required super .streamWeeklyTraffic,
346+
347+ required this .subscribers,
352348 required this .desktopNotifications,
353349 required this .emailNotifications,
354350 required this .wildcardMentionsNotify,
355351 required this .pushNotifications,
356352 required this .audibleNotifications,
357353 required this .pinToTop,
358- required this .emailAddress,
359354 required this .isMuted,
360- required this .isWebPublic,
361355 required this .color,
362- required this .streamPostPolicy,
363- required this .messageRetentionDays,
364- required this .historyPublicToSubscribers,
365- required this .firstMessageId,
366- required this .streamWeeklyTraffic,
367- required this .canRemoveSubscribersGroupId,
356+ required this .emailAddress,
368357 });
369358
370359 factory Subscription .fromJson (Map <String , dynamic > json) =>
371360 _$SubscriptionFromJson (json);
372361
362+ @override
373363 Map <String , dynamic > toJson () => _$SubscriptionToJson (this );
374364}
375365
0 commit comments