Solian/lib/models/account.dart

60 lines
1.5 KiB
Dart
Raw Normal View History

2024-04-17 15:00:53 +00:00
class Account {
int id;
DateTime createdAt;
DateTime updatedAt;
DateTime? deletedAt;
String name;
String nick;
String avatar;
String banner;
String description;
2024-04-25 15:03:16 +00:00
String? emailAddress;
2024-04-17 15:00:53 +00:00
int powerLevel;
2024-04-25 15:03:16 +00:00
int? externalId;
2024-04-17 15:00:53 +00:00
Account({
required this.id,
required this.createdAt,
required this.updatedAt,
this.deletedAt,
required this.name,
required this.nick,
required this.avatar,
required this.banner,
required this.description,
2024-04-25 15:03:16 +00:00
this.emailAddress,
2024-04-17 15:00:53 +00:00
required this.powerLevel,
2024-04-25 15:03:16 +00:00
this.externalId,
2024-04-17 15:00:53 +00:00
});
factory Account.fromJson(Map<String, dynamic> json) => Account(
2024-05-01 16:49:38 +00:00
id: json['id'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
deletedAt: json['deleted_at'],
name: json['name'],
nick: json['nick'],
avatar: json['avatar'],
banner: json['banner'],
description: json['description'],
emailAddress: json['email_address'],
powerLevel: json['power_level'],
externalId: json['external_id'],
2024-04-17 15:00:53 +00:00
);
Map<String, dynamic> toJson() => {
2024-05-01 16:49:38 +00:00
'id': id,
'created_at': createdAt.toIso8601String(),
'updated_at': updatedAt.toIso8601String(),
'deleted_at': deletedAt,
'name': name,
'nick': nick,
'avatar': avatar,
'banner': banner,
'description': description,
'email_address': emailAddress,
'power_level': powerLevel,
'external_id': externalId,
2024-04-17 15:00:53 +00:00
};
}