2026-03-19 18:42:05 +08:00
|
|
|
class OtpSendRequest {
|
|
|
|
|
final String phone;
|
2026-02-25 14:45:08 +08:00
|
|
|
|
2026-03-19 18:42:05 +08:00
|
|
|
const OtpSendRequest({required this.phone});
|
2026-02-25 14:45:08 +08:00
|
|
|
|
2026-03-19 18:42:05 +08:00
|
|
|
Map<String, dynamic> toJson() => {'phone': _normalizePhone(phone)};
|
2026-02-25 14:45:08 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-19 18:42:05 +08:00
|
|
|
class PhoneSessionRequest {
|
|
|
|
|
final String phone;
|
2026-02-25 14:45:08 +08:00
|
|
|
final String token;
|
|
|
|
|
|
2026-03-19 18:42:05 +08:00
|
|
|
const PhoneSessionRequest({required this.phone, required this.token});
|
2026-02-25 14:45:08 +08:00
|
|
|
|
2026-03-19 18:42:05 +08:00
|
|
|
Map<String, dynamic> toJson() => {
|
|
|
|
|
'phone': _normalizePhone(phone),
|
|
|
|
|
'token': token,
|
|
|
|
|
};
|
2026-02-25 14:45:08 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-19 18:42:05 +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
|
|
|
}
|