Added createdAt attribute in dto classes and json schema
This commit is contained in:
@@ -3,8 +3,8 @@ import 'package:uuid/uuid.dart';
|
||||
|
||||
class Player {
|
||||
final String id;
|
||||
final String name;
|
||||
final DateTime createdAt;
|
||||
final String name;
|
||||
|
||||
Player({String? id, DateTime? createdAt, required this.name})
|
||||
: id = id ?? const Uuid().v4(),
|
||||
@@ -18,8 +18,13 @@ class Player {
|
||||
/// Creates a Player instance from a JSON object.
|
||||
Player.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
createdAt = DateTime.parse(json['createdAt']),
|
||||
name = json['name'];
|
||||
|
||||
/// Converts the Player instance to a JSON object.
|
||||
Map<String, dynamic> toJson() => {'id': id, 'name': name};
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'createdAt': createdAt.toIso8601String(),
|
||||
'name': name,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user