import 'package:didvan/models/category.dart';

class RadarAttachment {
  final int id;
  final String title;
  final String description;
  final int timeToRead;
  final String image;
  final bool forManagers;
  final String createdAt;
  final List<CategoryData> categories;

  const RadarAttachment({
    required this.id,
    required this.title,
    required this.description,
    required this.timeToRead,
    required this.image,
    required this.forManagers,
    required this.categories,
    required this.createdAt,
  });

  factory RadarAttachment.fromJson(Map<String, dynamic> json) =>
      RadarAttachment(
        id: json['id'],
        title: json['title'],
        description: json['description'],
        timeToRead: json['timeToRead'],
        image: json['image'],
        createdAt: json['createdAt'],
        forManagers: json['forManagers'],
        categories: List<CategoryData>.from(
          json['categories'].map(
            (cat) => CategoryData.fromJson(cat),
          ),
        ),
      );

  Map<String, dynamic> toJson() => {
        'id': id,
        'title': title,
        'description': description,
        'timeToRead': timeToRead,
        'image': image,
        'forManagers': forManagers,
      };
}
