/// Modèle de sauvegarde
/// Correspond à BackupResponse du backend
library backup_model;

import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';

part 'backup_model.g.dart';

@JsonSerializable(explicitToJson: true)
class BackupModel extends Equatable {
  final String? id;
  final String? name;
  final String? description;
  final String? type; // AUTO, MANUAL, RESTORE_POINT
  final int? sizeBytes;
  final String? sizeFormatted;
  final String? status; // PENDING, IN_PROGRESS, COMPLETED, FAILED
  final DateTime? createdAt;
  final DateTime? completedAt;
  final String? createdBy;
  final bool? includesDatabase;
  final bool? includesFiles;
  final bool? includesConfiguration;
  final String? filePath;
  final String? errorMessage;

  const BackupModel({
    this.id,
    this.name,
    this.description,
    this.type,
    this.sizeBytes,
    this.sizeFormatted,
    this.status,
    this.createdAt,
    this.completedAt,
    this.createdBy,
    this.includesDatabase,
    this.includesFiles,
    this.includesConfiguration,
    this.filePath,
    this.errorMessage,
  });

  factory BackupModel.fromJson(Map<String, dynamic> json) =>
      _$BackupModelFromJson(json);

  Map<String, dynamic> toJson() => _$BackupModelToJson(this);

  @override
  List<Object?> get props => [
        id,
        name,
        description,
        type,
        sizeBytes,
        sizeFormatted,
        status,
        createdAt,
        completedAt,
        createdBy,
        includesDatabase,
        includesFiles,
        includesConfiguration,
        filePath,
        errorMessage,
      ];
}
