verifyOtp method
Implementation
@override
Future<AuthResult<bool>> verifyOtp(String contact, String otp, AuthMethod method) async {
try {
final response = await _client.post(
Uri.parse('$baseUrl/auth/verify-otp'),
headers: _headers,
body: jsonEncode({'contact': contact, 'otp': otp, 'method': method.name}),
);
final result = _handleResponse<Map<String, dynamic>>(response, (json) => json);
return result.fold(
(data) => AuthResult.success(data['verified'] as bool? ?? false),
(error) => AuthResult.failure(error),
);
} catch (e) {
return AuthResult.failure(AuthException(e.toString(), code: 'network-error'));
}
}