validateCode method
POST /sdk/validate-code with a normalized (trim + UPPERCASE) code. Fail-soft.
Implementation
Future<CodeValidationResult> validateCode(String code) async {
if (!_initialized) {
return const CodeValidationResult(
valid: false,
error: 'SDK not initialized',
errorCode: 'NETWORK_ERROR',
);
}
try {
final resp = await _api!.postObject(
'/sdk/validate-code', {'code': code.trim().toUpperCase()},);
return CodeValidationResult.fromJson(resp);
} catch (e) {
_log('validateCode error: $e');
return const CodeValidationResult(
valid: false,
error: 'Network error or invalid response',
errorCode: 'NETWORK_ERROR',
);
}
}