selfprivacy.org.app/lib/logic/models/json/recovery_token_status.dart

45 lines
1.1 KiB
Dart
Raw Normal View History

2022-05-24 16:09:47 +00:00
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/server_api.graphql.dart';
part 'recovery_token_status.g.dart';
@JsonSerializable()
2022-05-24 16:09:47 +00:00
class RecoveryKeyStatus extends Equatable {
2022-06-05 19:36:32 +00:00
factory RecoveryKeyStatus.fromJson(final Map<String, dynamic> json) =>
_$RecoveryKeyStatusFromJson(json);
2022-05-24 18:55:39 +00:00
const RecoveryKeyStatus({
required this.exists,
required this.valid,
this.date,
this.expiration,
2022-05-24 16:09:47 +00:00
this.usesLeft,
});
RecoveryKeyStatus.fromGraphQL(
final Query$RecoveryKey$api$recoveryKey recoveryKey,
) : this(
exists: recoveryKey.exists,
date: recoveryKey.creationDate,
expiration: recoveryKey.expirationDate,
usesLeft: recoveryKey.usesLeft,
valid: recoveryKey.valid,
);
final bool exists;
final DateTime? date;
final DateTime? expiration;
2022-05-24 16:09:47 +00:00
@JsonKey(name: 'uses_left')
final int? usesLeft;
final bool valid;
2022-05-24 16:09:47 +00:00
@override
List<Object?> get props => [
exists,
date,
expiration,
usesLeft,
valid,
];
}