Files
prosappweb/lib/models/usuario.dart
T
Lizandro GuarnizoandClaude Sonnet 4.6 0ecca498ad fix: align Flutter endpoints and model parsing with actual NestJS backend
- Auth: phone login → POST /auth/phone (direct, no OTP); link phone → POST /auth/verify-phone; add email → POST /auth/link-email
- Services: replace query-param paths with dedicated role endpoints (/services/me, /services/professional/requests, /services/professional, etc.)
- Services: PATCH /services/:id → PATCH /services/:id/status
- Calendar: → GET /services/professional/calendar
- Professionals: /users/professionals → /professionals (handles {data:[...]} response)
- Professional info: /professional-info/:id → /professionals/:id; PATCH → /professionals/me
- Comments: /comments?... → /comments/user/:id and /comments/professional/:id
- Chat: /chats → /chat; start chat → POST /chat/start/:professionalId; poll GET /chat/:chatId/messages; send → POST /chat/:chatId/message
- Cities: /cities → GET /locations/countries (parse nested countries→regions→cities)
- Profesional.fromDocument: null-safe fields; convert schedules array→Schedules, specializations array→name/picture lists, payment_methods object/array
- Usuario.fromDocument: null-safe professional_state and id
- UsuarioProfesional.fromDocument: handle backend format (users nested, professional at top level)
- ScheduleEntity.parseTime: handle ISO8601 time strings from backend
- MessageEntity.fromDocument: accept sender_id (backend) or owner_id (legacy)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-18 16:07:44 -05:00

67 lines
1.7 KiB
Dart

import 'package:prosapp_web_app/models/pro_state.dart';
class Usuario {
final String id;
final String? email;
final String? phone;
final String name;
final String? nickname;
final String? city;
final String? picture;
final String? birthday;
final String? gender;
final ProState proState;
final String? token;
Usuario({
required this.id,
required this.email,
required this.phone,
required this.name,
required this.nickname,
required this.city,
required this.picture,
required this.birthday,
required this.gender,
required this.proState,
required this.token,
});
Map<String, Object?> toDocument() {
return {
'id': id,
'email': email,
'phone': phone,
'name': name,
'nickname': name.toLowerCase().trim().replaceAll(' ', '_'),
'city': city,
'picture': picture,
'birthday': birthday,
'gender': gender,
'professional_state': enumToInt(proState),
'token': token,
};
}
static Usuario fromDocument(Map<String, dynamic> doc) {
return Usuario(
id: (doc['id'] as String?) ?? '',
email: doc['email'],
phone: doc['phone'],
name: doc['name'] ?? '',
nickname: doc['nickname'],
city: doc['city'],
picture: doc['picture'],
birthday: doc['birthday'],
gender: doc['gender'],
proState: intToEnum((doc['professional_state'] as int?) ?? 0),
token: doc['token'],
);
}
@override
String toString() {
return 'User(id: $id, email: $email, phone: $phone, name: $name, nickname: $nickname, city: $city, picture: $picture, birthday: $birthday, gender: $gender, proState: $proState, token: $token)';
}
}