@@ -252,7 +252,17 @@ class ZulipStream {
252
252
final StreamPostPolicy streamPostPolicy;
253
253
// final bool isAnnouncementOnly; // deprecated for `streamPostPolicy`; ignore
254
254
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
+ }
256
266
257
267
ZulipStream ({
258
268
required this .streamId,
@@ -266,7 +276,8 @@ class ZulipStream {
266
276
required this .historyPublicToSubscribers,
267
277
required this .messageRetentionDays,
268
278
required this .streamPostPolicy,
269
- required this .canRemoveSubscribersGroupId,
279
+ required this .canRemoveSubscribersGroup,
280
+ required this .streamWeeklyTraffic,
270
281
});
271
282
272
283
factory ZulipStream .fromJson (Map <String , dynamic > json) =>
@@ -301,75 +312,54 @@ enum StreamPostPolicy{
301
312
/// For docs, search for "subscriptions:"
302
313
/// in <https://zulip.com/api/register-queue>.
303
314
@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;
322
317
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;
326
323
327
- final int ? canRemoveSubscribersGroupId; // TODO(server-6)
324
+ bool pinToTop;
328
325
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;
341
327
// final bool? inHomeView; // deprecated; ignore
342
328
343
- final String color;
329
+ String color;
330
+ String emailAddress;
344
331
345
332
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,
352
348
required this .desktopNotifications,
353
349
required this .emailNotifications,
354
350
required this .wildcardMentionsNotify,
355
351
required this .pushNotifications,
356
352
required this .audibleNotifications,
357
353
required this .pinToTop,
358
- required this .emailAddress,
359
354
required this .isMuted,
360
- required this .isWebPublic,
361
355
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,
368
357
});
369
358
370
359
factory Subscription .fromJson (Map <String , dynamic > json) =>
371
360
_$SubscriptionFromJson (json);
372
361
362
+ @override
373
363
Map <String , dynamic > toJson () => _$SubscriptionToJson (this );
374
364
}
375
365
0 commit comments