⬆️ Support latest version of server
This commit is contained in:
@ -1,98 +0,0 @@
|
||||
import 'package:solian/models/account.dart';
|
||||
import 'package:solian/models/feed.dart';
|
||||
import 'package:solian/models/post.dart';
|
||||
import 'package:solian/models/realm.dart';
|
||||
|
||||
class Article {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
DateTime updatedAt;
|
||||
DateTime? deletedAt;
|
||||
String alias;
|
||||
String title;
|
||||
String description;
|
||||
String content;
|
||||
List<Tag>? tags;
|
||||
List<Category>? categories;
|
||||
List<int>? attachments;
|
||||
int? realmId;
|
||||
Realm? realm;
|
||||
DateTime? publishedAt;
|
||||
bool? isDraft;
|
||||
int authorId;
|
||||
Account author;
|
||||
PostMetric? metric;
|
||||
|
||||
Article({
|
||||
required this.id,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.deletedAt,
|
||||
required this.alias,
|
||||
required this.title,
|
||||
required this.description,
|
||||
required this.content,
|
||||
required this.tags,
|
||||
required this.categories,
|
||||
required this.attachments,
|
||||
required this.realmId,
|
||||
required this.realm,
|
||||
required this.publishedAt,
|
||||
required this.isDraft,
|
||||
required this.authorId,
|
||||
required this.author,
|
||||
required this.metric,
|
||||
});
|
||||
|
||||
factory Article.fromJson(Map<String, dynamic> json) => Article(
|
||||
id: json['id'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'] != null
|
||||
? DateTime.parse(json['deleted_at'])
|
||||
: null,
|
||||
alias: json['alias'],
|
||||
title: json['title'],
|
||||
description: json['description'],
|
||||
content: json['content'],
|
||||
tags: json['tags']?.map((x) => Tag.fromJson(x)).toList().cast<Tag>(),
|
||||
categories: json['categories']
|
||||
?.map((x) => Category.fromJson(x))
|
||||
.toList()
|
||||
.cast<Category>(),
|
||||
attachments: json['attachments'] != null
|
||||
? List<int>.from(json['attachments'])
|
||||
: null,
|
||||
realmId: json['realm_id'],
|
||||
realm: json['realm'] != null ? Realm.fromJson(json['realm']) : null,
|
||||
publishedAt: json['published_at'] != null
|
||||
? DateTime.parse(json['published_at'])
|
||||
: null,
|
||||
isDraft: json['is_draft'],
|
||||
authorId: json['author_id'],
|
||||
author: Account.fromJson(json['author']),
|
||||
metric:
|
||||
json['metric'] != null ? PostMetric.fromJson(json['metric']) : null,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt,
|
||||
'alias': alias,
|
||||
'title': title,
|
||||
'description': description,
|
||||
'content': content,
|
||||
'tags': tags,
|
||||
'categories': categories,
|
||||
'attachments': attachments,
|
||||
'realm_id': realmId,
|
||||
'realm': realm?.toJson(),
|
||||
'published_at': publishedAt?.toIso8601String(),
|
||||
'is_draft': isDraft,
|
||||
'author_id': authorId,
|
||||
'author': author.toJson(),
|
||||
'metric': metric?.toJson(),
|
||||
};
|
||||
}
|
@ -1,27 +1,3 @@
|
||||
class FeedRecord {
|
||||
String type;
|
||||
Map<String, dynamic> data;
|
||||
DateTime createdAt;
|
||||
|
||||
FeedRecord({
|
||||
required this.type,
|
||||
required this.data,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
factory FeedRecord.fromJson(Map<String, dynamic> json) => FeedRecord(
|
||||
type: json['type'],
|
||||
data: json['data'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'type': type,
|
||||
'data': data,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
class Tag {
|
||||
int id;
|
||||
String alias;
|
||||
|
@ -7,12 +7,10 @@ class Post {
|
||||
DateTime createdAt;
|
||||
DateTime updatedAt;
|
||||
DateTime? deletedAt;
|
||||
String alias;
|
||||
String content;
|
||||
dynamic body;
|
||||
List<Tag>? tags;
|
||||
List<Category>? categories;
|
||||
List<Post>? replies;
|
||||
List<int>? attachments;
|
||||
int? replyId;
|
||||
int? repostId;
|
||||
int? realmId;
|
||||
@ -30,12 +28,10 @@ class Post {
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.deletedAt,
|
||||
required this.alias,
|
||||
required this.content,
|
||||
required this.body,
|
||||
required this.tags,
|
||||
required this.categories,
|
||||
required this.replies,
|
||||
required this.attachments,
|
||||
required this.replyId,
|
||||
required this.repostId,
|
||||
required this.realmId,
|
||||
@ -56,17 +52,13 @@ class Post {
|
||||
deletedAt: json['deleted_at'] != null
|
||||
? DateTime.parse(json['deleted_at'])
|
||||
: null,
|
||||
alias: json['alias'],
|
||||
content: json['content'],
|
||||
body: json['body'],
|
||||
tags: json['tags']?.map((x) => Tag.fromJson(x)).toList().cast<Tag>(),
|
||||
categories: json['categories']
|
||||
?.map((x) => Category.fromJson(x))
|
||||
.toList()
|
||||
.cast<Category>(),
|
||||
replies: json['replies'],
|
||||
attachments: json['attachments'] != null
|
||||
? List<int>.from(json['attachments'])
|
||||
: null,
|
||||
replyId: json['reply_id'],
|
||||
repostId: json['repost_id'],
|
||||
realmId: json['realm_id'],
|
||||
@ -90,12 +82,10 @@ class Post {
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt,
|
||||
'alias': alias,
|
||||
'content': content,
|
||||
'body': body,
|
||||
'tags': tags,
|
||||
'categories': categories,
|
||||
'replies': replies,
|
||||
'attachments': attachments,
|
||||
'reply_id': replyId,
|
||||
'repost_id': repostId,
|
||||
'realm_id': realmId,
|
||||
|
Reference in New Issue
Block a user