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 = <String, dynamic>{};
data['id'] = super.id;
data['createdAt'] = super.createdAt;
data['updatedAt'] = super.updatedAt;
data['isActive'] = super.isActive;
data['isDeleted'] = super.isDeleted;
data['title'] = title;
data['description'] = description;
data['photoUrl'] = photoUrl;
data['oneSignalId'] = oneSignalId;
if (user != null) {
data['user'] = user!.toJson();
}
if (products != null) {
data['products'] = products!.map((v) => v.toJson()).toList();
}
if (categories != null) {
data['categories'] = categories!.map((v) => v.toJson()).toList();
}
if (campaigns != null) {
data['campaigns'] = campaigns!.map((v) => v.toJson()).toList();
}
return data;
}