492 lines
12 KiB
Dart
492 lines
12 KiB
Dart
class PostsModel {
|
|
int? id;
|
|
String? date;
|
|
String? dateGmt;
|
|
Guid? guid;
|
|
String? modified;
|
|
String? modifiedGmt;
|
|
String? slug;
|
|
String? status;
|
|
String? type;
|
|
String? link;
|
|
Guid? title;
|
|
Content? content;
|
|
Content? excerpt;
|
|
int? author;
|
|
int? featuredMedia;
|
|
String? commentStatus;
|
|
String? pingStatus;
|
|
bool? sticky;
|
|
String? template;
|
|
String? format;
|
|
Meta? meta;
|
|
List<int>? categories;
|
|
List<int>? tags;
|
|
List<String>? classList;
|
|
String? featuredImageSrc;
|
|
AuthorInfo? authorInfo;
|
|
Links? lLinks;
|
|
|
|
PostsModel(
|
|
{this.id,
|
|
this.date,
|
|
this.dateGmt,
|
|
this.guid,
|
|
this.modified,
|
|
this.modifiedGmt,
|
|
this.slug,
|
|
this.status,
|
|
this.type,
|
|
this.link,
|
|
this.title,
|
|
this.content,
|
|
this.excerpt,
|
|
this.author,
|
|
this.featuredMedia,
|
|
this.commentStatus,
|
|
this.pingStatus,
|
|
this.sticky,
|
|
this.template,
|
|
this.format,
|
|
this.meta,
|
|
this.categories,
|
|
this.tags,
|
|
this.classList,
|
|
this.featuredImageSrc,
|
|
this.authorInfo,
|
|
this.lLinks});
|
|
|
|
PostsModel.fromJson(Map<String, dynamic> json) {
|
|
id = json['id'];
|
|
date = json['date'];
|
|
dateGmt = json['date_gmt'];
|
|
guid = json['guid'] != null ? Guid.fromJson(json['guid']) : null;
|
|
modified = json['modified'];
|
|
modifiedGmt = json['modified_gmt'];
|
|
slug = json['slug'];
|
|
status = json['status'];
|
|
type = json['type'];
|
|
link = json['link'];
|
|
title = json['title'] != null ? Guid.fromJson(json['title']) : null;
|
|
content =
|
|
json['content'] != null ? Content.fromJson(json['content']) : null;
|
|
excerpt =
|
|
json['excerpt'] != null ? Content.fromJson(json['excerpt']) : null;
|
|
author = json['author'];
|
|
featuredMedia = json['featured_media'];
|
|
commentStatus = json['comment_status'];
|
|
pingStatus = json['ping_status'];
|
|
sticky = json['sticky'];
|
|
template = json['template'];
|
|
format = json['format'];
|
|
meta = json['meta'] != null ? Meta.fromJson(json['meta']) : null;
|
|
categories = json['categories'].cast<int>();
|
|
tags = json['tags'].cast<int>();
|
|
classList = json['class_list'].cast<String>();
|
|
featuredImageSrc = json['featured_image_src'];
|
|
authorInfo = json['author_info'] != null
|
|
? AuthorInfo.fromJson(json['author_info'])
|
|
: null;
|
|
lLinks = json['_links'] != null ? Links.fromJson(json['_links']) : null;
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['id'] = id;
|
|
data['date'] = date;
|
|
data['date_gmt'] = dateGmt;
|
|
if (guid != null) {
|
|
data['guid'] = guid!.toJson();
|
|
}
|
|
data['modified'] = modified;
|
|
data['modified_gmt'] = modifiedGmt;
|
|
data['slug'] = slug;
|
|
data['status'] = status;
|
|
data['type'] = type;
|
|
data['link'] = link;
|
|
if (title != null) {
|
|
data['title'] = title!.toJson();
|
|
}
|
|
if (content != null) {
|
|
data['content'] = content!.toJson();
|
|
}
|
|
if (excerpt != null) {
|
|
data['excerpt'] = excerpt!.toJson();
|
|
}
|
|
data['author'] = author;
|
|
data['featured_media'] = featuredMedia;
|
|
data['comment_status'] = commentStatus;
|
|
data['ping_status'] = pingStatus;
|
|
data['sticky'] = sticky;
|
|
data['template'] = template;
|
|
data['format'] = format;
|
|
if (meta != null) {
|
|
data['meta'] = meta!.toJson();
|
|
}
|
|
data['categories'] = categories;
|
|
data['tags'] = tags;
|
|
data['class_list'] = classList;
|
|
data['featured_image_src'] = featuredImageSrc;
|
|
if (authorInfo != null) {
|
|
data['author_info'] = authorInfo!.toJson();
|
|
}
|
|
if (lLinks != null) {
|
|
data['_links'] = lLinks!.toJson();
|
|
}
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class Guid {
|
|
String? rendered;
|
|
|
|
Guid({this.rendered});
|
|
|
|
Guid.fromJson(Map<String, dynamic> json) {
|
|
rendered = json['rendered'];
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['rendered'] = rendered;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class Content {
|
|
String? rendered;
|
|
bool? protected;
|
|
|
|
Content({this.rendered, this.protected});
|
|
|
|
Content.fromJson(Map<String, dynamic> json) {
|
|
rendered = json['rendered'];
|
|
protected = json['protected'];
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['rendered'] = rendered;
|
|
data['protected'] = protected;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class Meta {
|
|
String? ubCttVia;
|
|
String? footnotes;
|
|
|
|
Meta({this.ubCttVia, this.footnotes});
|
|
|
|
Meta.fromJson(Map<String, dynamic> json) {
|
|
ubCttVia = json['ub_ctt_via'];
|
|
footnotes = json['footnotes'];
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['ub_ctt_via'] = ubCttVia;
|
|
data['footnotes'] = footnotes;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class AuthorInfo {
|
|
String? displayName;
|
|
String? authorLink;
|
|
|
|
AuthorInfo({this.displayName, this.authorLink});
|
|
|
|
AuthorInfo.fromJson(Map<String, dynamic> json) {
|
|
displayName = json['display_name'];
|
|
authorLink = json['author_link'];
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['display_name'] = displayName;
|
|
data['author_link'] = authorLink;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class Links {
|
|
List<Self>? self;
|
|
List<Collection>? collection;
|
|
// List<About>? about;
|
|
List<Author>? author;
|
|
// List<Replies>? replies;
|
|
List<VersionHistory>? versionHistory;
|
|
List<PredecessorVersion>? predecessorVersion;
|
|
// List<WpAttachment>? wpAttachment;
|
|
List<WpTerm>? wpTerm;
|
|
List<Curies>? curies;
|
|
|
|
Links(
|
|
{this.self,
|
|
this.collection,
|
|
// this.about,
|
|
this.author,
|
|
// this.replies,
|
|
this.versionHistory,
|
|
this.predecessorVersion,
|
|
// this.wpAttachment,
|
|
this.wpTerm,
|
|
this.curies});
|
|
|
|
Links.fromJson(Map<String, dynamic> json) {
|
|
if (json['self'] != null) {
|
|
self = <Self>[];
|
|
json['self'].forEach((v) {
|
|
self!.add(Self.fromJson(v));
|
|
});
|
|
}
|
|
if (json['collection'] != null) {
|
|
collection = <Collection>[];
|
|
json['collection'].forEach((v) {
|
|
collection!.add(Collection.fromJson(v));
|
|
});
|
|
}
|
|
// if (json['about'] != null) {
|
|
// about = <About>[];
|
|
// json['about'].forEach((v) {
|
|
// about!.add(About.fromJson(v));
|
|
// });
|
|
// }
|
|
if (json['author'] != null) {
|
|
author = <Author>[];
|
|
json['author'].forEach((v) {
|
|
author!.add(Author.fromJson(v));
|
|
});
|
|
}
|
|
// if (json['replies'] != null) {
|
|
// replies = <Replies>[];
|
|
// json['replies'].forEach((v) {
|
|
// replies!.add(Replies.fromJson(v));
|
|
// });
|
|
// }
|
|
if (json['version-history'] != null) {
|
|
versionHistory = <VersionHistory>[];
|
|
json['version-history'].forEach((v) {
|
|
versionHistory!.add(VersionHistory.fromJson(v));
|
|
});
|
|
}
|
|
if (json['predecessor-version'] != null) {
|
|
predecessorVersion = <PredecessorVersion>[];
|
|
json['predecessor-version'].forEach((v) {
|
|
predecessorVersion!.add(PredecessorVersion.fromJson(v));
|
|
});
|
|
}
|
|
// if (json['wp:attachment'] != null) {
|
|
// wpAttachment = <WpAttachment>[];
|
|
// json['wp:attachment'].forEach((v) {
|
|
// wpAttachment!.add(WpAttachment.fromJson(v));
|
|
// });
|
|
// }
|
|
if (json['wp:term'] != null) {
|
|
wpTerm = <WpTerm>[];
|
|
json['wp:term'].forEach((v) {
|
|
wpTerm!.add(WpTerm.fromJson(v));
|
|
});
|
|
}
|
|
if (json['curies'] != null) {
|
|
curies = <Curies>[];
|
|
json['curies'].forEach((v) {
|
|
curies!.add(Curies.fromJson(v));
|
|
});
|
|
}
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
if (self != null) {
|
|
data['self'] = self!.map((v) => v.toJson()).toList();
|
|
}
|
|
if (collection != null) {
|
|
data['collection'] = collection!.map((v) => v.toJson()).toList();
|
|
}
|
|
// if (about != null) {
|
|
// data['about'] = about!.map((v) => v.toJson()).toList();
|
|
// }
|
|
if (author != null) {
|
|
data['author'] = author!.map((v) => v.toJson()).toList();
|
|
}
|
|
// if (replies != null) {
|
|
// data['replies'] = replies!.map((v) => v.toJson()).toList();
|
|
// }
|
|
if (versionHistory != null) {
|
|
data['version-history'] = versionHistory!.map((v) => v.toJson()).toList();
|
|
}
|
|
if (predecessorVersion != null) {
|
|
data['predecessor-version'] =
|
|
predecessorVersion!.map((v) => v.toJson()).toList();
|
|
}
|
|
// if (wpAttachment != null) {
|
|
// data['wp:attachment'] = wpAttachment!.map((v) => v.toJson()).toList();
|
|
// }
|
|
if (wpTerm != null) {
|
|
data['wp:term'] = wpTerm!.map((v) => v.toJson()).toList();
|
|
}
|
|
if (curies != null) {
|
|
data['curies'] = curies!.map((v) => v.toJson()).toList();
|
|
}
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class Self {
|
|
String? href;
|
|
TargetHints? targetHints;
|
|
|
|
Self({this.href, this.targetHints});
|
|
|
|
Self.fromJson(Map<String, dynamic> json) {
|
|
href = json['href'];
|
|
targetHints = json['targetHints'] != null
|
|
? TargetHints.fromJson(json['targetHints'])
|
|
: null;
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['href'] = href;
|
|
if (targetHints != null) {
|
|
data['targetHints'] = targetHints!.toJson();
|
|
}
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class TargetHints {
|
|
List<String>? allow;
|
|
|
|
TargetHints({this.allow});
|
|
|
|
TargetHints.fromJson(Map<String, dynamic> json) {
|
|
allow = json['allow'].cast<String>();
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['allow'] = allow;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class Collection {
|
|
String? href;
|
|
|
|
Collection({this.href});
|
|
|
|
Collection.fromJson(Map<String, dynamic> json) {
|
|
href = json['href'];
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['href'] = href;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class Author {
|
|
bool? embeddable;
|
|
String? href;
|
|
|
|
Author({this.embeddable, this.href});
|
|
|
|
Author.fromJson(Map<String, dynamic> json) {
|
|
embeddable = json['embeddable'];
|
|
href = json['href'];
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['embeddable'] = embeddable;
|
|
data['href'] = href;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class VersionHistory {
|
|
int? count;
|
|
String? href;
|
|
|
|
VersionHistory({this.count, this.href});
|
|
|
|
VersionHistory.fromJson(Map<String, dynamic> json) {
|
|
count = json['count'];
|
|
href = json['href'];
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['count'] = count;
|
|
data['href'] = href;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class PredecessorVersion {
|
|
int? id;
|
|
String? href;
|
|
|
|
PredecessorVersion({this.id, this.href});
|
|
|
|
PredecessorVersion.fromJson(Map<String, dynamic> json) {
|
|
id = json['id'];
|
|
href = json['href'];
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['id'] = id;
|
|
data['href'] = href;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class WpTerm {
|
|
String? taxonomy;
|
|
bool? embeddable;
|
|
String? href;
|
|
|
|
WpTerm({this.taxonomy, this.embeddable, this.href});
|
|
|
|
WpTerm.fromJson(Map<String, dynamic> json) {
|
|
taxonomy = json['taxonomy'];
|
|
embeddable = json['embeddable'];
|
|
href = json['href'];
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['taxonomy'] = taxonomy;
|
|
data['embeddable'] = embeddable;
|
|
data['href'] = href;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class Curies {
|
|
String? name;
|
|
String? href;
|
|
bool? templated;
|
|
|
|
Curies({this.name, this.href, this.templated});
|
|
|
|
Curies.fromJson(Map<String, dynamic> json) {
|
|
name = json['name'];
|
|
href = json['href'];
|
|
templated = json['templated'];
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['name'] = name;
|
|
data['href'] = href;
|
|
data['templated'] = templated;
|
|
return data;
|
|
}
|
|
}
|