import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:surface/types/attachment.dart'; part 'post.freezed.dart'; part 'post.g.dart'; @freezed class SnPost with _$SnPost { const SnPost._(); const factory SnPost({ required int id, required DateTime createdAt, required DateTime updatedAt, required DateTime? deletedAt, required String type, required Map body, required String language, required String? alias, required String? aliasPrefix, @Default([]) List tags, @Default([]) List categories, required List? replies, required int? replyId, required int? repostId, required SnPost? replyTo, required SnPost? repostTo, required List? visibleUsersList, required List? invisibleUsersList, required int visibility, required DateTime? editedAt, required DateTime? pinnedAt, required DateTime? lockedAt, required bool isDraft, required DateTime? publishedAt, required DateTime? publishedUntil, required int totalUpvote, required int totalDownvote, required int publisherId, required SnPublisher publisher, required SnMetric metric, SnPostPreload? preload, }) = _SnPost; factory SnPost.fromJson(Map json) => _$SnPostFromJson(json); String get typePlural => switch (type) { 'story' => 'stories', _ => '${type}s', }; } @freezed class SnPostTag with _$SnPostTag { const factory SnPostTag({ required int id, required DateTime createdAt, required DateTime updatedAt, required dynamic deletedAt, required String alias, required String name, required String description, required dynamic posts, }) = _SnPostTag; factory SnPostTag.fromJson(Map json) => _$SnPostTagFromJson(json); } @freezed class SnPostPreload with _$SnPostPreload { const factory SnPostPreload({ required SnAttachment? thumbnail, required List? attachments, }) = _SnPostPreload; factory SnPostPreload.fromJson(Map json) => _$SnPostPreloadFromJson(json); } @freezed class SnBody with _$SnBody { const factory SnBody({ required List attachments, required String content, required dynamic location, required dynamic thumbnail, required dynamic title, }) = _SnBody; factory SnBody.fromJson(Map json) => _$SnBodyFromJson(json); } @freezed class SnMetric with _$SnMetric { const factory SnMetric({ required int replyCount, required int reactionCount, @Default({}) Map reactionList, }) = _SnMetric; factory SnMetric.fromJson(Map json) => _$SnMetricFromJson(json); } @freezed class SnPublisher with _$SnPublisher { const factory SnPublisher({ required int id, required DateTime createdAt, required DateTime updatedAt, required DateTime? deletedAt, required int type, required String name, required String nick, required String description, required String avatar, required String banner, required int totalUpvote, required int totalDownvote, required int? realmId, required int accountId, }) = _SnPublisher; factory SnPublisher.fromJson(Map json) => _$SnPublisherFromJson(json); }