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.
 
 

57 lines
1.6 KiB

class Campaign {
String campaignID;
String description;
String businessID;
String status;
String title;
DateTime startDate;
String targetProduct;
int rewards;
Campaign({
this.businessID,
this.campaignID,
this.description,
this.rewards,
this.startDate,
this.status,
this.targetProduct,
this.title,
});
factory Campaign.fromJSON(Map<String, dynamic> json) {
return Campaign(
businessID: json["businessId"],
campaignID: json["campaignId"],
description: json["description"],
status: json["status"],
title: json["title"],
startDate: DateTime.tryParse((json["startDate"].toString())),
targetProduct: json["targetProduct"],
rewards: int.tryParse((json["rewards"].toString())),
);
}
Map<dynamic, dynamic> toJson() {
final Map<dynamic, dynamic> data = Map<dynamic, dynamic>();
try {
data['businessId'] = this.businessID;
data['campaignId'] = this.campaignID;
data['description'] = this.description;
data['status'] = this.status.toString();
data['startDate'] = this.startDate.toString();
data['title'] = this.title;
data['targetProduct'] = this.targetProduct;
data['rewards'] = this.rewards;
} catch (e) {
print(e);
}
return data;
}
@override
String toString() {
return '{"businessId": "$businessID", "campaignId": "$campaignID", "description": "$description", "status": "$status",' +
'"startDate": "$startDate", "title": "$title", "targetProduct": "$targetProduct", "rewards": "$rewards"}';
}
}