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.9 KiB

3 years ago
class CouponsHead {
String? couponId;
String? businessId;
String? targetProduct;
String? type;
int? quantity;
DateTime? expiration;
double? lower;
double? upper;
String? state;
DateTime? generated;
3 years ago
CouponsHead(
{this.businessId,
this.couponId,
this.expiration,
this.quantity,
this.state,
this.targetProduct,
this.type,
this.lower,
this.upper,
this.generated});
CouponsHead.fromJSON(Map<dynamic, dynamic> json)
: businessId = json['businessId'],
couponId = json['couponId'],
expiration = DateTime.tryParse((json['expiration']).toString()),
generated = DateTime.tryParse((json['generated']).toString()),
quantity = int.parse((json['quantity']).toString()),
state = json['state'],
type = json['type'],
targetProduct = json['targetProduct'],
lower = double.parse((json['lower']).toString()),
upper = double.parse((json['upper']).toString());
Map<dynamic, dynamic> toJson() {
3 years ago
final Map<dynamic, dynamic> data = Map<dynamic, dynamic>();
data['businessID'] = this.businessId;
data['couponID'] = this.couponId;
data['expiration'] = this.expiration!.toIso8601String();
3 years ago
data['generated'] = this.generated != null
? this.generated!.toIso8601String()
3 years ago
: DateTime.now().toIso8601String();
data['quantity'] = this.quantity;
data['state'] = this.state;
data['type'] = this.type;
data['targetProduct'] = this.targetProduct;
data['lowerlimit'] = this.lower.toString();
data['upperlimit'] = this.upper.toString();
return data;
}
@override
String toString() {
return '{"businessID": "$businessId","couponID": "$couponId", "expiration": "$expiration", "generated": "$generated","quantity": "$quantity",' +
'"state": "$state", "type": "$type", "targetProduct": "$targetProduct","lower": "$lower","upper": "$upper"}';
}
}