2022-12-21 23:24:08 +00:00
|
|
|
import 'package:stackwallet/models/paynym/paynym_account_lite.dart';
|
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
|
2022-12-21 23:24:08 +00:00
|
|
|
final List<PaynymAccountLite> followers;
|
2022-12-21 16:17:53 +00:00
|
|
|
|
|
|
|
/// list of nymId
|
2022-12-21 23:24:08 +00:00
|
|
|
final List<PaynymAccountLite> following;
|
2022-12-21 16:17:53 +00:00
|
|
|
|
|
|
|
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:24:08 +00:00
|
|
|
followers = (map["followers"] as List<dynamic>)
|
|
|
|
.map((e) =>
|
|
|
|
PaynymAccountLite.fromMap(Map<String, dynamic>.from(e as Map)))
|
|
|
|
.toList(),
|
|
|
|
following = (map["following"] as List<dynamic>)
|
|
|
|
.map((e) =>
|
|
|
|
PaynymAccountLite.fromMap(Map<String, dynamic>.from(e as Map)))
|
|
|
|
.toList();
|
2022-12-21 16:17:53 +00:00
|
|
|
|
2023-01-04 20:56:36 +00:00
|
|
|
PaynymAccount copyWith({
|
|
|
|
String? nymID,
|
|
|
|
String? nymName,
|
|
|
|
List<PaynymCode>? codes,
|
|
|
|
List<PaynymAccountLite>? followers,
|
|
|
|
List<PaynymAccountLite>? following,
|
|
|
|
}) {
|
|
|
|
return PaynymAccount(
|
|
|
|
nymID ?? this.nymID,
|
|
|
|
nymName ?? this.nymName,
|
|
|
|
codes ?? this.codes,
|
|
|
|
followers ?? this.followers,
|
|
|
|
following ?? this.following,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
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:24:08 +00:00
|
|
|
"followers": followers.map((e) => e.toMap()),
|
|
|
|
"following": followers.map((e) => e.toMap()),
|
2022-12-21 16:17:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return toMap().toString();
|
|
|
|
}
|
|
|
|
}
|