import "materiel_item.dart";

/// Réponse renvoyée par l'API après création d'un emprunt.
class EmpruntResponse {
  const EmpruntResponse({
    required this.id,
    required this.dateEmprunt,
    required this.dateRetourPrevue,
    required this.statut,
    required this.materiel,
  });

  factory EmpruntResponse.fromJson(Map<String, dynamic> json) {
    return EmpruntResponse(
      id: json["id"] as int,
      dateEmprunt: DateTime.parse(json["dateEmprunt"] as String),
      dateRetourPrevue: DateTime.parse(json["dateRetourPrevue"] as String),
      statut: json["statut"] as String,
      materiel: MaterielItem.fromJson(json["materiel"] as Map<String, dynamic>),
    );
  }

  final int id;
  final DateTime dateEmprunt;
  final DateTime dateRetourPrevue;
  final String statut;
  final MaterielItem materiel;
}
