2018-02-28 00:59:43 +00:00
|
|
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
|
|
|
|
part of angel_serialize.test.models.author;
|
|
|
|
|
|
|
|
// **************************************************************************
|
|
|
|
// Generator: SerializerGenerator
|
|
|
|
// **************************************************************************
|
|
|
|
|
2018-02-28 01:10:57 +00:00
|
|
|
abstract class AuthorSerializer {
|
2018-02-28 02:10:43 +00:00
|
|
|
static Author fromMap(Map map,
|
|
|
|
{String id,
|
|
|
|
String name,
|
|
|
|
int age,
|
|
|
|
List<Book> books,
|
|
|
|
Book newestBook,
|
2018-03-02 18:38:41 +00:00
|
|
|
String obscured,
|
2018-02-28 02:10:43 +00:00
|
|
|
DateTime createdAt,
|
|
|
|
DateTime updatedAt}) {
|
|
|
|
return new Author(
|
|
|
|
id: map['id'],
|
|
|
|
name: map['name'],
|
|
|
|
age: map['age'],
|
|
|
|
books: map['books'] is Iterable
|
|
|
|
? map['books'].map(BookSerializer.fromMap).toList()
|
|
|
|
: null,
|
|
|
|
newestBook: map['newest_book'] != null
|
|
|
|
? BookSerializer.fromMap(map['newest_book'])
|
|
|
|
: null,
|
2018-03-02 18:38:41 +00:00
|
|
|
obscured: map['obscured'],
|
2018-02-28 02:10:43 +00:00
|
|
|
createdAt: map['created_at'] != null
|
|
|
|
? DateTime.parse(map['created_at'])
|
|
|
|
: null,
|
|
|
|
updatedAt: map['updated_at'] != null
|
|
|
|
? DateTime.parse(map['updated_at'])
|
|
|
|
: null);
|
|
|
|
}
|
|
|
|
|
2018-02-28 01:41:19 +00:00
|
|
|
static Map<String, dynamic> toMap(Author model) {
|
2018-02-28 01:10:57 +00:00
|
|
|
return {
|
2018-02-28 01:41:19 +00:00
|
|
|
'id': model.id,
|
|
|
|
'name': model.name,
|
|
|
|
'age': model.age,
|
2018-02-28 02:10:43 +00:00
|
|
|
'books': model.books?.map(BookSerializer.toMap)?.toList(),
|
2018-02-28 01:41:19 +00:00
|
|
|
'newest_book': BookSerializer.toMap(model.newestBook),
|
2018-02-28 02:10:43 +00:00
|
|
|
'created_at': model.createdAt?.toIso8601String(),
|
|
|
|
'updated_at': model.updatedAt?.toIso8601String()
|
2018-02-28 01:10:57 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2018-02-28 00:59:43 +00:00
|
|
|
|
2018-02-28 01:10:57 +00:00
|
|
|
abstract class LibrarySerializer {
|
2018-02-28 02:10:43 +00:00
|
|
|
static Library fromMap(Map map,
|
|
|
|
{String id,
|
|
|
|
Map<String, Book> collection,
|
|
|
|
DateTime createdAt,
|
|
|
|
DateTime updatedAt}) {
|
|
|
|
return new Library(
|
|
|
|
id: map['id'],
|
|
|
|
collection: map['collection'] is Map
|
|
|
|
? map['collection'].keys.fold({}, (out, key) {
|
|
|
|
return out
|
|
|
|
..[key] = BookSerializer.fromMap(map['collection'][key]);
|
|
|
|
})
|
|
|
|
: null,
|
|
|
|
createdAt: map['created_at'] != null
|
|
|
|
? DateTime.parse(map['created_at'])
|
|
|
|
: null,
|
|
|
|
updatedAt: map['updated_at'] != null
|
|
|
|
? DateTime.parse(map['updated_at'])
|
|
|
|
: null);
|
|
|
|
}
|
|
|
|
|
2018-02-28 01:41:19 +00:00
|
|
|
static Map<String, dynamic> toMap(Library model) {
|
2018-02-28 01:10:57 +00:00
|
|
|
return {
|
2018-02-28 01:41:19 +00:00
|
|
|
'id': model.id,
|
2018-02-28 02:10:43 +00:00
|
|
|
'collection': model.collection.keys?.fold({}, (map, key) {
|
2018-02-28 01:43:43 +00:00
|
|
|
return map..[key] = BookSerializer.toMap(model.collection[key]);
|
|
|
|
}),
|
2018-02-28 02:10:43 +00:00
|
|
|
'created_at': model.createdAt?.toIso8601String(),
|
|
|
|
'updated_at': model.updatedAt?.toIso8601String()
|
2018-02-28 01:10:57 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|