import 'package:didvan/models/overview_data.dart';
import 'package:didvan/models/tag.dart';

class StudioDetailsData {
  final int id;
  final int duration;
  final String title;
  final String description;
  final String image;
  final String link;
  final String? iframe;
  final String createdAt;
  final int order;
  final String type;
  bool relatedContentsIsEmpty;
  bool marked;
  int comments;
  final List<Tag> tags;
  final List<OverviewData> relatedContents = [];

  StudioDetailsData({
    required this.id,
    required this.duration,
    required this.title,
    required this.description,
    required this.image,
    required this.link,
    required this.iframe,
    required this.createdAt,
    required this.order,
    required this.marked,
    required this.comments,
    required this.tags,
    required this.type,
    this.relatedContentsIsEmpty = false,
  });

  factory StudioDetailsData.fromJson(Map<String, dynamic> json) {
    return StudioDetailsData(
      id: json['id'],
      duration: json['duration'],
      title: json['title'],
      description: json['description'],
      image: json['image'],
      link: json['link'],
      iframe: json['iframe'],
      createdAt: json['createdAt'],
      order: json['order'],
      marked: json['marked'],
      comments: json['comments'],
      tags: List<Tag>.from(json['tags'].map((e) => Tag.fromJson(e))),
      type: json['type'],
    );
  }

  Map<String, dynamic> toJson() => {
        'id': id,
        'duration': duration,
        'title': title,
        'description': description,
        'image': image,
        'createdAt': createdAt,
        'order': order,
        'marked': marked,
        'comments': comments,
        'tags': tags.map((e) => e.toJson()).toList(),
      };
}
