import 'package:be_happy/domain/entities/subscription.dart';

class ClientSubscription {
  final int id;
  final int subscriptionId;
  final Subscription subscription;
  final DateTime? expiredAt;

  ClientSubscription({
    required this.id,
    required this.subscriptionId,
    required this.subscription,
    this.expiredAt,
  });

  factory ClientSubscription.fromJson(Map<String, dynamic> json) {
    return ClientSubscription(
      id: json['id'] ?? 0,
      subscriptionId: json['subscriptionId'] ?? 0,
      subscription: Subscription.fromJson(json['subscription'] as Map<String, dynamic>),
      expiredAt: json['expiredAt'] != null ? DateTime.parse(json['expiredAt']) : null,
    );
  }
}