import 'package:syncrow_web/utils/constants/app_enum.dart';

class PasswordModel {
  final dynamic passwordId;
  final dynamic invalidTime;
  final dynamic effectiveTime;
  final dynamic passwordCreated;
  final dynamic createdTime;
  final dynamic passwordName; // New field
  final AccessStatus passwordStatus;
  final AccessType passwordType;
  final dynamic deviceUuid;

  PasswordModel({
    this.passwordId,
    this.invalidTime,
    this.effectiveTime,
    this.passwordCreated,
    this.createdTime,
    this.passwordName, // New field
    required this.passwordStatus,
    required this.passwordType,
    this.deviceUuid,
  });

  factory PasswordModel.fromJson(Map<String, dynamic> json) {
    return PasswordModel(
      passwordId: json['passwordId'],
      invalidTime: json['invalidTime'],
      effectiveTime: json['effectiveTime'],
      passwordCreated: json['passwordCreated'],
      createdTime: json['createdTime'],
      passwordName: json['passwordName']??'No Name',
      passwordStatus: AccessStatusExtension.fromString(json['passwordStatus']),
      passwordType: AccessTypeExtension.fromString(json['passwordType']),
      deviceUuid: json['deviceUuid'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'passwordId': passwordId,
      'invalidTime': invalidTime,
      'effectiveTime': effectiveTime,
      'passwordCreated': passwordCreated,
      'createdTime': createdTime,
      'passwodName': passwordName, // New field
      'passwordStatus': passwordStatus,
      'passwordType': passwordType,
      'deviceUuid': deviceUuid,
    };
  }
}
