toPostJson method
Converts the body data model to a JSON object for a POST request.
This method should be implemented by subclasses to convert their specific data to a JSON object. It should only include properties that need to be sent in a POST request.
Implementation
@override
Map<String, dynamic>? toPostJson() {
Map<String, dynamic> data = <String, dynamic>{};
data['type'] = type.toString().split('.').last;
data['note'] = note;
data['billingAddressId'] = billingAddressId;
data['shippingAddressId'] = shippingAddressId;
if (campaigns != null) {
data['campaigns'] = campaigns?.map((e) => e.toJson()).toList();
}
if (billingAddress != null) {
data['billingAddress'] = billingAddress?.toJson();
}
if (shippingAddress != null) {
data['shippingAddress'] = shippingAddress?.toJson();
}
data['paymentMethod'] = paymentMethod;
data['deliveryDate'] = deliveryDate;
return data;
}