2018-02-28 00:59:43 +00:00
|
|
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
|
|
|
|
part of angel_serialize.test.models.author;
|
|
|
|
|
|
|
|
// **************************************************************************
|
2018-06-29 04:11:57 +00:00
|
|
|
// SerializerGenerator
|
2018-02-28 00:59:43 +00:00
|
|
|
// **************************************************************************
|
|
|
|
|
2018-02-28 01:10:57 +00:00
|
|
|
abstract class AuthorSerializer {
|
2018-03-09 12:45:03 +00:00
|
|
|
static Author fromMap(Map map) {
|
2018-05-15 19:33:57 +00:00
|
|
|
if (map['name'] == null) {
|
|
|
|
throw new FormatException("Missing required field 'name' on Author.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (map['age'] == null) {
|
|
|
|
throw new FormatException("Custom message for missing `age`");
|
|
|
|
}
|
|
|
|
|
2018-02-28 02:10:43 +00:00
|
|
|
return new Author(
|
2018-06-27 05:36:57 +00:00
|
|
|
id: map['id'] as String,
|
|
|
|
name: map['name'] as String,
|
|
|
|
age: map['age'] as int,
|
2018-02-28 02:10:43 +00:00
|
|
|
books: map['books'] is Iterable
|
2018-06-27 05:36:57 +00:00
|
|
|
? new List.unmodifiable(((map['books'] as Iterable)
|
|
|
|
.where((x) => x is Map) as Iterable<Map>)
|
|
|
|
.map(BookSerializer.fromMap))
|
2018-02-28 02:10:43 +00:00
|
|
|
: null,
|
|
|
|
newestBook: map['newest_book'] != null
|
2018-07-11 13:06:03 +00:00
|
|
|
? BookSerializer.fromMap(map['newest_book'] as Map)
|
2018-02-28 02:10:43 +00:00
|
|
|
: null,
|
2018-06-27 05:36:57 +00:00
|
|
|
obscured: map['obscured'] as String,
|
2018-02-28 02:10:43 +00:00
|
|
|
createdAt: map['created_at'] != null
|
2018-03-30 18:53:38 +00:00
|
|
|
? (map['created_at'] is DateTime
|
2018-06-27 05:36:57 +00:00
|
|
|
? (map['created_at'] as DateTime)
|
2018-03-30 18:53:38 +00:00
|
|
|
: DateTime.parse(map['created_at']))
|
2018-02-28 02:10:43 +00:00
|
|
|
: null,
|
|
|
|
updatedAt: map['updated_at'] != null
|
2018-03-30 18:53:38 +00:00
|
|
|
? (map['updated_at'] is DateTime
|
2018-06-27 05:36:57 +00:00
|
|
|
? (map['updated_at'] as DateTime)
|
2018-03-30 18:53:38 +00:00
|
|
|
: DateTime.parse(map['updated_at']))
|
2018-02-28 02:10:43 +00:00
|
|
|
: null);
|
|
|
|
}
|
|
|
|
|
2018-02-28 01:41:19 +00:00
|
|
|
static Map<String, dynamic> toMap(Author model) {
|
2018-06-28 01:58:42 +00:00
|
|
|
if (model == null) {
|
|
|
|
return null;
|
|
|
|
}
|
2018-05-15 19:33:57 +00:00
|
|
|
if (model.name == null) {
|
|
|
|
throw new FormatException("Missing required field 'name' on Author.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (model.age == null) {
|
|
|
|
throw new FormatException("Custom message for missing `age`");
|
|
|
|
}
|
|
|
|
|
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-07-11 13:06:03 +00:00
|
|
|
'books': model.books?.map((m) => m.toJson())?.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-03-09 12:39:21 +00:00
|
|
|
abstract class AuthorFields {
|
|
|
|
static const String id = 'id';
|
|
|
|
|
|
|
|
static const String name = 'name';
|
|
|
|
|
|
|
|
static const String age = 'age';
|
|
|
|
|
|
|
|
static const String books = 'books';
|
|
|
|
|
|
|
|
static const String newestBook = 'newest_book';
|
|
|
|
|
|
|
|
static const String secret = 'secret';
|
|
|
|
|
|
|
|
static const String obscured = 'obscured';
|
|
|
|
|
|
|
|
static const String createdAt = 'created_at';
|
|
|
|
|
|
|
|
static const String updatedAt = 'updated_at';
|
|
|
|
}
|
|
|
|
|
2018-02-28 01:10:57 +00:00
|
|
|
abstract class LibrarySerializer {
|
2018-03-09 12:45:03 +00:00
|
|
|
static Library fromMap(Map map) {
|
2018-02-28 02:10:43 +00:00
|
|
|
return new Library(
|
2018-06-27 05:36:57 +00:00
|
|
|
id: map['id'] as String,
|
2018-02-28 02:10:43 +00:00
|
|
|
collection: map['collection'] is Map
|
2018-06-27 05:36:57 +00:00
|
|
|
? new Map.unmodifiable(
|
|
|
|
(map['collection'] as Map).keys.fold({}, (out, key) {
|
2018-02-28 02:10:43 +00:00
|
|
|
return out
|
2018-06-29 15:30:47 +00:00
|
|
|
..[key] = BookSerializer.fromMap(
|
|
|
|
((map['collection'] as Map)[key]) as Map);
|
2018-05-15 19:01:13 +00:00
|
|
|
}))
|
2018-02-28 02:10:43 +00:00
|
|
|
: null,
|
|
|
|
createdAt: map['created_at'] != null
|
2018-03-30 18:53:38 +00:00
|
|
|
? (map['created_at'] is DateTime
|
2018-06-27 05:36:57 +00:00
|
|
|
? (map['created_at'] as DateTime)
|
2018-03-30 18:53:38 +00:00
|
|
|
: DateTime.parse(map['created_at']))
|
2018-02-28 02:10:43 +00:00
|
|
|
: null,
|
|
|
|
updatedAt: map['updated_at'] != null
|
2018-03-30 18:53:38 +00:00
|
|
|
? (map['updated_at'] is DateTime
|
2018-06-27 05:36:57 +00:00
|
|
|
? (map['updated_at'] as DateTime)
|
2018-03-30 18:53:38 +00:00
|
|
|
: DateTime.parse(map['updated_at']))
|
2018-02-28 02:10:43 +00:00
|
|
|
: null);
|
|
|
|
}
|
|
|
|
|
2018-02-28 01:41:19 +00:00
|
|
|
static Map<String, dynamic> toMap(Library model) {
|
2018-06-28 01:58:42 +00:00
|
|
|
if (model == null) {
|
|
|
|
return null;
|
|
|
|
}
|
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
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2018-03-09 12:39:21 +00:00
|
|
|
|
|
|
|
abstract class LibraryFields {
|
|
|
|
static const String id = 'id';
|
|
|
|
|
|
|
|
static const String collection = 'collection';
|
|
|
|
|
|
|
|
static const String createdAt = 'created_at';
|
|
|
|
|
|
|
|
static const String updatedAt = 'updated_at';
|
|
|
|
}
|
2018-05-13 17:23:40 +00:00
|
|
|
|
|
|
|
abstract class BookmarkSerializer {
|
|
|
|
static Bookmark fromMap(Map map, Book book) {
|
2018-05-15 19:33:57 +00:00
|
|
|
if (map['page'] == null) {
|
|
|
|
throw new FormatException("Missing required field 'page' on Bookmark.");
|
|
|
|
}
|
|
|
|
|
2018-05-13 17:23:40 +00:00
|
|
|
return new Bookmark(book,
|
2018-06-27 05:36:57 +00:00
|
|
|
id: map['id'] as String,
|
|
|
|
history: map['history'] as List<int>,
|
|
|
|
page: map['page'] as int,
|
|
|
|
comment: map['comment'] as String,
|
2018-05-13 17:23:40 +00:00
|
|
|
createdAt: map['created_at'] != null
|
|
|
|
? (map['created_at'] is DateTime
|
2018-06-27 05:36:57 +00:00
|
|
|
? (map['created_at'] as DateTime)
|
2018-05-13 17:23:40 +00:00
|
|
|
: DateTime.parse(map['created_at']))
|
|
|
|
: null,
|
|
|
|
updatedAt: map['updated_at'] != null
|
|
|
|
? (map['updated_at'] is DateTime
|
2018-06-27 05:36:57 +00:00
|
|
|
? (map['updated_at'] as DateTime)
|
2018-05-13 17:23:40 +00:00
|
|
|
: DateTime.parse(map['updated_at']))
|
|
|
|
: null);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Map<String, dynamic> toMap(Bookmark model) {
|
2018-06-28 01:58:42 +00:00
|
|
|
if (model == null) {
|
|
|
|
return null;
|
|
|
|
}
|
2018-05-15 19:33:57 +00:00
|
|
|
if (model.page == null) {
|
|
|
|
throw new FormatException("Missing required field 'page' on Bookmark.");
|
|
|
|
}
|
|
|
|
|
2018-05-13 17:23:40 +00:00
|
|
|
return {
|
|
|
|
'id': model.id,
|
2018-05-13 18:02:47 +00:00
|
|
|
'history': model.history,
|
2018-05-13 17:23:40 +00:00
|
|
|
'page': model.page,
|
|
|
|
'comment': model.comment,
|
|
|
|
'created_at': model.createdAt?.toIso8601String(),
|
|
|
|
'updated_at': model.updatedAt?.toIso8601String()
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract class BookmarkFields {
|
|
|
|
static const String id = 'id';
|
|
|
|
|
2018-05-13 18:02:47 +00:00
|
|
|
static const String history = 'history';
|
|
|
|
|
2018-05-13 17:23:40 +00:00
|
|
|
static const String page = 'page';
|
|
|
|
|
|
|
|
static const String comment = 'comment';
|
|
|
|
|
|
|
|
static const String createdAt = 'created_at';
|
|
|
|
|
|
|
|
static const String updatedAt = 'updated_at';
|
|
|
|
}
|