class FailedOperation {
  final bool success;
  final dynamic deviceUuid;
  final dynamic error;
  final String deviceName;

  FailedOperation({
    required this.success,
    required this.deviceUuid,
    required this.error,
    required this.deviceName,
  });

  factory FailedOperation.fromJson(Map<String, dynamic> json) {
    return FailedOperation(
      success: json['success'],
      deviceUuid: json['deviceUuid'],
      error: json['error'],
      deviceName: json['deviceName'] as String? ?? '',
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'success': success,
      'deviceUuid': deviceUuid,
      'error': error,
      'deviceName': deviceName,
    };
  }
}

class SuccessOperation {
  final bool success;
  // final Result result;
  final String deviceUuid;
  final String deviceName;

  SuccessOperation({
    required this.success,
    // required this.result,
    required this.deviceUuid,
    required this.deviceName,
  });

  factory SuccessOperation.fromJson(Map<String, dynamic> json) {
    return SuccessOperation(
      success: json['success'],
      // result: Result.fromJson(json['result']),
      deviceUuid: json['deviceUuid'],
      deviceName: json['deviceName'] as String? ?? '',
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'success': success,
      // 'result': result.toJson(),
      'deviceUuid': deviceUuid,
      'deviceName': deviceName,
    };
  }
}

// class Result {
//   final dynamic effectiveTime;
//   final dynamic invalidTime;
//   final dynamic offlineTempPassword;
//   final dynamic offlineTempPasswordId;
//   final dynamic offlineTempPasswordName;
//
//   Result({
//     required this.effectiveTime,
//     required this.invalidTime,
//     required this.offlineTempPassword,
//     required this.offlineTempPasswordId,
//     required this.offlineTempPasswordName,
//   });
//
//   factory Result.fromJson(Map<String, dynamic> json) {
//     return Result(
//       effectiveTime: json['effective_time'],
//       invalidTime: json['invalid_time'],
//       offlineTempPassword: json['offline_temp_password'].toString(),
//       offlineTempPasswordId: json['offline_temp_password_id'],
//       offlineTempPasswordName: json['offline_temp_password_name'],
//     );
//   }
//
//   Map<String, dynamic> toJson() {
//     return {
//       'effective_time': effectiveTime,
//       'invalid_time': invalidTime,
//       'offline_temp_password': offlineTempPassword,
//       'offline_temp_password_id': offlineTempPasswordId,
//       'offline_temp_password_name': offlineTempPasswordName,
//     };
//   }
// }

class PasswordStatus {
  final List<SuccessOperation> successOperations;
  final List<FailedOperation> failedOperations;

  PasswordStatus({
    required this.successOperations,
    required this.failedOperations,
  });

  factory PasswordStatus.fromJson(Map<String, dynamic> json) {
    return PasswordStatus(
      successOperations: (json['successOperations'] as List)
          .map((i) => SuccessOperation.fromJson(i))
          .toList(),
      failedOperations: (json['failedOperations'] as List)
          .map((i) => FailedOperation.fromJson(i))
          .toList(),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'successOperations': successOperations.map((e) => e.toJson()).toList(),
      'failedOperations': failedOperations.map((e) => e.toJson()).toList(),
    };
  }
}
