toJson method
Converts the BaseDTO to a JSON object.
This method can be used when making HTTP requests to convert the DTO to a format that can be sent in the request.
Implementation
@override
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = super.toJson();
data['status'] = status.toString().split('.').last;
data['type'] = type;
data['isPaid'] = isPaid;
data['isTest'] = isTest;
data['customerNote'] = customerNote;
data['storeNote'] = storeNote;
data['paymentMethod'] = paymentMethod;
if (store != null) {
data['store'] = store!.toJson();
}
if (campaigns != null) {
data['campaigns'] = campaigns!.map((v) => v.toJson()).toList();
}
if (customer != null) {
data['customer'] = customer!.toJson();
}
if (billingAddress != null) {
data['billingAddress'] = billingAddress!.toJson();
}
if (shippingAddress != null) {
data['shippingAddress'] = shippingAddress!.toJson();
}
if (invoices != null) {
data['invoices'] = invoices!.map((v) => v.toJson()).toList();
}
data['deliveryDate'] = deliveryDate;
return data;
}