import 'package:fotodocumentation/utils/date_time_utils.dart';

class PictureDto {
  final int id;
  final String? comment;
  final String? category;
  final String image;
  final DateTime pictureDate;
  final String? username;

  PictureDto(
      {required this.id, required this.comment, required this.category, required this.image, required this.pictureDate, required this.username});

  /// Create from JSON response
  factory PictureDto.fromJson(Map<String, dynamic> json) {
    return PictureDto(
      id: json['id'] as int,
      comment: json['comment'] as String?,
      category: json['category'] as String?,
      image: json['image'] as String,
      pictureDate: DateTimeUtils.toDateTime(json['pictureDate']) ?? DateTime.now(),
      username: json['username'] as String?
    );
  }
}