You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.8 KiB
60 lines
1.8 KiB
import 'package:teso/Classes/API%20Clasess/CampAd.dart';
|
|
import 'package:teso/Classes/API%20Clasess/CommentsPost.dart';
|
|
import 'package:teso/Classes/API%20Clasess/Post.dart';
|
|
import 'package:teso/Classes/API%20Clasess/PostFav.dart';
|
|
import 'package:teso/Classes/TesoUser.dart';
|
|
|
|
class PostedAd {
|
|
Post post;
|
|
List<PostFav> likes;
|
|
List<CommentsPost> comments;
|
|
bool campaignAd;
|
|
CampAd campAdvert;
|
|
TesoUser publisher;
|
|
|
|
PostedAd({
|
|
this.post,
|
|
this.likes,
|
|
this.comments,
|
|
List<TesoUser> friends,
|
|
this.campaignAd,
|
|
this.campAdvert,
|
|
this.publisher,
|
|
});
|
|
factory PostedAd.fromJSON(Map<String, dynamic> json) {
|
|
var favorites = json["likes"] as List;
|
|
List<PostFav> favs = favorites.map((e) => PostFav.fromJSON(e)).toList();
|
|
var comments = json["comments"] as List;
|
|
List<CommentsPost> cmnt =
|
|
comments.map((e) => CommentsPost.fromJSON(e)).toList();
|
|
|
|
return PostedAd(
|
|
post: Post.fromJSON(json["post"]),
|
|
likes: favs,
|
|
comments: cmnt,
|
|
campaignAd: json["campaignAd"],
|
|
campAdvert: json["campaignAdvert"] != null
|
|
? CampAd.fromJSON(json["campaignAdvert"])
|
|
: null,
|
|
publisher: json["publisher"] != null
|
|
? TesoUser.fromJSON(json["publisher"])
|
|
: null,
|
|
);
|
|
}
|
|
|
|
Map<dynamic, dynamic> toJson() {
|
|
final Map<dynamic, dynamic> data = Map<dynamic, dynamic>();
|
|
data['post'] = this.post;
|
|
data['likes'] = this.likes;
|
|
data['comments'] = this.comments;
|
|
data['campaignAd'] = this.campaignAd;
|
|
data['campaignAdvert'] = this.campaignAd;
|
|
data['publisher'] = this.publisher;
|
|
return data;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return '{"post": "$post", "likes": "$likes", "comments": "$comments","campaignAd" :"$campaignAd","campaignAdvert":"$campAdvert", "publisher":"$publisher"}';
|
|
}
|
|
}
|
|
|