stack_wallet/lib/models/paynym/paynym_account.dart

57 lines
1.4 KiB
Dart
Raw Normal View History

2022-12-21 16:17:53 +00:00
import 'package:stackwallet/models/paynym/paynym_code.dart';
class PaynymAccount {
final String nymID;
final String nymName;
final List<PaynymCode> codes;
/// list of nymId
final List<String> followers;
/// list of nymId
final List<String> following;
PaynymAccount(
this.nymID,
this.nymName,
this.codes,
this.followers,
this.following,
);
PaynymAccount.fromMap(Map<String, dynamic> map)
: nymID = map["nymID"] as String,
nymName = map["nymName"] as String,
codes = (map["codes"] as List<dynamic>)
.map((e) => PaynymCode.fromMap(Map<String, dynamic>.from(e as Map)))
.toList(),
2022-12-21 23:02:14 +00:00
followers = [],
following = [] {
final f1 = map["followers"] as List<dynamic>;
for (final item in f1) {
followers.add(Map<String, dynamic>.from(item as Map)["nymId"] as String);
}
final f2 = map["following"] as List<dynamic>;
for (final item in f2) {
final nymId = Map<String, dynamic>.from(item as Map)["nymId"] as String;
print(nymId + "DDDDDDDDDDDDD");
following.add(nymId);
}
}
2022-12-21 16:17:53 +00:00
Map<String, dynamic> toMap() => {
"nymID": nymID,
"nymName": nymName,
"codes": codes.map((e) => e.toMap()),
2022-12-21 23:02:14 +00:00
"followers": followers.map((e) => {"nymId": e}).toList(),
"following": followers.map((e) => {"nymId": e}).toList(),
2022-12-21 16:17:53 +00:00
};
@override
String toString() {
return toMap().toString();
}
}