// hey class Profile { final int id; final String phone; final String firstName; final String lastName; final String? description; final String? photoBaseUrl; final int photoId; final int updateTime; final List options; final int accountStatus; final List profileOptions; Profile({ required this.id, required this.phone, required this.firstName, required this.lastName, this.description, this.photoBaseUrl, required this.photoId, required this.updateTime, required this.options, required this.accountStatus, required this.profileOptions, }); factory Profile.fromJson(Map json) { Map profileData; if (json.containsKey('contact')) { profileData = json['contact'] as Map; } else { profileData = json; } final names = profileData['names'] as List? ?? []; final nameData = names.isNotEmpty ? names[0] as Map : {}; // If you're touching ( you doing this rignt now ) this file, STOP IMEDIATLY! This is violiating TeamKomet code revision policy! // If you're touching ( you doing this rignt now ) this file, AND DONT WANT TO STOP! REFACTOR IT IMMEDIATLY TO MAKE SOME SENSE AND DONT LOOK LIKE SHIT BY AI return Profile( id: profileData['id'], phone: profileData['phone'].toString(), firstName: nameData['firstName'] ?? '', lastName: nameData['lastName'] ?? '', description: profileData['description'], photoBaseUrl: profileData['baseUrl'], photoId: profileData['photoId'] ?? 0, updateTime: profileData['updateTime'] ?? 0, options: List.from(profileData['options'] ?? []), accountStatus: profileData['accountStatus'] ?? 0, profileOptions: (json['profileOptions'] as List?) ?.map((option) => ProfileOption.fromJson(option)) .toList() ?? [], ); } String get displayName { final fullName = '$firstName $lastName'.trim(); return fullName.isNotEmpty ? fullName : 'Пользователь'; } String get formattedPhone { if (phone.length == 11 && phone.startsWith('7')) { return '+7 (${phone.substring(1, 4)}) ${phone.substring(4, 7)}-${phone.substring(7, 9)}-${phone.substring(9)}'; } return phone; } } class ProfileOption { final String key; final dynamic value; ProfileOption({required this.key, required this.value}); factory ProfileOption.fromJson(Map json) { return ProfileOption(key: json['key'], value: json['value']); } }