2021-12-06 18:31:19 +00:00
|
|
|
import 'package:json_annotation/json_annotation.dart';
|
2023-06-22 14:14:00 +00:00
|
|
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/backups.graphql.dart';
|
2021-12-06 18:31:19 +00:00
|
|
|
|
|
|
|
part 'backup.g.dart';
|
|
|
|
|
|
|
|
@JsonSerializable()
|
|
|
|
class Backup {
|
2022-06-09 21:13:06 +00:00
|
|
|
factory Backup.fromJson(final Map<String, dynamic> json) =>
|
|
|
|
_$BackupFromJson(json);
|
2023-06-22 14:14:00 +00:00
|
|
|
Backup.fromGraphQL(
|
|
|
|
final Query$AllBackupSnapshots$backup$allSnapshots snapshot,
|
|
|
|
) : this(
|
|
|
|
id: snapshot.id,
|
|
|
|
time: snapshot.createdAt,
|
|
|
|
serviceId: snapshot.service.id,
|
|
|
|
fallbackServiceName: snapshot.service.displayName,
|
|
|
|
);
|
|
|
|
|
|
|
|
Backup({
|
|
|
|
required this.time,
|
|
|
|
required this.id,
|
|
|
|
required this.serviceId,
|
|
|
|
required this.fallbackServiceName,
|
|
|
|
});
|
2021-12-06 18:31:19 +00:00
|
|
|
|
|
|
|
// Time of the backup
|
|
|
|
final DateTime time;
|
|
|
|
@JsonKey(name: 'short_id')
|
|
|
|
final String id;
|
2023-06-22 14:14:00 +00:00
|
|
|
final String serviceId;
|
|
|
|
final String fallbackServiceName;
|
2021-12-06 18:31:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum BackupStatusEnum {
|
|
|
|
@JsonValue('NO_KEY')
|
|
|
|
noKey,
|
|
|
|
@JsonValue('NOT_INITIALIZED')
|
|
|
|
notInitialized,
|
|
|
|
@JsonValue('INITIALIZED')
|
|
|
|
initialized,
|
|
|
|
@JsonValue('BACKING_UP')
|
|
|
|
backingUp,
|
|
|
|
@JsonValue('RESTORING')
|
|
|
|
restoring,
|
|
|
|
@JsonValue('ERROR')
|
|
|
|
error,
|
|
|
|
@JsonValue('INITIALIZING')
|
|
|
|
initializing,
|
|
|
|
}
|
|
|
|
|
|
|
|
@JsonSerializable()
|
|
|
|
class BackupStatus {
|
2022-06-05 19:36:32 +00:00
|
|
|
factory BackupStatus.fromJson(final Map<String, dynamic> json) =>
|
|
|
|
_$BackupStatusFromJson(json);
|
2022-06-09 21:13:06 +00:00
|
|
|
BackupStatus({
|
|
|
|
required this.status,
|
|
|
|
required this.progress,
|
|
|
|
required this.errorMessage,
|
|
|
|
});
|
2021-12-06 18:31:19 +00:00
|
|
|
|
|
|
|
final BackupStatusEnum status;
|
|
|
|
final double progress;
|
|
|
|
@JsonKey(name: 'error_message')
|
2021-12-09 03:22:33 +00:00
|
|
|
final String? errorMessage;
|
2021-12-06 18:31:19 +00:00
|
|
|
}
|