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.
 
 

49 lines
1.5 KiB

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