Post.fromJson constructor

Post.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory Post.fromJson(Map<String, dynamic> json) {
  return Post(
    id: castOrElse(json['id']),
    date: castOrElse(
      json['date'],
      transformer: parseDateIfNotNull,
    ),
    dateGmt: castOrElse(
      json['date_gmt'],
      transformer: parseDateIfNotNull,
    ),
    guid: Content.fromJson(json['guid']),
    password: castOrElse(json['password']),
    modified: castOrElse(json['modified'], transformer: parseDateIfNotNull),
    modifiedGmt: castOrElse(
      json['modified_gmt'],
      transformer: parseDateIfNotNull,
    ),
    slug: castOrElse(json['slug']),
    status: castOrElse(
      json['status'],
      transformer: (value) => getContentStatusFromValue(value as String?),
      orElse: () => ContentStatus.pending,
    )!,
    type: castOrElse(json['type']),
    link: castOrElse(json['link']),
    title: Content.fromJson(json['title']),
    content: Content.fromJson(json['content']),
    excerpt: Content.fromJson(json['excerpt']),
    author: castOrElse(json['author']),
    featuredMedia: castOrElse(json['featured_media']),
    commentStatus: getStatusFromValue(json['comment_status'] as String?),
    pingStatus: getStatusFromValue(json['ping_status'] as String?),
    sticky: castOrElse(json['sticky']),
    template: castOrElse(json['template']),
    format: getFormatFromValue(json['format'] as String?),
    meta: json['meta'],
    categories: mapIterableWithChecks<int>(
      json['categories'],
      (dynamic v) => v as int,
    ),
    tags: mapIterableWithChecks<int>(json['tags'], (dynamic v) => v as int),
    authorMeta: castOrElse(
      json['author_meta'],
      transformer: (value) =>
          AuthorMeta.fromJson(value as Map<String, dynamic>),
    ),
    featuredImageUrl: decodeByMultiKeys(
      json,
      ['featured_image_url', 'featured_media_src_url'],
    ),
    links: castOrElse(
      json['_links'],
      transformer: (value) => Links.fromJson(value as Map<String, dynamic>),
    ),
    self: json,
  );
}