toJson method

  1. @override
Map<String, dynamic> toJson()
override

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['email'] = email;
  data['passwordChangedAt'] = passwordChangedAt;
  data['isGuest'] = isGuest;
  data['isTest'] = isTest;
  data['type'] = type;
  if (detail != null) {
    data['detail'] = detail!.toJson();
  }
  if (addresses != null) {
    data['addresses'] = addresses!.map((v) => v.toJson()).toList();
  }
  if (roles != null) {
    data['roles'] = roles!.map((v) => v.toJson()).toList();
  }
  if (stores != null) {
    data['stores'] = stores!.map((v) => v.toJson()).toList();
  }
  return data;
}