35 lines
849 B
Dart
35 lines
849 B
Dart
import 'package:json_annotation/json_annotation.dart';
|
|
|
|
part 'ninja_node.g.dart';
|
|
|
|
double? _toDouble(v) {
|
|
return double.tryParse(v.toString());
|
|
}
|
|
|
|
BigInt _toBigInt(v) {
|
|
return BigInt.from(v);
|
|
}
|
|
|
|
/// Represent a node that is returned from the MyNanoNinja API
|
|
@JsonSerializable()
|
|
class NinjaNode {
|
|
@JsonKey(name:'votingweight', fromJson: _toBigInt)
|
|
BigInt votingWeight;
|
|
|
|
@JsonKey(name:'uptime', fromJson: _toDouble)
|
|
double uptime;
|
|
|
|
@JsonKey(name:'score')
|
|
int score;
|
|
|
|
@JsonKey(name:'account')
|
|
String account;
|
|
|
|
@JsonKey(name:'alias')
|
|
String alias;
|
|
|
|
NinjaNode({required this.votingWeight, required this.uptime, required this.score, required this.account, required this.alias});
|
|
|
|
factory NinjaNode.fromJson(Map<String, dynamic> json) => _$NinjaNodeFromJson(json);
|
|
Map<String, dynamic> toJson() => _$NinjaNodeToJson(this);
|
|
} |