Add `ReplyView`
This commit is contained in:
parent
ca9759db47
commit
413b4bef30
|
@ -0,0 +1,104 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'reply.g.dart';
|
||||
|
||||
/// based on https://github.com/LemmyNet/lemmy/blob/464ea862b10fa7b226b2550268e40d8e685a939c/server/lemmy_db/src/comment_view.rs#L356
|
||||
@JsonSerializable(fieldRename: FieldRename.snake, createToJson: false)
|
||||
class ReplyView {
|
||||
final int id;
|
||||
final int creatorId;
|
||||
final int postId;
|
||||
final String postName;
|
||||
|
||||
/// can be null
|
||||
final int parentId;
|
||||
final String content;
|
||||
final bool removed;
|
||||
final bool read;
|
||||
final DateTime published;
|
||||
|
||||
/// can be null
|
||||
final DateTime updated;
|
||||
final bool deleted;
|
||||
final String apId;
|
||||
final bool local;
|
||||
final int communityId;
|
||||
final String communityActorId;
|
||||
final bool communityLocal;
|
||||
final String communityName;
|
||||
|
||||
/// can be null
|
||||
final String communityIcon;
|
||||
final bool banned;
|
||||
final bool bannedFromCommunity;
|
||||
final String creatorActorId;
|
||||
final bool creatorLocal;
|
||||
final String creatorName;
|
||||
|
||||
/// can be null
|
||||
final String creatorPreferredUsername;
|
||||
|
||||
/// can be null
|
||||
final String creatorAvatar;
|
||||
final DateTime creatorPublished;
|
||||
final int score;
|
||||
final int upvotes;
|
||||
final int downvotes;
|
||||
final int hotRank;
|
||||
final int hotRankActive;
|
||||
|
||||
/// can be null
|
||||
final int userId;
|
||||
|
||||
/// can be null
|
||||
final int myVote;
|
||||
|
||||
/// can be null
|
||||
final bool subscribed;
|
||||
|
||||
/// can be null
|
||||
final bool saved;
|
||||
final int recipientId;
|
||||
|
||||
const ReplyView({
|
||||
this.id,
|
||||
this.creatorId,
|
||||
this.postId,
|
||||
this.postName,
|
||||
this.parentId,
|
||||
this.content,
|
||||
this.removed,
|
||||
this.read,
|
||||
this.published,
|
||||
this.updated,
|
||||
this.deleted,
|
||||
this.apId,
|
||||
this.local,
|
||||
this.communityId,
|
||||
this.communityActorId,
|
||||
this.communityLocal,
|
||||
this.communityName,
|
||||
this.communityIcon,
|
||||
this.banned,
|
||||
this.bannedFromCommunity,
|
||||
this.creatorActorId,
|
||||
this.creatorLocal,
|
||||
this.creatorName,
|
||||
this.creatorPreferredUsername,
|
||||
this.creatorAvatar,
|
||||
this.creatorPublished,
|
||||
this.score,
|
||||
this.upvotes,
|
||||
this.downvotes,
|
||||
this.hotRank,
|
||||
this.hotRankActive,
|
||||
this.userId,
|
||||
this.myVote,
|
||||
this.subscribed,
|
||||
this.saved,
|
||||
this.recipientId,
|
||||
});
|
||||
|
||||
factory ReplyView.fromJson(Map<String, dynamic> json) =>
|
||||
_$ReplyViewFromJson(json);
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'reply.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ReplyView _$ReplyViewFromJson(Map<String, dynamic> json) {
|
||||
return ReplyView(
|
||||
id: json['id'] as int,
|
||||
creatorId: json['creator_id'] as int,
|
||||
postId: json['post_id'] as int,
|
||||
postName: json['post_name'] as String,
|
||||
parentId: json['parent_id'] as int,
|
||||
content: json['content'] as String,
|
||||
removed: json['removed'] as bool,
|
||||
read: json['read'] as bool,
|
||||
published: json['published'] == null
|
||||
? null
|
||||
: DateTime.parse(json['published'] as String),
|
||||
updated: json['updated'] == null
|
||||
? null
|
||||
: DateTime.parse(json['updated'] as String),
|
||||
deleted: json['deleted'] as bool,
|
||||
apId: json['ap_id'] as String,
|
||||
local: json['local'] as bool,
|
||||
communityId: json['community_id'] as int,
|
||||
communityActorId: json['community_actor_id'] as String,
|
||||
communityLocal: json['community_local'] as bool,
|
||||
communityName: json['community_name'] as String,
|
||||
communityIcon: json['community_icon'] as String,
|
||||
banned: json['banned'] as bool,
|
||||
bannedFromCommunity: json['banned_from_community'] as bool,
|
||||
creatorActorId: json['creator_actor_id'] as String,
|
||||
creatorLocal: json['creator_local'] as bool,
|
||||
creatorName: json['creator_name'] as String,
|
||||
creatorPreferredUsername: json['creator_preferred_username'] as String,
|
||||
creatorAvatar: json['creator_avatar'] as String,
|
||||
creatorPublished: json['creator_published'] == null
|
||||
? null
|
||||
: DateTime.parse(json['creator_published'] as String),
|
||||
score: json['score'] as int,
|
||||
upvotes: json['upvotes'] as int,
|
||||
downvotes: json['downvotes'] as int,
|
||||
hotRank: json['hot_rank'] as int,
|
||||
hotRankActive: json['hot_rank_active'] as int,
|
||||
userId: json['user_id'] as int,
|
||||
myVote: json['my_vote'] as int,
|
||||
subscribed: json['subscribed'] as bool,
|
||||
saved: json['saved'] as bool,
|
||||
recipientId: json['recipient_id'] as int,
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue