class UserProfileDto {
  num id;
  String name;
  String email;
  String avatar;
  String ageRange;
  List<String> foodAllergiesList;
  List<String> dietaryPreferencesList;
  List<String> medicalInformationList;
  List<String> currentMedicationsList;
  String activityLevel;
  int? qStatus;

  UserProfileDto({
    this.id = 0,
    this.name = "",
    this.email = "",
    this.avatar = "",
    this.ageRange = "",
    List<String>? foodAllergiesList,
    List<String>? dietaryPreferencesList,
    List<String>? medicalInformationList,
    List<String>? currentMedicationsList,
    this.qStatus,
    this.activityLevel = "",
  }) : foodAllergiesList = foodAllergiesList ?? [],
       dietaryPreferencesList = dietaryPreferencesList ?? [],
       medicalInformationList = medicalInformationList ?? [],
       currentMedicationsList = currentMedicationsList ?? [];

  Map<String, dynamic> toJson() {
    return {
      "id": id,
      "name": name,
      "email": email,
      "avatar": avatar,
      "age_range": ageRange,
      "food_allergies": foodAllergiesList,
      "dietary_preferences": dietaryPreferencesList,
      "medical_information": medicalInformationList,
      "current_medications": currentMedicationsList,
      "activity_level": activityLevel,
      "q_status": qStatus,
    };
  }

  factory UserProfileDto.fromJson(Map<String, dynamic> json) {
    return UserProfileDto(
      id: json["id"] ?? 0,
      name: json["name"] ?? "",
      email: json["email"] ?? "",
      avatar: json["avatar"] ?? "",
      ageRange: json["age_range"] ?? "",
      foodAllergiesList: (json["food_allergies"] as List?)?.cast<String>() ?? [],
      dietaryPreferencesList: (json["dietary_preferences"] as List?)?.cast<String>() ?? [],
      medicalInformationList: (json["medical_information"] as List?)?.cast<String>() ?? [],
      currentMedicationsList: (json["current_medications"] as List?)?.cast<String>() ?? [],
      activityLevel: json["activity_level"] ?? "",
      qStatus: json["q_status"],
    );
  }
}
