import 'package:teso/Classes/API%20Clasess/CouponDetails.dart'; import 'package:teso/Classes/API%20Clasess/Product.dart'; import '../TesoUser.dart'; class BusinessProfileClass { List products; List coupons; List subscribers; bool subscribed; BusinessProfileClass({ this.coupons, this.products, this.subscribed, this.subscribers, }); factory BusinessProfileClass.fromJSON(Map json) { var subscribers = json["subscribers"] as List; List subs = subscribers.map((e) => TesoUser.fromJSON(e)).toList(); subs.removeWhere( (element) => element.userGUID == "null" || element.userGUID == null); var comments = json["coupons"] as List; List cmnt = comments.map((e) => CouponDetails.fromJSON(e)).toList(); var prod = json["products"] as List; List pro = prod.map((e) => Product.fromJson(e)).toList(); return BusinessProfileClass( coupons: cmnt, products: pro, subscribed: json["subscribed"], subscribers: subs); } Map toJson() { final Map data = Map(); data['coupons'] = this.coupons; data['subscribers'] = this.subscribers; data['products'] = this.products; data['subscribed'] = this.subscribed; return data; } @override String toString() { return '{"coupons": "$coupons", "subscribers": "$subscribers", "subscribed": "$subscribed","products" :"$products"}'; } }