Files
social-app/apps/lib/features/auth/data/models/signup_request.dart
T

29 lines
684 B
Dart
Raw Normal View History

class OtpSendRequest {
final String phone;
2026-02-25 14:45:08 +08:00
const OtpSendRequest({required this.phone});
2026-02-25 14:45:08 +08:00
Map<String, dynamic> toJson() => {'phone': _normalizePhone(phone)};
2026-02-25 14:45:08 +08:00
}
class PhoneSessionRequest {
final String phone;
2026-02-25 14:45:08 +08:00
final String token;
const PhoneSessionRequest({required this.phone, required this.token});
2026-02-25 14:45:08 +08:00
Map<String, dynamic> toJson() => {
'phone': _normalizePhone(phone),
'token': token,
};
2026-02-25 14:45:08 +08:00
}
String _normalizePhone(String input) {
var normalized = input.trim();
normalized = normalized.replaceAll(RegExp(r'[\s\-\(\)]'), '');
if (normalized.startsWith('00') && normalized.length > 2) {
return '+${normalized.substring(2)}';
}
return normalized;
2026-02-25 14:45:08 +08:00
}