newsfeed_following_entity.g.dart 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. import 'package:domain/generated/json/base/json_convert_content.dart';
  2. import 'package:domain/entity/newsfeed_following_entity.dart';
  3. NewsfeedFollowingEntity $NewsfeedFollowingEntityFromJson(
  4. Map<String, dynamic> json) {
  5. final NewsfeedFollowingEntity newsfeedFollowingEntity = NewsfeedFollowingEntity();
  6. final int? count = jsonConvert.convert<int>(json['count']);
  7. if (count != null) {
  8. newsfeedFollowingEntity.count = count;
  9. }
  10. final int? page = jsonConvert.convert<int>(json['page']);
  11. if (page != null) {
  12. newsfeedFollowingEntity.page = page;
  13. }
  14. final int? limit = jsonConvert.convert<int>(json['limit']);
  15. if (limit != null) {
  16. newsfeedFollowingEntity.limit = limit;
  17. }
  18. final int? countPage = jsonConvert.convert<int>(json['count_page']);
  19. if (countPage != null) {
  20. newsfeedFollowingEntity.countPage = countPage;
  21. }
  22. final List<NewsfeedFollowingList>? list = (json['list'] as List<dynamic>?)
  23. ?.map(
  24. (e) =>
  25. jsonConvert.convert<NewsfeedFollowingList>(e) as NewsfeedFollowingList)
  26. .toList();
  27. if (list != null) {
  28. newsfeedFollowingEntity.list = list;
  29. }
  30. return newsfeedFollowingEntity;
  31. }
  32. Map<String, dynamic> $NewsfeedFollowingEntityToJson(
  33. NewsfeedFollowingEntity entity) {
  34. final Map<String, dynamic> data = <String, dynamic>{};
  35. data['count'] = entity.count;
  36. data['page'] = entity.page;
  37. data['limit'] = entity.limit;
  38. data['count_page'] = entity.countPage;
  39. data['list'] = entity.list?.map((v) => v.toJson()).toList();
  40. return data;
  41. }
  42. extension NewsfeedFollowingEntityExtension on NewsfeedFollowingEntity {
  43. NewsfeedFollowingEntity copyWith({
  44. int? count,
  45. int? page,
  46. int? limit,
  47. int? countPage,
  48. List<NewsfeedFollowingList>? list,
  49. }) {
  50. return NewsfeedFollowingEntity()
  51. ..count = count ?? this.count
  52. ..page = page ?? this.page
  53. ..limit = limit ?? this.limit
  54. ..countPage = countPage ?? this.countPage
  55. ..list = list ?? this.list;
  56. }
  57. }
  58. NewsfeedFollowingList $NewsfeedFollowingListFromJson(
  59. Map<String, dynamic> json) {
  60. final NewsfeedFollowingList newsfeedFollowingList = NewsfeedFollowingList();
  61. final int? id = jsonConvert.convert<int>(json['id']);
  62. if (id != null) {
  63. newsfeedFollowingList.id = id;
  64. }
  65. final String? content = jsonConvert.convert<String>(json['content']);
  66. if (content != null) {
  67. newsfeedFollowingList.content = content;
  68. }
  69. final List<String>? resources = (json['resources'] as List<dynamic>?)?.map(
  70. (e) => jsonConvert.convert<String>(e) as String).toList();
  71. if (resources != null) {
  72. newsfeedFollowingList.resources = resources;
  73. }
  74. final int? likesCount = jsonConvert.convert<int>(json['likes_count']);
  75. if (likesCount != null) {
  76. newsfeedFollowingList.likesCount = likesCount;
  77. }
  78. final int? commentsCount = jsonConvert.convert<int>(json['comments_count']);
  79. if (commentsCount != null) {
  80. newsfeedFollowingList.commentsCount = commentsCount;
  81. }
  82. final bool? liked = jsonConvert.convert<bool>(json['liked']);
  83. if (liked != null) {
  84. newsfeedFollowingList.liked = liked;
  85. }
  86. final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  87. if (createdAt != null) {
  88. newsfeedFollowingList.createdAt = createdAt;
  89. }
  90. final NewsfeedFollowingListAccount? account = jsonConvert.convert<
  91. NewsfeedFollowingListAccount>(json['account']);
  92. if (account != null) {
  93. newsfeedFollowingList.account = account;
  94. }
  95. return newsfeedFollowingList;
  96. }
  97. Map<String, dynamic> $NewsfeedFollowingListToJson(
  98. NewsfeedFollowingList entity) {
  99. final Map<String, dynamic> data = <String, dynamic>{};
  100. data['id'] = entity.id;
  101. data['content'] = entity.content;
  102. data['resources'] = entity.resources;
  103. data['likes_count'] = entity.likesCount;
  104. data['comments_count'] = entity.commentsCount;
  105. data['liked'] = entity.liked;
  106. data['created_at'] = entity.createdAt;
  107. data['account'] = entity.account?.toJson();
  108. return data;
  109. }
  110. extension NewsfeedFollowingListExtension on NewsfeedFollowingList {
  111. NewsfeedFollowingList copyWith({
  112. int? id,
  113. String? content,
  114. List<String>? resources,
  115. int? likesCount,
  116. int? commentsCount,
  117. bool? liked,
  118. String? createdAt,
  119. NewsfeedFollowingListAccount? account,
  120. }) {
  121. return NewsfeedFollowingList()
  122. ..id = id ?? this.id
  123. ..content = content ?? this.content
  124. ..resources = resources ?? this.resources
  125. ..likesCount = likesCount ?? this.likesCount
  126. ..commentsCount = commentsCount ?? this.commentsCount
  127. ..liked = liked ?? this.liked
  128. ..createdAt = createdAt ?? this.createdAt
  129. ..account = account ?? this.account;
  130. }
  131. }
  132. NewsfeedFollowingListAccount $NewsfeedFollowingListAccountFromJson(
  133. Map<String, dynamic> json) {
  134. final NewsfeedFollowingListAccount newsfeedFollowingListAccount = NewsfeedFollowingListAccount();
  135. final int? id = jsonConvert.convert<int>(json['id']);
  136. if (id != null) {
  137. newsfeedFollowingListAccount.id = id;
  138. }
  139. final String? name = jsonConvert.convert<String>(json['name']);
  140. if (name != null) {
  141. newsfeedFollowingListAccount.name = name;
  142. }
  143. final String? avatar = jsonConvert.convert<String>(json['avatar']);
  144. if (avatar != null) {
  145. newsfeedFollowingListAccount.avatar = avatar;
  146. }
  147. final bool? followed = jsonConvert.convert<bool>(json['followed']);
  148. if (followed != null) {
  149. newsfeedFollowingListAccount.followed = followed;
  150. }
  151. return newsfeedFollowingListAccount;
  152. }
  153. Map<String, dynamic> $NewsfeedFollowingListAccountToJson(
  154. NewsfeedFollowingListAccount entity) {
  155. final Map<String, dynamic> data = <String, dynamic>{};
  156. data['id'] = entity.id;
  157. data['name'] = entity.name;
  158. data['avatar'] = entity.avatar;
  159. data['followed'] = entity.followed;
  160. return data;
  161. }
  162. extension NewsfeedFollowingListAccountExtension on NewsfeedFollowingListAccount {
  163. NewsfeedFollowingListAccount copyWith({
  164. int? id,
  165. String? name,
  166. String? avatar,
  167. bool? followed,
  168. }) {
  169. return NewsfeedFollowingListAccount()
  170. ..id = id ?? this.id
  171. ..name = name ?? this.name
  172. ..avatar = avatar ?? this.avatar
  173. ..followed = followed ?? this.followed;
  174. }
  175. }