Untitled

 avatar
unknown
plain_text
14 days ago
4.1 kB
3
Indexable
import 'dart:convert';

class PersonalisedInsight {
  final int id;
  final String title;
  final String thumbnailImage;
  final int insightsType;
  final int goalType;
  final String goalTypeName;
  final int viewType;
  final String viewTypeName;
  final String? insightsVideo;
  final List<StoryImage> storyImage;
  final String imageVideoImage;
  final String videoImageVideo;
  final Article article;
  final String? createdAt;
  final String? updatedAt;

  PersonalisedInsight({
    required this.id,
    required this.title,
    required this.thumbnailImage,
    required this.insightsType,
    required this.goalType,
    required this.goalTypeName,
    required this.viewType,
    required this.viewTypeName,
    this.insightsVideo,
    required this.storyImage,
    required this.imageVideoImage,
    required this.videoImageVideo,
    required this.article,
    this.createdAt,
    this.updatedAt,
  });

  factory PersonalisedInsight.fromJson(Map<String, dynamic> json) {
    return PersonalisedInsight(
      id: json['id'],
      title: json['title'],
      thumbnailImage: json['thumbnail_image'],
      insightsType: json['insights_type'],
      goalType: json['goal_type'],
      goalTypeName: json['goal_type_name'],
      viewType: json['view_type'],
      viewTypeName: json['view_type_name'],
      insightsVideo: json['insights_video'],
      storyImage: (json['story_image'] as List)
          .map((e) => StoryImage.fromJson(e))
          .toList(),
      imageVideoImage: json['image_video_image'],
      videoImageVideo: json['video_image_video'],
      article: Article.fromJson(json['article']),
      createdAt: json['created_at'],
      updatedAt: json['updated_at'],
    );
  }
}

class StoryImage {
  final int id;
  final String url;

  StoryImage({required this.id, required this.url});

  factory StoryImage.fromJson(Map<String, dynamic> json) {
    return StoryImage(
      id: json['id'],
      url: json['url'],
    );
  }
}

class Article {
  final int id;
  final String name;
  final List<Tag> tags;
  final int articleType;
  final int goalType;
  final String goalTypeName;
  final String description;
  final ExpertData expertData;
  final List<dynamic> articleReference;
  final String articleImage;
  final String? createdAt;
  final String? updatedAt;

  Article({
    required this.id,
    required this.name,
    required this.tags,
    required this.articleType,
    required this.goalType,
    required this.goalTypeName,
    required this.description,
    required this.expertData,
    required this.articleReference,
    required this.articleImage,
    this.createdAt,
    this.updatedAt,
  });

  factory Article.fromJson(Map<String, dynamic> json) {
    return Article(
      id: json['id'],
      name: json['name'],
      tags: (json['tags'] as List).map((e) => Tag.fromJson(e)).toList(),
      articleType: json['article_type'],
      goalType: json['goal_type'],
      goalTypeName: json['goal_type_name'],
      description: json['description'],
      expertData: ExpertData.fromJson(json['expert_data']),
      articleReference: json['article_reference'] ?? [],
      articleImage: json['article_image'],
      createdAt: json['created_at'],
      updatedAt: json['updated_at'],
    );
  }
}

class Tag {
  final int id;
  final String name;

  Tag({required this.id, required this.name});

  factory Tag.fromJson(Map<String, dynamic> json) {
    return Tag(
      id: json['id'],
      name: json['name'],
    );
  }
}

class ExpertData {
  final int id;
  final String name;
  final String tagLine;
  final String healthExpertsImage;

  ExpertData({
    required this.id,
    required this.name,
    required this.tagLine,
    required this.healthExpertsImage,
  });

  factory ExpertData.fromJson(Map<String, dynamic> json) {
    return ExpertData(
      id: json['id'],
      name: json['name'],
      tagLine: json['tag_line'],
      healthExpertsImage: json['health_experts_image'],
    );
  }
}
Editor is loading...
Leave a Comment