mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-23 09:56:23 +03:00
38 lines
999 B
Dart
38 lines
999 B
Dart
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
part 'models.freezed.dart';
|
|
part 'models.g.dart';
|
|
|
|
@freezed
|
|
class Version with _$Version {
|
|
const Version._();
|
|
const factory Version(int major, int minor, int patch) = _Version;
|
|
|
|
factory Version.fromJson(List<dynamic> values) {
|
|
return Version(values[0], values[1], values[2]);
|
|
}
|
|
|
|
List<dynamic> toJson() => [major, minor, patch];
|
|
|
|
@override
|
|
String toString() {
|
|
return '$major.$minor.$patch';
|
|
}
|
|
}
|
|
|
|
@Freezed(unionKey: 'kind')
|
|
class RpcResponse with _$RpcResponse {
|
|
factory RpcResponse.success(Map<String, dynamic> body) = Success;
|
|
factory RpcResponse.signal(String status, Map<String, dynamic> body) = Signal;
|
|
factory RpcResponse.error(
|
|
String status, String message, Map<String, dynamic> body) = RpcError;
|
|
|
|
factory RpcResponse.fromJson(Map<String, dynamic> json) =>
|
|
_$RpcResponseFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
class RpcState with _$RpcState {
|
|
const factory RpcState(String version) = _RpcState;
|
|
}
|