import 'package:proxibuy/data/models/offer_model.dart';

class NotificationModel {
  final String id;
  final String description;
  final DateTime createdAt;
  final String discountId;
  final String discountName;
  final String shopName;
  final bool status;
  OfferModel? offer;

  NotificationModel({
    required this.id,
    required this.description,
    required this.createdAt,
    required this.discountId,
    required this.discountName,
    required this.shopName,
    required this.status,
    this.offer,
  });

  factory NotificationModel.fromJson(Map<String, dynamic> json) {
    final bool statusValue = json['Status'] is bool ? json['Status'] : false;

    return NotificationModel(
      id: json['ID'] ?? '',
      description: json['Description'] ?? 'No description available.',
      createdAt: DateTime.tryParse(json['createdAt'] ?? '') ?? DateTime.now(),
      discountId: json['Discount']?['ID'] ?? '',
      discountName: json['Discount']?['Name'] ?? 'Unknown Discount',
      shopName: json['Discount']?['Shop']?['Name'] ?? 'Unknown Shop',
      status: statusValue,
    );
  }
}